Loops
Ascending for loops include both bounds. If the start is omitted, it is zero:
for i to 3 do
print(i) // 0, 1, 2, 3 on separate lines
end
for i = 2 to 4 do
print(i)
endDescending loops also include both bounds:
for i = 3 downto 1 do
print(i)
endWhile loops use do and end:
while count < 10 do
count += 1
endLoop bounds must be integers. The loop variable is a new int visible only
inside the loop body, and the end bound is evaluated before every iteration.
A for loop with in visits the elements of an array, the characters of a
string, or the keys of a map. With two names, the first is the index (for a
map, the key) and the second the element (for a map, the value):
for color in colors do
print(color)
end
for i, color in colors do
print(i, color)
end
for name, age in ages do
print(name, age)
end_ in place of a name skips it. An array or string is read by index while the
index is below its length, so elements added during the loop are visited too.
A map's keys and values are copied when the loop starts, so changing the map
inside the loop does not change what it visits.
break and continue are valid only inside for or while loops.