elm/exercises/anagram/Anagram.example.elm

21 lines
422 B
Elm
Raw Normal View History

module Anagram exposing (..)
2016-03-13 01:35:43 +00:00
import String exposing (toLower, toList)
detect : String -> List String -> List String
detect word candidates =
let
original =
toLower word
ref =
normalize word
in
List.filter (\w -> normalize w == ref && toLower w /= original) candidates
2016-03-13 01:35:43 +00:00
normalize : String -> List Char
normalize word =
word |> toLower |> toList |> List.sort