99haskell icon indicating copy to clipboard operation
99haskell copied to clipboard

exercise 10

Open flip111 opened this issue 10 years ago • 0 comments

In exercise 10 it's not clear that you need the previous function (from exercise 9) this is not really user friendly. Also imports do not work so you can not use the native pack or group functions from Data.List

pack (x:xs) = let (first,rest) = span (==x) xs
               in (x:first) : pack rest
pack [] = []

encode :: Eq a => [a] -> [(Int, a)]
encode xs = (enc . pack) xs
    where enc = foldr (\x acc -> (length x, head x) : acc) []

flip111 avatar May 20 '15 15:05 flip111