more useful options | |
PerlMonks |
Re: Telephone - Nested Loopsby Moron (Curate) |
on Jun 22, 2007 at 13:37 UTC ( [id://622785]=note: print w/replies, xml ) | Need Help?? |
NestedLoops takes a structure over which it will iterate but it needs a second parameter to tell it what to do per iteration. So you could do your thing by passing it a 7- deep nested array by reference and a code ref like sub { print "$_\n" for @_; };
But as a rule, such predictable structures should never even be built (update: I have a habit of not building ranges like 0..7 even though that's small, because I don;t want to build in memory a 0..colussus by accident!). So the thing should never even get the chance to be passed to a method; rather the algorithm should be a bit smarter.
More update: my decision chart: "Can it be mapped to a simple virtual structure? Y: don't build it and don;t bother to use a CPAN module to generate or iterate it. N: "Can the structure be iterated virtually without building it? N: use Algorithm:: Y: "Is there a method for it in Math::Combinatorics? Y: use that then N: use Algorithm::
__________________________________________________________________________________
^M Free your mind!
In Section
Seekers of Perl Wisdom
|
|