Search Top Index
HELP REPEAT Aaron Sloman, September 1978 The word REPEAT is one way of building a loop in POP-11. The statement repeat <number> times <actions> endrepeat; causes the <actions> to be performed the appropriate <number> of times; e.g. repeat 4 times pr(".") endrepeat; will print four dots (see HELP *PR). [% repeat 66 times "cat" endrepeat %] => will make a list containing 66 occurrences of the word "cat" and print it out (see HELP *PERCENT). repeat 4 times draw(5); turn(90); endrepeat; will cause the turtle to draw a 5 by 5 square (see HELP *TURTLE). repeat 5*x times repeat y + z times pr(".") endrepeat; pr(newline) endrepeat; will print out 5 times X lines of dots, each line containing Y + Z dots. For an indefinite loop use repeat [isnt this boring] => endrepeat; This will produce an indefinite loop, which may be terminated by *RETURN, *QUITIF, *QUITUNLESS, or *QUITLOOP. A loop can be restarted with *NEXTLOOP, *NEXTIF, *NEXTUNLESS You can also execute a procedure a fixed number of times by using *SYSREPEAT. For example: sysrepeat(5, vedcharup); See also HELP *SYSREPEAT - procedure for calling "repeat" syntax - useful for closures *LOOPS - for other types of iteration *FOREVER - use of FOREVER in iteration See also REF * SYNTAX, * POPSYNTAX --- C.all/help/repeat -------------------------------------------------- --- Copyright University of Sussex 1987. All rights reserved. ----------