Dotimes

dotimes range instruction-list

Runs the instruction list for each value specified in the range. The first input is a list with a temporary variable name and a maximum number. The second input is a list of instructions that uses the variable name included in the first input. In the following example, the instruction setc sets the turtle color for each value of i, from 0 to 7.

Example:

dotimes [i 8] [setc :i wait 5]

The following example displays 0, 1, 2, 3, ... to 9 in the Command Center.

dotimes [i 10] [show :i]

0

1

2

...

9

Note: The name of the variable that you choose for dotimes is bound to this primitive. A change in its value (for example: make "i :i + 1) in the instruction list won't have an effect.