DEV Community

loading...

Discussion on: Daily Challenge #210 - Separate Capitalization

Collapse
craigmc08 profile image
Craig McIlwrath

Kinda silly solution using 2 mutually recursive functions (Haskell)

import Data.Char (toUpper, toLower) 

skip :: String -> String
skip [] = [] 
skip (c:cs) = c : capitalize' cs

capitalize' :: String -> String
capitalize' [] = [] 
capitalize' (c:cs) = toUpper c : skip cs

capitalize :: String -> (String, String) 
capitalize cs = (capitalize' cs, skip cs) 
Collapse
avalander profile image
Avalander

Ooh, clever! I like it!