~jaro/balkon

ref: c5e25e2b7a77d3af82227c1151820c2f4ddc559f balkon/test/Data/Text/ParagraphLayout/RunLengthEncoding.hs -rw-r--r-- 326 bytes
c5e25e2bJaro Clean up vertical alignment code structure. 1 year, 2 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