beetlebug▾
/

tsv lpush

Puts one element into a list in a shared array, at the start by default.

tsv::lpush ARRAY ELEMENT VALUE ?INDEX?

Description

The command tsv::lpush puts VALUE into the list in the element before the element at INDEX, 0 by default, so with no INDEX it goes at the start. end puts it at the end in amortized constant time. An element that does not exist starts as an empty list.

Arguments

ArgumentTypeDefaultDescription
ARRAYarray namerequiredThe name of the shared array.
ELEMENTstringrequiredThe name of the element.
VALUEstringrequiredThe element to put in.
INDEXindex0The place of the new element.

Returns

An empty string.

Examples

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

% tsv::set l x {b c}
> tsv::lpush l x d end
> tsv::get l x
b c d

Errors

% tsv::set l x {b c}
> tsv::lpush l x
wrong # args: should be "tsv::lpush l x element ?index?"
-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