Skip to content

Instantly share code, notes, and snippets.

@amitaibu
Last active March 5, 2016 17:59
Show Gist options
  • Save amitaibu/a7187ebd5a88c9738203 to your computer and use it in GitHub Desktop.
Save amitaibu/a7187ebd5a88c9738203 to your computer and use it in GitHub Desktop.
myMaximumBy :: (a -> a -> Ordering) -> [a] -> a
myMaximumBy _ [] = undefined
myMaximumBy _ (x : []) = x
myMaximumBy f (x : xs) =
case f x val of
GT -> x
_ -> val
where val = (myMaximumBy f xs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment