Bill MacKay wrote: > Can someone explain when we would use tail >recursion or embedded recursion? Perhaps an example may suffice. >Thanks in advance, In logo we tend to use recursion a lot because FOR loops and WHILE loops are not primitives. Examples: 1) to make a turtle move forever to move fd 1 move end that's tail recursion 2) embedded recursion Drawing fractals is one example. There are some examples and code on my web site at http://www.senet.com.au/~kerrb/ Go to the animation, mainly fractals link. For the code look under Yehuda or the HowTo article. For the best explanation of recursion see Brian Harvey's book, 'Computer Science Logo Style' (volume 1). He explains recursion in 4 different ways in Chapter 5: the combining method, little people method, tracing method and leap of faith method. I'd also recommend Chapter 7: Recursive operations, which I found difficult but very rewarding. Other languages don't seem to use recursion as much but instead rely on FOR and WHILE loops. In MicroWorlds tail recursion is simulated visually by means of a <many times> button. -- Bill Kerr --------------------------------------------------------------- Please post messages to the Logo forum to logo-l@gsn.org. Mail questions about the list administration to logofdn@gsn.org. To unsubscribe send unsubscribe logo-l to majordomo@gsn.org.
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