[top][index]
search for:

for -- loop control

for i from a to b when c list x do y -- repeatedly evaluate x and y as long as c is true, letting the variable i be assigned the values a, a+1, a+2, ..., b, returning a list of the values of x encountered.

Each of the clauses from a, to b, when c, list x, and do y is optional, provided either the list x or the do y clause is present. If the clause from a is missing, then from 0 is assumed. If the clause to b is missing, then no upper limit is imposed on the value of i. If the clause list x is absent, then null is returned.

The numbers a and b must be small integers that fit into a single word.

The variable i is a new local variable whose scope includes only the expressions c, x, and y.

i1 : for i from 3 to 6 do print i
3
4
5
6
i2 : for i when i^2 < 90 list i

o2 = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}

o2 : List

See also:

  • loops -- evaluate code repeatedly
  • while -- loop control
  • return -- return from a function

  • [top][index]
    search for: