Ad

Capitalize the first occurence of a letter in the given string. Ignore whitespace.

Added relevant test cases.

Code
Diff
  • module ToUpperFirst where
    
        import Data.Char (toUpper, isSpace)
        
        toUpperFirst (x : xs) = if isSpace x then x : toUpperFirst xs else toUpper x : xs
        toUpperFirst _ = ""
    • module ToUpperFirst where
    • import Data.Char (toUpper)
    • import Data.Char (toUpper, isSpace)
    • toUpperFirst (x : xs) = toUpper x : xs
    • toUpperFirst (x : xs) = if isSpace x then x : toUpperFirst xs else toUpper x : xs
    • toUpperFirst _ = ""