mirror of
https://github.com/correl/elm.git
synced 2024-12-22 11:09:08 +00:00
14 lines
317 B
Text
14 lines
317 B
Text
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
|