M balkon.cabal => balkon.cabal +1 -0
@@ 197,6 197,7 @@ test-suite balkon-test
Data.Text.ParagraphLayout.RectSpec,
Data.Text.ParagraphLayout.Rich.ParagraphData,
Data.Text.ParagraphLayout.RichSpec,
+ Data.Text.ParagraphLayout.RunLengthEncoding,
Data.Text.ParagraphLayout.TextData
-- Test dependencies.
A test/Data/Text/ParagraphLayout/RunLengthEncoding.hs => test/Data/Text/ParagraphLayout/RunLengthEncoding.hs +8 -0
@@ 0,0 1,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