Advertisement
Guest User

Untitled

a guest
Dec 5th, 2020
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import Data.List
  2. import Data.Ord
  3. import Data.Function
  4.  
  5. pickMajority :: Ord b => (a -> b) -> [a] -> a
  6. pickMajority f = head
  7.                . head
  8.                . sortBy (flip $ comparing length)
  9.                . groupBy ((==) `on` f)
  10.                . sortBy (comparing f)
  11.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement