> Date: Wed, 18 Mar 1998 23:22:47 +1000 > From: Bill Mackay <wmackay@scu.edu.au> > To: logo-l@gsn.org > Subject: LOGO-L> Recursion > Reply-to: Bill Mackay <wmackay@scu.edu.au> > Hello, > I've just joined the list so maybe this has been covered - but I didn't > see it in the archives. Can someone explain when we would use tail > recursion or embedded recursion? Perhaps an example may suffice. > Thanks in advance, > Bill Mackay Bill, I've never met here html-files with pictures being sent as an attachment, so I'm not sure it will work well. Nevertheless I'm trying. The attachment contains html-file and two animated pictures of spirals to demonstrate the difference between tail and embedded recursion. These pictures are just illustrating Jim Muller's MAZE and AMAZE. You'll see, the behaviour of SPIRAL1 (spiral1a.gif) differs from one of SPIRAL2 (spiral2a.gif) and the behaviour of SPIRAL2 coinsides with the one of SPIRAL3. TO SPIRAL1 :A IF :A<10 [STOP] FD :A RT 90 SPIRAL1 :A-10 END TO SPIRAL2 :A IF :A<10 [STOP] SPIRAL2 :A-10 FD :A RT 90 END TO SPIRAL3 :A IF :A>100 [STOP] FD :A RT 90 SPIRAL3 :A+10 END All the best, Olga.
The following section of this message contains a file attachment
prepared for transmission using the Internet MIME message format.
If you are using Pegasus Mail, or any another MIME-compliant system,
you should be able to save it or view it from within your mailer.
If you cannot, please ask your system administrator for assistance.
---- File information -----------
File: spir_snd.htm
Date: 19 Mar 1998, 15:14
Size: 1349 bytes.
Type: HTML-text
Title: Spirals Demo
These pictures are to display the difference between embedded recursion and a tail one.
The difference in behaviour of spiral 1 and spiral 2 is obvious, though the codes look very much alike. And, though the codes are different for spiral 2 and spiral 3, their behaviour is similar.
![]() |
![]() |
![]() |
| SPIRAL1 100 | SPIRAL2 100 | SPIRAL3 10 |
TO SPIRAL1 :A IF :A<10 [STOP] FD :A RT 90 SPIRAL1 :A-10 END |
TO SPIRAL2 :A IF :A<10 [STOP] SPIRAL2 :A-10 FD :A RT 90 END |
TO SPIRAL3 :A IF :A>100 [STOP] FD :A RT 90 SPIRAL3 :A+10 END |
The following section of this message contains a file attachment
prepared for transmission using the Internet MIME message format.
If you are using Pegasus Mail, or any another MIME-compliant system,
you should be able to save it or view it from within your mailer.
If you cannot, please ask your system administrator for assistance.
---- File information -----------
File: spiral1a.gif
Date: 15 Feb 1998, 17:05
Size: 6734 bytes.
Type: GIF-image
The following section of this message contains a file attachment
prepared for transmission using the Internet MIME message format.
If you are using Pegasus Mail, or any another MIME-compliant system,
you should be able to save it or view it from within your mailer.
If you cannot, please ask your system administrator for assistance.
---- File information -----------
File: spiral2a.gif
Date: 15 Feb 1998, 17:07
Size: 5561 bytes.
Type: GIF-image
Global SchoolNet Foundation -
Linking Kids Around the World!
Copyright GSN - All Rights Reserved
- Comments
& Questions
Visit GSN's
Global
Schoolhouse for more exciting learning resources!
Search our Site
-
Home