Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Conglomerate of arrays with no duplicates

by Roger (Parson)
on Jan 31, 2004 at 00:17 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://325462]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-24 05:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found