Apr-22-2017, 08:57 PM
(Apr-22-2017, 12:01 AM)Larz60+ Wrote: There are certain things that recursion does that I can't really imagine doing any other way.Anything recursive can be written in an iterative fashion. You might have to manage a stack manually, but it's always doable.
While I believe "indirect" (or "mutual") recursion is playing with fire, and I regret deeply the one time I tried it, "direct" or regular recursion has a learning curve to it but is arguably better than using break or continue in a loop. CPython lacks optimizations for recursion, but as a style of control flow it can be an elegant way to avoid side effects.