Retrieving an Element of an Array: Difference between revisions

→‎{{header|Tcl}}: xref to lists
(→‎{{header|Tcl}}: xref to lists)
Line 453:
=={{header|Tcl}}==
All arrays in Tcl are associative. If "key" is the variable that holds the key of the element to be retrieved, then
<lang tcl>set result $array($key)</lang>
 
If you are looking for a collection of values that are indexed by number, you want a list. List are indexed into with the <tt>lindex</tt> command:
set result $array($key)
<lang tcl>set result [lindex $list $index]</lang>
 
=={{header|Toka}}==
Anonymous user