Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Factorial Matrix

by ikegami (Patriarch)
on Jan 29, 2008 at 20:00 UTC ( [id://664972] : note . print w/replies, xml ) Need Help??


in reply to Factorial Matrix

That's a cross product, not listing permutations or combinations.

It's trivial with Algorithm::Loops's NestedLoops.

use Algorithm::Loops qw( NestedLoops ); my @array1 = qw( A B ); my @array2 = qw( 1 2 ); my @array3 = qw( C D E ); my $iter = NestedLoops([ \@array1, \@array2, \@array3, ]); while (my @row = $iter->()) { print("@row\n"); }