Next: , Previous: Conditional Statements, Up: Top


5.3 Iterative Statements

while assertion block end
Repeats block while assertion is true.
for i = a to b { step c } block end
Repeats block while incrementing number i by c (default: 1), from a to b. Numbers b and c are evaluated at each step. Iteration ends as soon as i is greater than or smaller than b, depending on the sign of c.
for P in s block end
Repeats block while point P runs through set s.

Example:

     O = point(3,2)
     H = hexagon(O, 3, 0°)
     draw (H)
     
     for P in H
       draw O.P dotted
     end