I had to untangle it from it's dependancies with the object it is a method of, but this produces the sequence as show (prior to scrunching and formatting):
#! perl -slw
use strict;
sub gen {
my( $len, $depth ) = @_;
return () unless $len;
return map {
my $pre = $_;
( $pre, map{ $pre . $_ } gen( $len -1, $depth ) );
} 0 .. $depth - 1;
}
print for gen( 4, 3 );
Examine what is said, not who speaks.
"But you should never overestimate the ingenuity of the sceptics to come up with a counter-argument." -Myles Allen
"Think for yourself!" - Abigail
"Time is a poor substitute for thought"--theorbtwo
"Efficiency is intelligent laziness." -David Dunham
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
| [reply] [d/l] |