Self function
Steven D'Aprano
steven at REMOVE.THIS.cybersource.com.au
Mon May 4 23:22:34 EDT 2009
On Mon, 04 May 2009 15:51:15 -0700, Carl Banks wrote:
> All
> recursion does it make what you're doing a lot less readable for almost
> all programmers.
What nonsense. There are many algorithms that are more understandable
written recursively than iteratively -- consult any good text book for
examples. There are algorithms that are naturally iterative, and
algorithms which are naturally recursive (and a few which are equally
simple either way), and forcing either one into the other form leads to
complicated and confusing code. This especially holds for mutually-
recursive functions, where re-writing them to be iterative is usually
very difficult.
Sometimes it's worth rewriting a recursive algorithm to be iterative for
the performance optimization, but that comes at the price of reduced
readability.
--
Steven
More information about the Python-list
mailing list