Newbie: conventional instead of recursive way

Erik Max Francis max at alcyone.com
Wed Dec 18 18:50:43 EST 2002


Igor Zivkovic wrote:

> The problem is that I don't know how to write the same function using
> a
> conventional loop construct. This is one of my poor attempts:

What'd you'd probably do is maintain a stack consisting of the indices
of the lists you've encountered so far.  The real question I'd ask,
though, is why you think the recursive solution is not acceptable?  This
is a case where recursion really looks to be the best solution; why do
you want to avoid it?

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Consistency is the last refuge of the unimaginative.
\__/ Oscar Wilde
    Alcyone Systems / http://www.alcyone.com/
 Alcyone Systems, San Jose, California.



More information about the Python-list mailing list