FOR

Syntax

FOR word number number list

(FOR word number number list number)

Explanation

FOR lets you execute a list of Logo commands a given number of times. Inputs to FOR are a control variable, a beginning value, an ending value, and a list of Logo commands to be executed. FOR assigns the beginning value to the variable, executes the run list, and then increments the variable by one. This process is repeated until the value of the variable equals the ending value.

The variable increment step can be changed to a number other than one by listing the increment as a fifth input to FOR and enclosing FOR and all its inputs in parentheses.

See also REPEAT.

Examples

? FOR "I 1 4 [PRINT :I]

1

2

3

4

? (FOR "I 1 4 [PRINT :I] 2)

1

3

?