99-haskell-problems/Problems 11-20/problem_12.hs

9 lines
248 B
Haskell
Raw Normal View History

2024-05-24 18:50:16 -05:00
data ListItem a = Single a | Multiple Int a deriving (Read)
fromListItem :: ListItem a -> [a]
fromListItem (Single x) = [x]
fromListItem (Multiple n x) = replicate n x
decodeModified :: [ListItem a] -> [a]
decodeModified = concatMap fromListItem