Guest User

Untitled

a guest
Jan 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. module DecorateSortUniq where
  2.  
  3. import Data.List
  4.  
  5. decorateSortUniq :: Ord a => [a] -> [a]
  6. decorateSortUniq = map snd . sortBy (\(a,_) (b,_)->compare a b) . uniq snd . sortBy (\(_,a) (_,b)->compare a b) . zip [0..]
  7. where uniq f (x:y:xs) = if f x == f y then uniq f (x:xs) else x:uniq f (y:xs)
  8. uniq _ (x:_) = [x]
Add Comment
Please, Sign In to add comment