6.1.1 Basic Loops

Oz has a looping construct introduced by the keyword for. The simplest form is to iterate over the elements of a list:

<list loop>=
for X in [a b c] do {Inspect X} end

One can think of X as a mutable variable that succesively takes of values of the list [a b c]. You can also use special syntax to write something loops over integers:

<integer loop>=
for I in 2..25 do {Inspect I} end

This has the same effect as if I ranged over the integer list [2 ... 25] except that this list is never constructed explicitely.


Denys Duchier, Claire Gardent and Joachim Niehren
Version 1.3.99 (20050412)