NoRedInk / elm-simple-fuzzy / Simple.Fuzzy

Fuzzy match through a list of strings

Matching and Filtering

match : String -> String -> Basics.Bool

match allows you to see if the letters of your query match within a bigger string.

match "poo" "Poo" --> True

match "poo" "Police" --> False

match "poo" "Please be polite Online!" --> True

filter : (a -> String) -> String -> List a -> List a

filter will filter an arbitrary list of objects given a function that converts the object to value you want to match on

let
    languages =
        [ { name = "Elm" }
        , { name = "Ruby" }
        , { name = "Rust" }
        , { name = "Haskell" }
        , { name = "javascript" }
        , { name = "English" }
        ]
in
    filter .name "el" languages
--> [ { name = "Elm" }
--> , { name = "Haskell"}
--> , { name = "English"}
--> ]

Helpers

root : String -> String

root strips a word down to just the lower case version of itself without any punctuation or spacing. Digits are retained.

root "Wow, I'm excited!!!!" --> "wowimexcited"

root "I'm excited 2!" --> "imexcited2"