May 2018
Beginner
252 pages
6h 19m
English
On other occasions, you might want the loop continuations to depend on a condition:
You may want to continue while a certain condition is true, and stop with the loop when the condition turns false
You may want to do the opposite—loop until a certain condition is true
Here is an example of the while word, printing out the odd integers smaller than 10:
n: 1 while [n <= 10 ][ if odd? n [prin n prin " "] n: n + 1 ] ;== 1 3 5 7 9
We can have the same result by simulating a second step:
n: 1 while [n <= 10 ][ prin n prin " " n: ...