minimumBy -package:base-prelude

The least 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 least elements, the leftmost of them is chosen.

Examples

Basic usage:
>>> minimumBy (compare `on` length) ["Hello", "World", "!", "Longest", "bar"]
"!"
WARNING: This function is partial for possibly-empty structures like lists.
The least 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 least elements, the leftmost of them is chosen.
O(n) Yield the minimum 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.

Examples

>>> import Data.Ord

>>> import qualified Data.Vector as V

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

>>> V.minimumBy (comparing fst) $ V.fromList [(1,'a'), (1,'b')]
(1,'a')
O(n) Yield the minimum 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.

Examples

>>> import Data.Ord

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

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

>>> V.minimumBy (comparing fst) $ V.fromList [(1,'a'), (1,'b')]
(1,'a')
O(n) Yield the minimum 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.
O(n) Yield the minimum 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.
O(n) Yield the minimum 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.

Examples

>>> import Data.Ord

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

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

>>> VU.minimumBy (comparing fst) $ VU.fromList [(1,'a'), (1 :: Int,'b')]
(1,'a')
O(n) Yield the minimum element of the vector according to the given comparison function. The vector may not be empty.
Computes the minimum element with respect to the given comparison function
Computes the minimum element with respect to the given comparison function
The least element of a non-empty structure with respect to the given comparison function.

Examples

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