in reply to Easy way to find permutations?
The solution I offered at that time looked something like this:
my @array = ( [ 1, 2, 3, 4, 5 ], [qw( q w e r t )], [qw( junk crap spam crud kipple )], ); my @all_combinations = combin( \@array ); # where combin() is defined as follows: sub combin { my( $ar, @stack ) = @_; return \@stack unless @$ar; my( $head, @a ) = @$ar; map { combin( \@a, @stack, $_ ) } @$head }
|
|---|