Ad

Changes:

  • refactoring
  • Tests added
  • Feedback implemented
Code
Diff
  • module HeLlOwOrLd where
    
    import Data.Char (toUpper, toLower, isLetter)
    
    convert :: String -> String
    convert = zipWith ($) (cycle [toUpper, toLower]) . filter isLetter
    
    • module HeLlOwOrLd where
    • import Data.Char (toUpper, toLower)
    • import Data.Char (toUpper, toLower, isLetter)
    • convert :: String -> String
    • convert [] = []
    • convert (' ':xs) = convert xs
    • convert (x:xs) = (toUpper x):(convert' xs) where
    • convert' :: String -> String
    • convert' [] = []
    • convert' (' ':xs) = convert' xs
    • convert' (x:xs) = (toLower x):(convert xs)
    • convert = zipWith ($) (cycle [toUpper, toLower]) . filter isLetter