Version 6 of append

Updated 2001-11-11 23:51:13

For the full man page, see http://www.purl.org/tcl/home/man/tcl8.4/TclCmd/append.htm

   NAME  append - Append to variable

   SYNOPSIS  append varName ?value value value ...?

   DESCRIPTION   Append all of the value arguments to the current value
                 of variable varName. If varName doesn't exist, it is
                 given a value equal to the concatenation of all the
                 value arguments. This command provides an efficient
                 way to build up long variables incrementally. For
                 example, ``append a $b'' is much more efficient than
                 ``set a $a$b'' if $a is long.

SEE ALSO concat, lappend


Is the result of an append of two lists a list as you might expect it? (Peter Lewerin: Yes, because append is not lappend.)

 set a [list a b c]
 set b [list 1 2 3]
 append a $b
 puts $a

Note that the third element of this new list is not c, but c1. Does anyone know if there are cases where an append would result in something not a list?


Here's an example of such a case:

 set l1 [list a {b c}]
 set l2 [list {d e} f]
 append l1 $l2
 llength $l1

Tcl syntax help Arts and crafts of Tcl-tk programming Category Command