solution.hs 357 B

123456789101112131415161718
  1. -- https://www.codewars.com/kata/54b42f9314d9229fd6000d9c
  2. module Dups where
  3. import Data.Char
  4. count s c
  5. | s == [] = 0
  6. | c == (head s) = 1 + count (tail s) c
  7. | otherwise = count (tail s) c
  8. convert s c
  9. | count s c > 1 = ')'
  10. | otherwise = '('
  11. duplicateEncode :: String -> String
  12. duplicateEncode s = map (convert ls) ls
  13. where ls = map toLower s