RosettaCodeData/Task/Loops-Foreach/LIL/loops-foreach.lil
2023-07-01 13:44:08 -04:00

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"