in reply to Re^2: is there a more simple way to have the intersection of two lists ?
in thread is there a more simple way to have the intersection of two lists ?
Hum, right. I over-optimized. I should have stuck to the general solution (i.e. accepts more than two sets) I first wrote.
my %seen; $seen{$_}|=1<<0 for @list1; $seen{$_}|=1<<1 for @list2; my @intersection = grep $seen{$_}==(1<<2)-1, keys %seen;
It loses any order, though.
|
|---|