Returns the index of an element of the non-empty list xs that minimizes f.
If x, y are such that f x = f y, it returns the index of whichever comes first
in the list.
The correctness of this function assumes β to be linearly pre-ordered.
Equations
- List.minIdxOn f (y :: ys) h_2 = List.minIdxOn.go✝ f y 0 1 ys
Instances For
Returns the index of an element of xs that minimizes f. If x, y
are such that f x = f y, it returns the index of whichever comes first in the list.
Returns none if the list is empty.
The correctness of this function assumes β to be linearly pre-ordered.
Equations
- List.minIdxOn? f [] = none
- List.minIdxOn? f (y :: ys) = some (List.minIdxOn f (y :: ys) ⋯)
Instances For
Returns the index of an element of the non-empty list xs that maximizes f.
If x, y are such that f x = f y, it returns the index of whichever comes first
in the list.
The correctness of this function assumes β to be linearly pre-ordered.
Equations
- List.maxIdxOn f xs h = List.minIdxOn f xs h
Instances For
Returns the index of an element of xs that maximizes f. If x, y
are such that f x = f y, it returns the index of whichever comes first in the list.
Returns none if the list is empty.
The correctness of this function assumes β to be linearly pre-ordered.
Equations
- List.maxIdxOn? f xs = List.minIdxOn? f xs
Instances For
The proof of List.minOn_append uses associativity of minOn and applies foldl_assoc.
The proof of minIdxOn_append is analogous, but the
aggregation operation, combineMinIdxOn, depends on
the length of the lists to combine. After proving associativity of the aggregation operation,
the proof closely follows the proof of foldl_assoc.