Re: generating a wordlist from an array of arrays
- From: japhy@xxxxxxxxxxxx (Jeff 'japhy' Pinyan)
- Date: Thu, 29 Sep 2005 18:05:20 -0400 (EDT)
On Sep 29, mark berger said:
hey list. i stuck with gererating a wordlist from a changing multidimensional array. each entry in the array contains a list with the possible values.
You want a "cartesian cross product". And there's a module out there that does just that: Set::CrossProduct.
http://search.cpan.org/~bdfoy/Set-CrossProduct-1.6/CrossProduct.pm
Sample use:
use Set::CrossProduct;
my $iterator = Set::CrossProduct->new(['a','b'],['c'],['d','e','f']);
my @wordlayout = $iterator->combinations;
@wordlayout will be an array of array references (like ['a','c','f']). To turn them into strings, you could do:
my @wordlayout = map join("", @$_), $iterator->combinations;any hints on how to solve this? probably using recursion but i got no idea about it right now. and sorry for my bad english, hope i can make my problem understandable.
It would be a fun exercise to do this on your own, and yes, recursion is the most obvious way to do it.
-- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://www.perlmonks.org/ % have long ago been overpaid? http://princeton.pm.org/ % -- Meister Eckhart .
- References:
- generating a wordlist from an array of arrays
- From: Mark Berger
- generating a wordlist from an array of arrays
- Prev by Date: Re: compiling Storable in order to use Proc::ProcessTable
- Next by Date: RE: a little help...
- Previous by thread: generating a wordlist from an array of arrays
- Next by thread: Re: generating a wordlist from an array of arrays
- Index(es):
Relevant Pages
|