http://qs321.pair.com?node_id=640382

perlfan has asked for the wisdom of the Perl Monks concerning the following question:

I've been going over the posts and tutorials here on this subject, and I have made it to the point where I can code a very straightforward example of very simple recursion.
#!/usr/bin/env perl use strict; use warnings; sub recurse_factory { my $max = shift; my $number = shift; if ($number < $max) { return sub { return recurse_factory($max,$number+1); } } else { return sub { print "done ... $number\n"; }; } } my $TIMES = 100; my $next = recurse_factory(100,0); for (1..$TIMES+1) { $next = $next->(); }
However, I am trying to figure out how one may use this method (if at all) for a more complicated recursive algorithm. In essence what I'd like to do is find all acyclic paths in a digraph using the recursive depth first search method.

In otherwords, the recursion pattern looks more like the depth first traversal of a tree than a simple straight line like my simple example above. I am sure locked away in the great explanations I've found on this site is the key, but I need to be hit with a really big clue stick.

I think for this discussion, the recursive depth first traversal of a tree that returns a full root-to-leaf path would be an appropriate example...btw, I am assuming that this can be done with rgi's, but I could be wrong there, too.

TIA