Question: {- Carries out run-length encoding on input string. Run-length encoding is a simple form of data compression that replaces characters in a stream with the

{-

Carries out run-length encoding on input string.

Run-length encoding is a simple form of data compression that replaces

characters in a stream with the count of adjacent occurrences of that

character and just a single instance of the character itself. Write a

function that takes a string and returns a list of tuples reprenting the

run-length encoding of that string.

Examples:

runLengthEncode "aaaaaaabbb"

=> [(7,'a'),(3,'b')]

runLengthEncode "happy daaay"

=> [(1,'h'),(1,'a'),(2,'p'),(1,'y'),(1,' '),(1,'d'),(3,'a'),(1,'y')]

-}

runLengthEncode :: String -> [(Int,Char)]

runLengthEncode = undefined

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!