-
Notifications
You must be signed in to change notification settings - Fork 0
Loops
MRH edited this page Sep 18, 2020
·
2 revisions
There are three types of procedural loops:
loop loops through an iterator
loop let i in 0..10: out i;
In the example above the loop will iterate through the 0..10 iterator (0 through 10) and output the numbers.
The loop can also iterate through objects and arrays like this:
`
a = new [5, 7, 3, 1];
loop let e of a:
out i;
loop let i in a: out i; ` The of operator creates an element iterator from the array and the in operator creates a index iterator.
The while loop will loop until the statement is false:
i = 0; while i < 10: i++;
The do loop is the same as a while but it does a statement check at the end of a iteration instead of before like the while loop.
i = 0; do i < 10: i++;