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
| Argument | Type | Default | Description |
|---|---|---|---|
| ARRAY | array name | required | The name of the shared array. |
| ELEMENT | string | required | The name of the element. |
| FIRST | index | required | The index of the first element to replace. |
| LAST | index | required | The index of the last element to replace. |
| VALUE | string | none | A 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