12 lines
468 B
Text
12 lines
468 B
Text
# Loops/Foreach, in LIL
|
|
set collection [list 1 2 "three"]
|
|
append collection [list 4 5 six] # appended as a single item in collection
|
|
print "Collection is: $collection"
|
|
|
|
# using default "i" variable name set for each item
|
|
foreach $collection {print $i}
|
|
|
|
# user named variable in the steps, retrieving accumulated result of loop
|
|
# each loop step quotes two copies of the item
|
|
set newlist [foreach j $collection {quote $j $j}]
|
|
print "Result of second foreach: $newlist"
|