in reply to Comparing two arrays
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Comparing two arrays
by baxy77bax (Deacon) on Dec 15, 2013 at 11:04 UTC | |
by hdb (Monsignor) on Dec 15, 2013 at 11:54 UTC |