Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Tail-recursion in perl?!

by jonadab (Parson)
on Jul 10, 2005 at 01:21 UTC ( [id://473720]=note: print w/replies, xml ) Need Help??


in reply to Re: Tail-recursion in perl?!
in thread Tail-recursion in perl?!

This recursion version can be found almost in all text books, not because it is the best way to code this particular logic, but it is probably the best example one can use to demo recursion.

A better example would be quicksort. The reason I say it's better is because it demonstrates how recursion is a more natural way to think about certain problems. With the factorial example, the iterative version is at least as easy to follow as the recursive version, but with quicksort the recursive version is *MUCH* easier to understand. Perhaps an even better example would be a depth-first traversal of a general tree.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://473720]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2024-04-23 10:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found