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 ]; }
In reply to Re^2: intersection of N arrays
by nkuitse
in thread intersection of N arrays
by basscakes
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |