Skip to content

Instantly share code, notes, and snippets.

@lucassmagal
Last active December 22, 2015 06:29
Show Gist options
  • Save lucassmagal/6431442 to your computer and use it in GitHub Desktop.
Save lucassmagal/6431442 to your computer and use it in GitHub Desktop.
upperLetter, downLetter :: Char -> Char
upperLetter letter =
let ascii = fromEnum letter in
if ascii >= 97 && ascii <= 122
then toEnum (ascii - 32)
else letter
downLetter letter =
let ascii = fromEnum letter in
if ascii >= 65 && ascii <= 90
then toEnum (ascii + 32)
else letter
strToUpper, strToDown :: String -> String
strToUpper [] = []
strToUpper (h:t) = upperLetter h:strToUpper t
-- uppercase str = [ upperLetter l | l <- str ]
strToDown [] = []
strToDown (h:t) = downLetter h:strToDown t
-- downcase str = [ downLetter l | l <- str ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment