Skip to content

Instantly share code, notes, and snippets.

@dhinojosa
Created May 14, 2019 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhinojosa/b878981f676b6b5d25585edeeff68d9d to your computer and use it in GitHub Desktop.
Save dhinojosa/b878981f676b6b5d25585edeeff68d9d to your computer and use it in GitHub Desktop.
Capitalize the first letter, all API calls model the possibility of things going wrong, but not with exceptions but with explicit types
-- From https://github.com/dhinojosa/elm-study/blob/master/src/PigLatin.elm
capFirst : String -> String
capFirst s =
case uncons s of
Just ( h, t ) ->
cons (Char.toUpper h) t
Nothing ->
""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment