elm/exercises/hamming/Hamming.example.elm

15 lines
347 B
Elm
Raw Permalink Normal View History

module Hamming exposing (..)
2016-03-12 02:09:38 +00:00
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