[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Out of curiousity, is "recursion" the desirable way(or is it pythonic > way) ? How would one do it in the imperative way ?
For an inherently recursive problem (as this one appears to be), the traditional alternative to recursion is maintaining your own LIFO stack. If (with all the obvious refactorings) things gets messy, ah well, at least you've broken free of the recursion limit;-). [[ Sometimes (rarely) things don't get messy, and then you find out that the problem wasn't really "inherently recursive";-) ]] An example of recursion elimination in Python can be found at <http://mail.python.org/pipermail/python-list/2002-January/082481.html> Alex -- http://mail.python.org/mailman/listinfo/python-list