mirror of
https://github.com/correl/elm.git
synced 2024-12-22 19:17:27 +00:00
20 lines
422 B
Elm
20 lines
422 B
Elm
module Anagram exposing (..)
|
|
|
|
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
|
|
|
|
|
|
normalize : String -> List Char
|
|
normalize word =
|
|
word |> toLower |> toList |> List.sort
|