in reply to combine elements of lists
It's very easy to implement using recursion.
my @list; $list[0]=[1,2,6]; $list[1]=[4,5]; $list[2]=[7,3]; sub combin { @_ or return []; my $l = shift; map { my $n = $_; map { [ $n, @$_ ] } combin(@_) } @$l } my @comb = combin(@list); print "@$_\n" for @comb;
Similar to how I did it another time.
And the functionality is available in a module, Set::CrossProduct.
|
|---|