lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hallo,

On 3/15/07, David Haley <dchaley@gmail.com> wrote:

Besides, saying recursion is "useless" is a little strong, don't you
think? There are plenty of recursive solutions that are more elegant
than an iterative solution, with the caveat that you can't recurse too
deep -- but very often the allowed depth is quite enough. Nearly all of
the times I blew the stack using recursion were when I messed up the
recursion's base case. :-) Not because the problem inherently needed
such a deep recursion.


    Well, I hardly take chances with a call stack. In fact, I think
the last time I used recursion in C was in college. It was the
floodfill algorithm for painting geometric figures, and it taught me
to never recurse in C again.
    Recently I had to write a minimal XML parser in C for a mobile
phone application. Of course I didn't write a recursive parser,
because of the memory limitation. Would I have written a recursive one
if it was a PC application? I doubt it. Constant-space algorithms give
you warm feelings that you aren't throwing dices.

--
-alex
http://www.ventonegro.org/