Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module DecorateSortUniq where
- import Data.List
- decorateSortUniq :: Ord a => [a] -> [a]
- decorateSortUniq = map snd . sortBy (\(a,_) (b,_)->compare a b) . uniq snd . sortBy (\(_,a) (_,b)->compare a b) . zip [0..]
- where uniq f (x:y:xs) = if f x == f y then uniq f (x:xs) else x:uniq f (y:xs)
- uniq _ (x:_) = [x]
Add Comment
Please, Sign In to add comment