max<A> function
- Bounded<
A> bounded
Creates a monoid that finds the maximum value in a Bounded structure
Example:
void main() {
// Create a bounded integer type for values between 1 and 10
Bounded<int> bounded = BoundedInt(1, 10);
// Create a monoid that finds the maximum value in the bounded structure
BaseMonoid<int> maxMonoid = max(bounded);
// Find the maximum value in a list of integers using the maxMonoid
List<int> numbers = [5, 2, 8, 4, 1];
int maxValue = concatAll(maxMonoid)(numbers); // Output: 10 (Maximum value)
}
Implementation
BaseMonoid<A> max<A>(Bounded<A> bounded) {
return _MaxMonoid<A>(bounded);
}