You probably know that recursion is when a function
calls itself.  With tail end recursion LISP ensures
that recursion is as efficient as iteration [1].  

Instead of iteration:

  repeat count 3 [
    print ["count: " count]
  ]

You would use:

  recursive: func [count target][
    print ["recursive count: " count]
    if count < target [recursive count + 1 target]
  ]
  recursive 1 3

In this simple example iteration looks much better. 
The recursive approach looks complicated and difficult
to understand.  So why is tail end recursion
desirable?

Well, consider a alogrithm for Longest Common
Subsequence [2]. As link 2 shows, the initial
recursive form is very easy to derive and understand,
but you have to work a lot harder to get a decent
iterative solution.

[1]
http://mathcs.holycross.edu/~mule/labs/prelabs/RecursionLambdaLab.htm

[2] http://www.ics.uci.edu/~eppstein/161/960229.html


________________________________________________________________________
Want to chat instantly with your online friends?  Get the FREE Yahoo!
Messenger http://mail.messenger.yahoo.co.uk
-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.

Reply via email to