beetlebug▾
/

tsv lreplace

Replaces a range of a list in a shared array.

tsv::lreplace ARRAY ELEMENT FIRST LAST ?VALUE ...?

Description

The command tsv::lreplace replaces the elements from FIRST to LAST of the list in the element with the VALUE words, as lreplace does, and changes the list in place. With no VALUE, it removes the range.

Arguments

ArgumentTypeDefaultDescription
ARRAYarray namerequiredThe name of the shared array.
ELEMENTstringrequiredThe name of the element.
FIRSTindexrequiredThe index of the first element to replace.
LASTindexrequiredThe index of the last element to replace.
VALUEstringnoneA new element.

Returns

An empty string.

Examples

% tsv::set l x {a b c}
> tsv::lreplace l x 0 1 Z
> tsv::get l x
Z c

% tsv::set l x {a b c}
> tsv::lreplace l x 0 0
> tsv::get l x
b c

Errors

% tsv::set l x {a b c}
> tsv::lreplace l x 0
wrong # args: should be "tsv::lreplace l x first last ?element ...?"
-errorcode TCL WRONGARGS

Facts

Capability
thread. A new interpreter does not have it until the host turns it on.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.1

See also