NOTE: Function should be implemented in Haskell! Run-length encoding, or RLE, is
ID: 3798439 • Letter: N
Question
NOTE: Function should be implemented in Haskell!
Run-length encoding, or RLE, is a common form of compression for data that are repetitious. Write a function, myRLE, which takes as an input a list, and compresses it as follows: Main> myRLE [1, 1, 1, 2, 3, 1, 4, 4, 5, 5, 5, 1, 2] [(3, 1), (1, 2), (1, 3), (1, 1), (2, 4), (3, 5), (1, 1), (1, 2)] Main> myRLE "hhhelllllllo worrrrld" [(3, 'h'), (1, 'e'), (7, '1'), (1, 'o'), (1, ' '), (1, 'w'), (1, 'o'), (4, 'r'), (1, '1'), (1, 'd')] You might find it useful to define a helper function.Explanation / Answer
module RunLengthEncoding where
import Data.List (group)
import Control.Arrow ((&&&))
module RunLengthEncoding where
import Data.List (group)
import Control.Arrow ((&&&))
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.