Hamming distance
The Hamming distance
between two strings
of equal length is the number of positions at which the two
strings differ.
:{
hamming :: (Eq a) => [a] -> [a] -> Int
hamming as bs = length $ filter (uncurry (/=)) $ zip as bs
:}
hamming "cat" "hat"
hamming "abcd" "adbc"
Examples