maximumBy is:exact

The largest element of a non-empty structure with respect to the given comparison function. Structure order is used as a tie-breaker: if there are multiple largest elements, the rightmost of them is chosen.

Examples

Basic usage:
>>> maximumBy (compare `on` length) ["Hello", "World", "!", "Longest", "bar"]
"Longest"
WARNING: This function is partial for possibly-empty structures like lists.
The largest element of a non-empty structure with respect to the given comparison function. Structure order is used as a tie-breaker: if there are multiple largest elements, the rightmost of them is chosen.
O(n) Yield the maximum element of the vector according to the given comparison function. The vector may not be empty. In case of a tie, the first occurrence wins. This behavior is different from maximumBy which returns the last tie.

Examples

>>> import Data.Ord

>>> import qualified Data.Vector as V

>>> V.maximumBy (comparing fst) $ V.fromList [(2,'a'), (1,'b')]
(2,'a')

>>> V.maximumBy (comparing fst) $ V.fromList [(1,'a'), (1,'b')]
(1,'a')
O(n) Yield the maximum element of the vector according to the given comparison function. The vector may not be empty. In case of a tie, the first occurrence wins. This behavior is different from maximumBy which returns the last tie.

Examples

>>> import Data.Ord

>>> import qualified Data.Vector.Strict as V

>>> V.maximumBy (comparing fst) $ V.fromList [(2,'a'), (1,'b')]
(2,'a')

>>> V.maximumBy (comparing fst) $ V.fromList [(1,'a'), (1,'b')]
(1,'a')
O(n) Yield the maximum element of the vector according to the given comparison function. The vector may not be empty. In case of a tie, the first occurrence wins. This behavior is different from maximumBy which returns the last tie.
O(n) Yield the maximum element of the vector according to the given comparison function. The vector may not be empty. In case of a tie, the first occurrence wins. This behavior is different from maximumBy which returns the last tie.
O(n) Yield the maximum element of the vector according to the given comparison function. The vector may not be empty. In case of a tie, the first occurrence wins. This behavior is different from maximumBy which returns the last tie.

Examples

>>> import Data.Ord

>>> import qualified Data.Vector.Unboxed as VU

>>> VU.maximumBy (comparing fst) $ VU.fromList [(2,'a'), (1 :: Int,'b')]
(2,'a')

>>> VU.maximumBy (comparing fst) $ VU.fromList [(1,'a'), (1 :: Int,'b')]
(1,'a')
Computes the maximum element with respect to the given comparison function
Computes the maximum element with respect to the given comparison function
The largest element of a non-empty structure with respect to the given comparison function.

Examples

Basic usage:
>>> maximumBy (compare `on` length) ["Hello", "World", "!", "Longest", "bar"]
"Longest"
WARNING: This function is partial for possibly-empty structures like lists.
The largest element of a non-empty structure with respect to the given comparison function.
O(n) Yield the maximum element of the vector according to the given comparison function. The vector may not be empty.
O(n) Yield the maximum element of the vector according to the given comparison function. The vector may not be empty.
O(n) Yield the maximum element of the vector according to the given comparison function. The vector may not be empty.
O(n) Yield the maximum element of the vector according to the given comparison function. The vector may not be empty.
Get the maximum element of a monomorphic container, using a supplied element ordering function. Safe version of maximumByEx, only works on monomorphic containers wrapped in a NonNull.
maximumBy is a total function
Determine the maximum element in a stream using the supplied comparison function.
maximumBy = Stream.fold Fold.maximumBy
The largest element of a structure with respect to the given comparison function.
O(n) Yield the maximum element of the non-empty vector according to the given comparison function.
O(n) Yield the maximum element of the non-empty vector according to the given comparison function.
O(n) Yield the maximum element of the non-empty vector according to the given comparison function.
O(n) Yield the maximum element of the non-empty vector according to the given comparison function.
O(n) Yield the maximum element of the non-empty vector according to the given comparison function.