elm/exercises/hamming/Hamming.example.elm
2016-12-17 17:29:40 -05:00

14 lines
347 B
Elm

module Hamming exposing (..)
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