FFRANK has asked for the wisdom of the Perl Monks concerning the following question:
By using Algorithm::Loops:#!/usr/bin/perl -w use strict; for my $i (0..9) { for my $j (0..9) { for my $k (0..9) { for my $l (0..9) { for my $m (0..9) { for my $n (0..9) { for my $o (0..9) { print $i,$j,$k,$l,$m,$n,$o,"\n"; } } } } } } }
I would appreciate very much if one could explain in detail how this Nested Loop works ? I tried many times to complete the code below from scratch and getting nowhere.#!/usr/bin/perl -w use strict; use Algorithm::Loops qw( NestedLoops ); my @symbol = qw(0 1 2 3 4 5 6 7 8 9); my @position; for my $deepness (0..6) { push @position, [@symbol]; } my @list; my $iter = NestedLoops(\@position); while (@list = $iter->()) { print "@list\n"; }
Thanks, regards.my @symbol=qw(0 1 2 3 4 5 6 7 8 9); my$deepness=7; #? Repeat the foreach to specified deepness ?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Telephone - Nested Loops
by dynamo (Chaplain) on Jun 22, 2007 at 14:16 UTC | |
Re: Telephone - Nested Loops
by ozone (Friar) on Jun 22, 2007 at 15:14 UTC | |
Re: Telephone - Nested Loops
by Moron (Curate) on Jun 22, 2007 at 13:37 UTC | |
by tye (Sage) on Jun 22, 2007 at 16:38 UTC | |
Re: Telephone - Nested Loops
by Limbic~Region (Chancellor) on Jun 22, 2007 at 15:04 UTC | |
Re: Telephone - Nested Loops
by Ploux (Acolyte) on Jun 22, 2007 at 13:37 UTC | |
by tye (Sage) on Jun 22, 2007 at 17:01 UTC | |
Re: Telephone - Nested Loops
by jdporter (Paladin) on Jun 22, 2007 at 18:06 UTC |