The recursive solution.
sub comb{ return @{ $_[0] } if @_ == 1; map{ my $x = $_; map{ "$x$_" } comb( @_ ) } @{ shift() } } my @combs = comb [qw(a b c)],[qw(1 2 3)],[qw(- + *)];
In reply to Re: cartesian product preserving order
by BrowserUk
in thread cartesian product preserving order
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |