Purpose: to discuss the benefits and tricks to using Tcl '''arrays'''. ---- What Tcl refers to as an ''array'' has other names in other languages. Awk calls them ''associative arrays'' and some language (??) calls them ''hash maps''. In Python, ''dictionaries'' are pretty much the same. The reason this is an important concept up front is that Tcl does not provide a simple numerically indexed array in the traditional sense. Instead, the index for a Tcl array is a Tcl string. Tcl arrays are one dimensional. However, as [Laurent Duperval] recently mentioned in news:comp.lang.tcl, if you are careful you can simulate a multi-dimensional array like this: for {set i 0} {$i < 10} {incr i} { for {set j 0} {$j < 10} {incr j} { set a($i,$j) "Value for i = $i and j = $j" puts "$a($i,$j)" } } Note however that "$i,$j" is parsed into a string that differs from the string "$i, $j" for instance -- it is best never to put blanks in the text of your array keys. Also, for this type of application, it is much better to use integer values for i and j rather than characters. Otherwise, as in the previous point, you might run into cases where white space varies within the values of i and j, resulting in missed values. ---- Note that if you really ''do'' want to have spaces (or other Tcl-significant characters) in your array indexes, you can still do this by putting the index into a variable and then using the dereferenced variable as your index: % set idx "The quick brown fox" % set ary($idx) "jumped over the lazy dogs." % parray ary ary(The quick brown fox) = jumped over the lazy dogs. You can even have the name of the array with a space in, but accessing it then takes the application of an [[upvar]] to convert to a more usable form... '''DKF''' ---- It's also important to know that arrays have no implicit string representation other than their name (and are thus mostly passed around by name-dropping and upvar). Explicit conversion from and to pairlists with alternating key/value is done with set L [array get A] ;# resp. array set A $L You can use this technique for complex structures, e.g. put arrays (transformed to pairlists) into array elements and unpack them into a temporary array as needed. ''RS''