lrepeat
Makes a list with the same elements repeated a number of times.
lrepeat COUNT ?ELEMENT ...?
Description
Gives a list of the ELEMENT arguments, in order, COUNT times. Each ELEMENT stays one element. A COUNT of 0 gives an empty list, and so does no ELEMENT. A negative COUNT is an error. The result counts toward the memory limit of the interpreter.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| COUNT | integer, 0 or more | required | The count of copies. |
| ELEMENT | any value | none | An element of each copy. |
Returns
The new list.
Examples
% lrepeat 3 a b
a b a b a b
% lrepeat 2 {a b}
{a b} {a b}
% lrepeat 0 a
Errors
% lrepeat -1 a
bad count "-1": must be integer >= 0
-errorcode NONE
% lrepeat x a
expected integer but got "x"
-errorcode NONE
Differences from Tcl
- The errors have
-errorcode NONE, where Tcl 8.6.16 and 9.0.4 giveTCL OPERATION LREPEAT NEGARGandTCL VALUE NUMBER(issue 658).
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.1