Loops
- forall
-
forall(f in FAC, t in TIME) make(f,t) = MAXCAP(f,t) forall(t in TIME) do use(t) = MAXUSE(t) buy(t) = MAXBUY(t) end-do
- while
-
i := 1 while (i = 10) do write(' ', i) i += 1 end-do
- repeat ... until
-
i := 1 repeat write(' ', i) i += 1 until (i 10)
- break, next
-
- break jumps out of the current loop
- break n jumps out of n nested loops (where n is a positive integer)
- next jumps to the beginning of the next iteration of the current loop
- counter
-
- Use the construct as counter to specify a counter variable in a bounded loop (i.e., forall or aggregate operators such as sum). At each iteration, the counter is incremented
cnt:=0.0 writeln("Average of odd numbers in 1..10: ", (sum(cnt as counter, i in 1..10 | isodd(i)) i) / cnt)