Run-length encoding: Difference between revisions

(→‎Haskell :: As a fold: Slight reduction – pruned out an import.)
Line 2,930:
encoded = runLengths testString
putStrLn $ showLengths encoded
print $
print $ concatMap (uncurry replicate) encoded == testString
 
------------------------- DISPLAY ------------------------
showLengths :: [(Int, Char)] -> String
showLengths [] = []</lang>
showLengths ((n, c) : xs) = show n <> [c] <> showLengths xs</lang>
{{Out}}
<pre>12W1B12W3B24W1B14W
9,655

edits