Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exercise 10 #2

Open
flip111 opened this issue May 20, 2015 · 0 comments
Open

exercise 10 #2

flip111 opened this issue May 20, 2015 · 0 comments

Comments

@flip111
Copy link

flip111 commented May 20, 2015

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) []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant