~jaro/balkon

ref: 573d4d8d02f6d30b7c1930f86f761120cc947350 balkon/test/Data/Text/ParagraphLayout/RunLengthEncoding.hs -rw-r--r-- 326 bytes
573d4d8dJaro Simplify code since run direction is always known. 1 year, 3 months ago
                                                                                
1
2
3
4
5
6
7
8
module Data.Text.ParagraphLayout.RunLengthEncoding (runLengthDecode) where

-- | Decode a run-length encoded list.
--
-- Helpful for concisely representing lists with many repeated values.
runLengthDecode :: [(Int, a)] -> [a]
runLengthDecode [] = []
runLengthDecode ((len, val) : xs) = replicate len val ++ runLengthDecode xs