Version 8 of concat

Updated 2003-08-04 09:06:02

Documentation for concat can be found at http://purl.org/tcl/home/man/tcl8.4/TclCmd/concat.htm


To concat an explicit empty list and another list use:

  set a [concat {{}} {a} {b}]

DGP No, that example concatenates three single-element lists into a single three-element list. Likewise, so does

  set a [concat [list {}] a b]

Don't confuse an empty list (a list of 0 elements), with a single-element list whose element happens to be an empty string.

Also don't imagine that braces have magic list-ifying powers.


When does one use concat compared to other Tcl methods of putting two strings together?

See Concatenating lists for a timing comparison of various methods.


Concatenating the sublists of a list (e.g. a matrix) is best done with join.


[ Tcl syntax help - Arts and crafts of Tcl-Tk programming - Category Command of Tcl ]