Fermat
Search
K
Comment on page

For

The for each in command iterates through the elements inside a structure:
for each in [structure] ([ID]):
[body] -- ID is accessible
end
In the case of a textual structure, the loop iterates over each character of the text:
for each in "hello" (it):
print it is "l"
end
Output:
> false
> false
> true
> true
> false
In the case of lists, the loop iterates over each element of the list:
for each in [1,2,3] (it):
print it + 1
end
Output:
> 2
> 3
> 4
In the case of dictionaries, the loop iterates over each key and value pair, so there are two [ID]s:
for each in {"cat" to 20 "dog" to 200 }(key, value):
print value + 100
end
Output:
> 120
> 300