elm/exercises/anagram/Anagram.example

21 lines
392 B
Text
Raw Normal View History

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