2 ms·
> Could be a function, an integer, a map, or an array. It is an array. 'incr' is a built in function that "increments" a variable by one. Variable names foll
by pwg 3y ago
> Could be a function, an integer, a map, or an array.
It is an array. 'incr' is a built in function that "increments" a variable by one.
Variable names followed by parenthesis () are Tcl arrays. So count(...) is "array syntax".
> Same problem with this:
> >foreach {line n} [array get count]
This is roughly equivalent to Python's "list comprehensions". "array get count" produces a list of values from the contents of the array named count (the list is "key1 value1 key2 value2 key3 value3 ..."
foreach is Tcl's "iterate over a list" function. In this case it is iterating two variables over the list at the same time taking two elements off the list each time. The first element is assigned to "line" the second element to "n".