evantianx / CodeWars-Haskell

0 stars 0 forks source link

Mumbling #11

Open evantianx opened 6 years ago

evantianx commented 6 years ago

Examples:

accum "abcd"    -- "A-Bb-Ccc-Dddd"
accum "RqaEzty" -- "R-Qq-Aaa-Eeee-Zzzzz-Tttttt-Yyyyyyy"
accum "cwAt"    -- "C-Ww-Aaa-Tttt"

The parameter of accum is a string which includes only letters from a..z and A..Z.

evantianx commented 6 years ago

Solutions

import Data.Char
import Data.List

accum :: String -> String
accum = intercalate "-" . zipWith f [0..]
        where f n c = toUpper c : replicate n (toLower c)