minimumBy package:base

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.
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:
>>> biminimumBy compare (42, 17)
17
>>> biminimumBy compare (Left 17)
17
>>> biminimumBy compare (BiList [42, 17, 23] [-5, 18])
-5
On empty structures, this function throws an exception:
>>> biminimumBy compare (BiList [] [])
*** Exception: bifoldr1: empty structure
...