laziness, impatience, and hubris | |
PerlMonks |
Re^2: Question about recursively generated iteratorsby ikegami (Patriarch) |
on Sep 21, 2007 at 16:48 UTC ( [id://640397]=note: print w/replies, xml ) | Need Help?? |
This method can be used when a function has a loop, since loops can be implemented using recursion. This is great because it facilitates making iterators from functions where the call to the visitor is not at the end and from functions with multiple calls to the visitor. For example, let's create a fibonacci generator. A simple implementation is:
Replace the loop with recursion.
Convert for make_iter.
Try it out
In Section
Seekers of Perl Wisdom
|
|