Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Prelude> myMaximumBy (_ _ -> GT) [1..10]
- 1
- Prelude> myMaximumBy (_ _ -> LT) [1..10]
- 10
- myMaximumBy :: (a -> a -> Ordering) -> [a] -> a
- myMaximumBy f (x:xs) = foldl doF x xs
- where
- doF a b
- | f a b == GT = a
- | otherwise = b
Add Comment
Please, Sign In to add comment