13.32.7 Lists and Arrays

A list is a way to group data and handle the group as a single entity. To define a list, use curly braces { } and double quotes “ “. For example, the following set command {1 2 3}, when followed by the list command, creates a list stored in the variable "a." This list will contain the items "1," "2," and "3."

set a { 1 2 3 }

Here's another example:

set e 2

set f 3

set a [ list b c d [ expr $e + $f ] ] puts $a

displays (or outputs):

b c d 5

Tcl supports many other list-related commands such as lindex, linsert, llength, lrange, and lappend. For more information, refer to one of the books or web sites available on this subject.