How about turning the arrays into strings and then using boolean & on them, using tr to count the 1s?
my @x = qw( 0 0 0 0 1 1 0 0 0 0 1 0 ); my @y = qw( 1 0 0 0 1 0 1 0 1 0 1 0 ); my $x = join '', @x; my $y = join '', @y; my $compare = $x & $y; my $joint = $compare =~ tr/1/1/; print "$joint\n";
Can you throw this into your benchmarking? @x obviously would need to be turned into a string only once.
In reply to Re: Comparing two arrays
by hdb
in thread Comparing two arrays
by baxy77bax
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |