From a usage point of view, a list is a finite ordered collection of element as (a,b,…,z).
In Tcl, a list consists of a string whose items are separated by white space. For example, this is a list,
1 2 3 4 5
In other languages, a list is sometimes known as :
Tcl lists are not fixed-length once created, as is the case in some other languages.
You can assign a list direct to a variable with the curly brace charcater.
set MyList {1 2 3 4 5}
or you can construct it using the list command as:
set MyList [list A B C D E]
To retrieve the element at a particular index one uses the lindex command.
lindex $MyList 1
will return the value 2 because the first element is indexed to zero.
Elements can be appended to a list stored in a variable using the lappend command. (Hence, Tcl lists are not fixed-length once created, as is the case in some other languages.)
The llength command computes the length of any list for you.