Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Conglomerate of arrays with no duplicates

by Roger (Parson)
on Jan 31, 2004 at 00:17 UTC ( #325462=note: print w/replies, xml ) Need Help??


in reply to Conglomerate of arrays with no duplicates

You could use Set::CrossProduct.

use strict; use warnings; use Set::CrossProduct; my @products = ('tshirt', 'pants', 'sweatshirt'); my %options = ( 'sizes' => ['small', 'medium', 'large'], 'colors' => ['red', 'green', 'blue'] ); # build an array of array my @p = (); push @p, \@products; push @p, $options{$_} for sort keys %options; # get all combinations my $iterator = Set::CrossProduct->new( \@p ); # print the combinations local $, = ' '; print "@$_\n" for (@{$iterator->combinations});


Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2020-06-02 02:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (12 votes). Check out past polls.

    Notices?