Advertisement
Guest User

Untitled

a guest
Apr 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. pack' :: (Eq a) => [a] -> [[a]] -> [[a]]
  2. pack' [] y = y
  3. pack' (x:xs) [] = pack' xs [[x]]
  4. pack' (x:xs) (y:ys) = if x == head y then pack' xs ((x:y):ys) else pack' xs ([[x], y]++ys)
  5.  
  6. pack :: (Eq a) => [a] -> [[a]]
  7. pack x = reverse (pack' x [])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement