"For" loop

for [i start stop step] [instructions]

Repeat list of instructions using successive values assigned to an iteration counter i. The first value is equal to start. Each subsequent value is taken as: the previous value + step if start < stop or: the previous value - step if start > stop. The loop is finished (and the list of instructions is not executed) when the iteration counter exceedes stop. Expressions start, stop and step can be constants (e.g. 3), variables (e.g. :x) or lists of expressions (e.g. [:x + 3]). Value step can be omitted; then default value is used: 1 if start < stop or -1 if start > stop.

Example:

make "x 5
for [i 1 :x 1.5] [print :i]

Output:

1
2.5
4

See also:

Loop instructions

Table of Content