repeat

Help Contents First Steps In Logo Built-in instructions Controlling program flow repeat
if while

repeat


The other instruction for program flow control is repeat. You can use to ask Logo to repeat a sequence in instructions several times. The following instruction:

	repeat 5 [print "Hello]
is functionally equivalent to:
	print "Hello
	print "Hello
	print "Hello
	print "Hello
	print "Hello
Of course if you want to repeat an action thousands of times, then it would be quite efficient to use repeat.

It is recommended not only for great number of repetitions, but also for unknown number of repetitions.

In many cases you do not know this number, but you can calculate it.

Here the value of chars determines how many times to repeat the instructions in the list.

make "i 65
repeat :chars
[
	print char :i
	make "i :i+1
]

Often repeat instructions are called repeat cycles.

Examples:
References:

if while