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

Re: Re: Re: Re: Re: Iterative vs Recursive Processes

by BrowserUk (Patriarch)
on May 13, 2003 at 00:12 UTC ( [id://257607]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Re: Iterative vs Recursive Processes
in thread Iterative vs Recursive Processes

S'fair enough:) Though I wasn't suggesting that recursion itself was non-useful. I agree that there are many algorithms which are naturally recursive and are much easier to both think of and implement using recursion. Almost anything to do with trees is a good example, but in all the cases I can think of where this is so, retaining state at intermediate points in the repetition is an integral part of the algorithm. Ie. Intrinsic to the delivery of the immediate final result. As opposed to a potential, future final result as can be delivered using the memoize case you cite.

I've not had the occasion to use Memoize in anger, but I read some of Dominus' arguments for it and Streams and stuff, and it is certainly a neat way of speeding up existing code (amongst other uses), but I was struck that it would be cheaper in memory and quicker to just re-code the original function to use a lookup table, though I can see this doesn't have the infinite list feature, but then I don't have infinite memory either:).

I very definately agree that dismissing any better screwdriver out-of-hand is silly. I was just hoping I might get some good counterpoints to the tail-recursion-is-a-hack -elevated-to-goodness argument that I was pretty much convinced by several years ago.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-03-28 17:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found