mrborisguy has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to generate permutations of a couple lists. After searching here and on CPAN, I've decided that Algorithm::Loops is exactly what I need! Well, almost exactly.
The problem is that instead of having arrays, I have iterators, so I'm wondering if there is any way to use iterators instead of arrays with Algorithm::Loops.
My iterators are used like:
while( defined( my $a = $iter->() ) ) { # do something with $a } #note: $iter->() returns a useful value, or undef
So, I guess what I want is to nest an arbitrary number of while loops instead of an arbitrary number of for loops, conceptually.
I can't just stick everything from $iter into an array, because $iter may be infinite. Does anybody have any ideas on how I could do this?
-Bryan
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: NestedLoops (Algorithm::Loops) and Iterators
by tmoertel (Chaplain) on Jul 26, 2005 at 22:49 UTC | |
by ikegami (Patriarch) on Jul 26, 2005 at 23:35 UTC | |
by tmoertel (Chaplain) on Jul 27, 2005 at 04:06 UTC | |
|
Re: NestedLoops (Algorithm::Loops) and Iterators
by ikegami (Patriarch) on Jul 26, 2005 at 22:34 UTC | |
|
Re: NestedLoops (Algorithm::Loops) and Iterators
by runrig (Abbot) on Jul 26, 2005 at 22:19 UTC | |
|
Re: NestedLoops (Algorithm::Loops) and Iterators
by Solo (Deacon) on Jul 26, 2005 at 22:58 UTC | |
|
Re: NestedLoops (Algorithm::Loops) and Iterators
by AReed (Pilgrim) on Jul 26, 2005 at 22:18 UTC | |
by mrborisguy (Hermit) on Jul 26, 2005 at 22:31 UTC |