or<A> function
- Predicate<
A> first
Creates a new predicate that is the logical disjunction of two given predicates.
Example usage:
```dart
Predicate<int> isEven = (int n) => n % 2 == 0;
Predicate<int> isPositive = (int n) => n > 0;
Predicate<int> isEvenOrPositive = or(isEven)(isPositive);
print(isEvenOrPositive(2)); // Prints: true
print(isEvenOrPositive(-1)); // Prints: false
print(isEvenOrPositive(1)); // Prints: true
Implementation
Predicate<A> Function(Predicate<A>) or<A>(Predicate<A> first) {
return (Predicate<A> second) {
return (A value) {
return first(value) || second(value);
};
};
}