1lappend(n) Tcl Built-In Commands lappend(n)
2
3
4
5______________________________________________________________________________
6
8 lappend - Append list elements onto a variable
9
11 lappend varName ?value value value ...?
12______________________________________________________________________________
13
15 This command treats the variable given by varName as a list and appends
16 each of the value arguments to that list as a separate element, with
17 spaces between elements. If varName does not exist, it is created as a
18 list with elements given by the value arguments. Lappend is similar to
19 append except that the values are appended as list elements rather than
20 raw text. This command provides a relatively efficient way to build up
21 large lists. For example, “lappend a $b” is much more efficient than
22 “set a [concat $a [list $b]]” when $a is long.
23
25 Using lappend to build up a list of numbers.
26
27 % set var 1
28 1
29 % lappend var 2
30 1 2
31 % lappend var 3 4 5
32 1 2 3 4 5
33
35 list(n), lindex(n), linsert(n), llength(n), lset(n), lsort(n),
36 lrange(n)
37
39 append, element, list, variable
40
41
42
43Tcl lappend(n)