minimumBy -package:vector-sized

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.
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.
The least element of a NonEmpty 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.
The minimumBy function takes a comparison function and a list and returns the least element of the list by the comparison function. The list must be finite and non-empty. List order is used as a tie-breaker: if there are multiple least elements, the first of them is chosen.

Examples

We can use this to find the shortest entry of a list:
>>> minimumBy (\x y -> compare (length x) (length y)) ["Hello", "World", "!", "Longest", "bar"]
"!"
>>> minimumBy (\(a, b) (c, d) -> compare (abs (a - b)) (abs (c - d))) [(10, 15), (1, 2), (3, 5)]
(1, 2)
The minimumBy function takes a comparison function and a list and returns the least element of the list by the comparison function. The list must be finite and non-empty. Empty lists throw an EmptyListException.
Minimal bin content using custom comparison.