Question: {- The functions rle and rleh below implement run-length encoding. Run-length encoding is a basic data-compression algorithm that summarizes runs of length n of a

{- The functions rle and rleh below implement run-length encoding. Run-length encoding is a basic data-compression algorithm that summarizes runs of length n of a repeated element x as just the pair (n,x). Run rle on some example lists to see what it is doing. Your job is to implement the rlelh function below, to be similar to rleh, but in the Logging functor, with the following log messages: "base" for the base case "change" for when we enter the else branch in the second equation -} -- rleh :: Eq a => Int -> a => [a] -> [(Int,a)] rleh ch [] - [(ch)] rlehch' (h:t) = if h == h' then rleh (C+1) ht else (c,h') : rleh 1 ht rle :: Eq a => [a] -> [(Int,a)] rle [] = [] rle (h:t) rleh 1 ht = = {- copy the code above and then tweak it to use the Logging applicative. See the filterc, filtera, filterg examples from week4's Inclass.hs. -} rlelh :: Eq a => Int -> a => [a] -> Logging ((Int, a)] rlelh undefined = rlel :: Eq a => [a] -> Logging ((Int,a)] rlel [] = pure [] rlel (h:t) rlelh 1 ht =

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 Programming Questions!