In Tcl, the concept of an array is different from many other programming languages, and the fact that Tcl calls an array is often called a hash map or associative array elsewhere. Array indices are not limited to integers, but can be any legal strings. In most cases, I use lists (or lists of lists) instead of arrays to process the data. You can use the foreach command to loop through an entire list or array.
foreach {index content} [array get date] { put $index: $content }
You do not need to initialize the array before setting its values, just start adding it. The individual elements of the array refer to
$array($key) or $array("abc")
There are no multidimensional arrays in Tcl, but they can be modeled with consistent key names, for example
set a(1,1) 0 set a(1,2) 1 ...
Other than that, Iβll just show you the mostly excellent Tcl wiki and the array page and the man page array for syntax problems, since I donβt see the point repeating most of their contents here.
source share