elm/exercises/hamming/Hamming.example
2016-03-14 08:48:57 -04:00

14 lines
314 B
Text

module Hamming (..) where
import String exposing (length, toList)
distance : String -> String -> Maybe Int
distance left right =
if length left /= length right then
Nothing
else
List.map2 (\l r -> l /= r) (toList left) (toList right)
|> List.filter identity
|> List.length
|> Just