in reply to Combinations of a set of elements

This may help you. The code below generates a array list that eliminates redundant data.

my @set = qw(A B C D A);

my @list;

my $elm;

my $count=0;

foreach my $one (@set) {

foreach my $two (@set) {

$elm ="$one"."$two";

foreach $list(@list){$count++ if ($list eq elm);}

push @list,"$one$two" if($count eq 0);

}

}

Cheers!!!!

Anandatirtha

Replies are listed 'Best First'.
Re: Re: Combinations of a set of elements
by Ananda (Pilgrim) on Nov 14, 2002 at 06:07 UTC
    Correction

    foreach $list(@list){$count++ if ($list eq $elm);}

    Anandatirtha