You are viewing a single comment's thread. Return to all comments →
Haskell
compression ( x : y : xs ) count | y == x = compression ( y : xs ) ( count + 1 ) | otherwise = ( if count == 1 then x : compression ( y : xs ) 1 else x : ( show count ) ++ compression ( y : xs ) 1 ) compression ( x : [] ) count | count > 1 = x : show count | otherwise = [ x ] _compression = flip compression 1 main = getLine >>= putStrLn . _compression
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