Returns an element of the non-empty list l that minimizes f. If x, y are
such that f x = f y, it returns whichever comes first in the list.
The correctness of this function assumes β to be linearly pre-ordered.
The property that List.minOn is the first minimizer in the list is guaranteed by the lemma
List.getElem_minIdxOn.
Equations
- List.minOn f (x :: xs) h_2 = List.foldl (minOn f) x xs
Instances For
Returns an element of the non-empty list l that maximizes f. If x, y are
such that f x = f y, it returns whichever comes first in the list.
The correctness of this function assumes β to be linearly pre-ordered.
The property that List.maxOn is the first maximizer in the list is guaranteed by the lemma
List.getElem_maxIdxOn.
Equations
- List.maxOn f l h = List.minOn f l h
Instances For
Returns an element of l that minimizes f. If x, y are such that
f x = f y, it returns whichever comes first in the list. Returns none if the list is
empty.
The correctness of this function assumes β to be linearly pre-ordered.
The property that List.minOn? is the first minimizer in the list is guaranteed by the lemma
List.getElem_get_minIdxOn?
Equations
- List.minOn? f [] = none
- List.minOn? f (x :: xs) = some (List.foldl (minOn f) x xs)
Instances For
Returns an element of l that maximizes f. If x, y are such that
f x = f y, it returns whichever comes first in the list. Returns none if the list is
empty.
The correctness of this function assumes β to be linearly pre-ordered.
The property that List.maxOn? is the first minimizer in the list is guaranteed by the lemma
List.getElem_get_maxIdxOn?.
Equations
- List.maxOn? f l = List.minOn? f l
Instances For
List.minOn? returns none when applied to an empty list.