in reply to intersection of N arrays
Some one can golf that I'm sure.. That's a real quick first pass.. Do you understand what its doing? If not, I can explain! :)my $numArrays = keys %ids; my %count = (); my @intersection = (); foreach my $k (keys %ids) { my %uniq = map { $_ => 1 } @{ $ids{$k} }; $count[$_]++ for keys %uniq; } foreach my $v (keys %count) { push @intersection, $v if $count[$v] == $numArrays; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: intersection of N arrays
by Solo (Deacon) on Jul 01, 2004 at 02:51 UTC | |
by jarich (Curate) on Jul 07, 2004 at 15:14 UTC | |
|
Re^2: intersection of N arrays
by nkuitse (Sexton) on Jul 02, 2004 at 14:58 UTC |