in reply to Telephone - Nested Loops

Not an answer to your question, but a solution to your need, maybe...

# arg 0: callback; is passed each generated vector # arg 1: length of generated vectors # remaining args: alphabet sub generate_all_vectors(&$@) { my( $callback, $veclen, @alphabet ) = @_; for ( my $i = 0; $i < @alphabet ** $veclen; $i++ ) { my $t = $i; # destructible copy $callback->( reverse map { my $n = $t % @alphabet; $t = int( $t / @alphabet ); $alphabet[$n] } 1 .. $veclen ) } } generate_all_vectors { print "@_\n" } 7, 0 .. 9;
A word spoken in Mind will reach its own level, in the objective world, by its own weight