min<A> function
- Ord<
A> O
Returns a function that returns the minimum of two values.
Example:
void main() {
// Create an Ord instance for integers
Ord<int> ordInt = fromCompare((x, y) => x.compareTo(y));
// Create a function to find the minimum of two integers using the ordInt instance
int Function(int, int) findMin = min(ordInt);
// Find the minimum of two integers
int minValue = findMin(5, 10); // Output: 5 (Minimum value)
}
Implementation
A Function(A first, A second) min<A>(Ord<A> O) {
return (A first, A second) => O.compare(first, second) < 0 ? first : second;
}