Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Creating tuples based on sets

by adrianh (Chancellor)
on Apr 16, 2003 at 21:50 UTC ( #251059=note: print w/replies, xml ) Need Help??


in reply to Creating tuples based on sets

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);

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://251059]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2021-03-01 05:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?