list

Makes a list with each argument as one element.

list ?ARG ...?

Description

Makes a list with each argument as one element, in order. It adds the braces and backslashes that an element needs, so that each value stays one element when the list is read again: a value with a space gets braces, and a value with an unbalanced brace gets backslashes.

With no argument it gives an empty list. An empty argument is an element too, and it shows as {}.

Arguments

ArgumentTypeDefaultDescription
ARGany valuenoneOne element of the list.

Returns

The new list.

Examples

% list a "b c" {}
a {b c} {}

% list

# Backslashes keep an unbalanced brace in its element.
% list "a{b" "c}" {$x} "#x"
a\{b c\} {$x} #x

% llength [list "a b" c]
2

Errors

Each count of arguments is valid, also none, and each value can be an element.

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.1

See also