lreverse

Gives the elements of a list in the reverse order.

lreverse LIST

Description

Gives a new list with the elements of LIST from the last to the first. Each element stays whole: a nested list is one element and keeps its own order. An empty list gives an empty list.

Arguments

ArgumentTypeDefaultDescription
LISTlistrequiredThe list.

Returns

The new list.

Examples

% lreverse {a b c}
c b a

% lreverse {a {b c}}
{b c} a

% lreverse {}

Errors

% lreverse "a {b"
unmatched open brace in list
-errorcode TCL VALUE LIST BRACE

% lreverse
wrong # args: should be "lreverse list"
-errorcode TCL WRONGARGS

Facts

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

See also