Loops
Otter has four readable ways to repeat work.
repeat: a fixed number of times
Otter
repeat 3 times
say "Hip hip hooray!"
.
while: as long as a condition holds
Otter
counter is 1
while counter is at most 3
say "While counter:" counter
add 1 to counter
.
count: through a numeric range
Both the start and the end are inclusive.
Otter
count from 1 to 4 as n
say "Counted:" n
.
Output
Counted: 1
Counted: 2
Counted: 3
Counted: 4
each: through a list
Otter
games are
"Zelda"
"Metroid"
"Mario"
.
each game in games
say "Game:" game
.
Output
Game: Zelda
Game: Metroid
Game: Mario
each item in items is the canonical form. for each is also accepted for older programs.
Next: lists