Skip to content
Tcl Source Code Artifact [107fd77e52]
Login

Artifact [107fd77e52]

Artifact 107fd77e525e95b0c44aa75fff90ad2fc250e221e3e45d8b08a7acd27fec8e3a:



CommandName: lrepeat ManualSection: n Version: 8.5 TclPart: Tcl TclDescription: Tcl Built-In Commands Links:

Name

lrepeat - Build a list by repeating elements

Synopsis

::: {.synopsis} ::: [lrepeat]{.cmd} [count]{.arg} [element]{.optdot} :::

Description

The fBlrepeatfR command creates a list of size fIcount * number of elementsfR by repeating fIcountfR times the sequence of elements fIelement ...fR. fIcountfR must be a non-negative integer, fIelementfR can be any Tcl value.

Note that fBlrepeat 1 element ...fR is identical to fBlist element ...fR.

Examples

lrepeat 3 a
      \(-> a a a
lrepeat 3 [lrepeat 3 0]
      \(-> {0 0 0} {0 0 0} {0 0 0}
lrepeat 3 a b c
      \(-> a b c a b c a b c
lrepeat 3 [lrepeat 2 a] b c
      \(-> {a a} b c {a a} b c {a a} b c