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        


In reply to Re^2: Telephone - Nested Loops (no) by tye
in thread Telephone - Nested Loops by FFRANK

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.