|
Recursion with the Repeat statementRecursion may be defined as repetition. For example the procedure TO
SQUARE will solve the problem of finding a way to draw a square in Logo. On the other hand, the procedure TO
SQUARE solves the same problem without writing out the directions for drawing each side of the square. Instead, it simply says "draw a side, four times." Incidentally, this is called finite recursion, because we are counting to a finite number. The procedure TO
SQUARE solves the same problem with an infinite recursion. Recursion is an extremely important characteristic of human problem solving and it is reflected in nearly all computer languages.
Using the Repeat statement to draw regular polygons
| |||||||||||||||||||||