Skip to content

Instantly share code, notes, and snippets.

@Chadtech
Last active March 10, 2017 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Chadtech/b76bbfefbc796bf43fd498e2b490cef3 to your computer and use it in GitHub Desktop.
Save Chadtech/b76bbfefbc796bf43fd498e2b490cef3 to your computer and use it in GitHub Desktop.
allAlphanumeric : String -> Bool
allAlphanumeric str =
List.map isAlphanumeric (String.toList str)
|> List.foldr (||) False
isAlphanumeric : Char -> Bool
isAlphanumeric char =
String.contains (String.fromChar char) alphanumeric
alphanumeric : String
alphanumeric =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvxwyz0123456789"
@ahstro
Copy link

ahstro commented Mar 10, 2017

You could also achieve this pretty succinctly using regex and partial application, like this. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment