One more variation ;-)
CPAN provides us with Set::CrossProduct, which allows us to write your mk_tuples like this:
use Set::CrossProduct; sub mk_tuples(\@$) { my ($arrayref, $n) = @_; [ Set::CrossProduct->new( [($arrayref) x $n] )->combinations ]; }; my @set = qw(A B C); my $output = mk_tuples(@set, 2);
In reply to Re: Creating tuples based on sets
by adrianh
in thread Creating tuples based on sets
by waxmop
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |