Name
foreach
— Iterate over elements in a list.
Synopsis
foreach
varname
list
body
foreach
varlist
list
body
Description
The foreach command iterates over a list. For each element
of the list,
varname
is set
to a new element of the list, and then
body
is run.
Example
set lst {a b c d e}
set res {}
foreach el $lst {
append $res $el
}
puts $res
Produces:
abcde