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.
# updated to add leading zeroes
sub Arbitel { # takes number of digits as argument
my $count = shift;
my $limit = 10**$count;
for ( my $i = 0; $i < $limit; $i++ ) {
print Lzro( $count, $i ) . "\n";
}
}
sub Lzro
my ( $count, $number ) = @_;
substr( ( '0' x $count ) . $number, -$count );
}
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!
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.