in reply to Using hashes for set operations...
my %set1 = map { $_ => 1 } @array1; my %set2 = map { $_ => 1 } @array2; my %intersection = grep $set1{$_}, keys %set2;
That assumes true values. You're using weird values, so you might have to use exists.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Using hashes for set operations...
by LanX (Saint) on May 21, 2011 at 18:50 UTC | |
by John M. Dlugosz (Monsignor) on May 21, 2011 at 19:08 UTC | |
by ikegami (Patriarch) on May 22, 2011 at 05:35 UTC | |
by John M. Dlugosz (Monsignor) on May 22, 2011 at 14:00 UTC | |
by ikegami (Patriarch) on May 22, 2011 at 15:22 UTC | |
by educated_foo (Vicar) on May 22, 2011 at 21:07 UTC | |
by Anonymous Monk on May 23, 2011 at 08:17 UTC | |
by ikegami (Patriarch) on May 22, 2011 at 05:18 UTC |