recursion vs iteration (was Re: reduce()--what is it good for?)

Anton Vredegoor anton at vredegoor.doge.nl
Mon Nov 10 20:02:37 CET 2003


On 9 Nov 2003 22:40:57 GMT, bokr at oz.net (Bengt Richter) wrote:

[ackerman function generates very long integers]

>Is there a fast formula for computing results, ignoring the representation problem?

This seems to be an easy way to generate them faster:

http://www.kosara.net/thoughts/ackermann.html

 ... back to the topic of this thread ...

>From what I get of the main discussion (recursion vs iteration) it is
reasonable to not make a distinction based on the type of algorithm
but to only look at the order in which the nodes of the search space
are visited. It seems possible to turn recursive functions into
iterative ones by pushing and popping a stack of argument values.

This opens up possibilities of continuing from arbitrary positions of
the stack instead of just by pushing and popping ...

Anton




More information about the Python-list mailing list