blob: 075b07c3e831fffcbc99dcbae476de7fef134fa2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
|
unit module Hamming;
subset DNA of Str where * !~~ /<-[ACGT]>/;
sub hamming-distance(
DNA $strand1, DNA $strand2 where $strand1.chars == $strand2.chars --> Int
) is export {
my Int $dist = 0;
for ^$strand1.chars -> $idx {
$dist++ unless $strand1.comb[$idx] eq $strand2.comb[$idx];
}
return $dist;
}
|