You are viewing a single comment's thread. Return to all comments →
Haskell
comp [] _ = [] comp [c] 1 = [c] comp [c] n = [c] ++ show n comp (x:xs) n | x == head xs = comp xs (n+1) | n == 1 = [x] ++ comp xs 1 | otherwise = [x] ++ show n ++ comp xs 1 main = getLine >>= putStrLn . (flip comp 1)
Seems like cookies are disabled on this browser, please enable them to open this website
String Compression
You are viewing a single comment's thread. Return to all comments →
Haskell