RosettaCodeData/Task/Loops-Foreach/LIL/loops-foreach.lil

13 lines
468 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
# 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"