Haskell
import Data.Char (|>) = flip ($) split :: String -> [String] split [] = [""] split (character : characters) | character == ' ' = "" : rest | otherwise = (character : head rest) : tail rest where rest = split characters uppercase :: String -> String uppercase string = map toUpper string lowercase :: String -> String lowercase string = map toLower string capitalize :: String -> String capitalize string = uppercase firstCharacter ++ lowercase remainingCharacters where firstCharacter :: String firstCharacter = take 1 string remainingCharacters :: String remainingCharacters = drop 1 string join :: [String] -> String join strings = foldl (++) "" strings camelcase :: String -> String camelcase string = string |> split |> map capitalize |> join main :: IO () main = do print $ camelcase "hello case" -- HelloCase print $ camelcase "camel case word" -- CamelCaseWord
Source-Code
Available on repl.it.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Haskell
Source-Code
Available on repl.it.