6 lines
223 B
Haskell
6 lines
223 B
Haskell
import Data.List (group, sort)
|
|
|
|
mode :: (Ord a) => [a] -> [a]
|
|
mode xs = map fst $ filter ((==best).snd) counts
|
|
where counts = map (\l -> (head l, length l)) . group . sort $ xs
|
|
best = maximum (map snd counts)
|