in reply to Re: intersection of N arrays
in thread intersection of N arrays
sub intersection { my $n = scalar @_; my %count; foreach my $list (@_) { my %elements = map { $_ => 1 } @$list; $count{$_}++ foreach keys %elements; } return [ grep { $count{$_} == $n } keys %count ]; }
|
---|