Re: generating a wordlist from an array of arrays



On Thu, Sep 29, 2005 at 07:26:51PM +0200 mark berger wrote:
> 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.
>
> fe:
>
> @wordlayout = ((a, b), # possible values for 1st char
> (c), # possible values for 2nd char
> (d, e, f)); # possible values for 3rd char
>
> the following wordlist should be generated:
>
> acd
> ace
> acf
> bcd
> bce
> bcf

use references for multidimensional arrays:

#!/usr/bin/perl

use warnings;

@w1 = (["a", "b"], ["c"], ["d", "e", "f"]);

$str ="";

foreach $k (@{$w1[0]}) {

foreach $l (@{$w1[2]}) {

$str = $str.$k.@{$w1[1]}[0].$l." ";
}
}

@w2 = split " ", $str;

foreach (@w2) {

print "$_\n";
}

it's another solution ...

hth

--
Gérard

.



Relevant Pages

  • Re: updating field with data from other fields
    ... Al Camp ... > email address of every entry, but the email address is empty...i need to ... Prev by Date: ...
    (microsoft.public.access.gettingstarted)
  • Re: Count logic question
    ... In the cell directly below the last entry in row B, ... HTH, ... PokerZan's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=23480 ... Prev by Date: ...
    (microsoft.public.excel.misc)
  • Re: 100 Euro Lottery Tix/ph/sms/cd 6pmTONIGHT
    ... Does anyone know if it is per person or per household, ... One entry per person ... HTH ... Prev by Date: ...
    (uk.rec.competitions)
  • Re: Input Masks in Excel?
    ... > Is there a way to convert the entry, i.e. 032405, and have it show up in ... >> HTH ... >> Bob Phillips ... Prev by Date: ...
    (microsoft.public.excel.setup)
  • Re: Access to data into an array causes seg-fault
    ... > now, i can access to a value of this multidimensional array, inside the ... It sounds like there is a problem with your particualr code but we can't ... Lawrence ... Prev by Date: ...
    (comp.lang.c)