in reply to Re: Telephone - Nested Loops
in thread Telephone - Nested Loops

NestedLoops takes a structure over which it will iterate [...]. 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 @_; };

Perhaps you should (re-)read the documentation for Algorithm::Loops::NestedLoops(), as you appear to misunderstand what it does, or at least your attempt to re-explain what it does is just very badly done. To start with the easy mistake: You don't have to pass code to NestedLoops() as it is happy to just give you an iterator.

What you give to NestedLoops() is not 7-deep. It doesn't "iterate over a structure". Your description makes it sound like NestedLoops() just traverses a data structure similar to what Data::Dumper does, that it is (to borrow bad terminology from a bad "design pattern") a "visitor pattern" implementation.

You give NestLoops() a reference to a list of ranges. So you might call this a 2-deep data structure but that'd really miss the point. It is a list of ranges and each range can just be a reference to a list but could also be something else. It doesn't iterate over this data structure. It iterates over the space of all possible ordered combinations of items from these ranges (and does so in the order most easily described as that resulting from nesting loops that each iterate over one range).

- tye