Summary
Add a variadic majority predicate combinator.
majority(p1, p2, p3, ...)
The same input is evaluated against each supplied predicate. The result is true when strictly more than half of the predicates are satisfied.
Semantics
For n predicates, majority succeeds when more than n / 2 predicates succeed.
Examples:
- 1 predicate → 1 success required
- 2 predicates → 2 successes required
- 3 predicates → 2 successes required
- 4 predicates → 3 successes required
- 5 predicates → 3 successes required
Requirements
- Accept any number of predicate arguments.
- Evaluate every predicate against the same input value.
- Short-circuit as soon as the final result is known.
- Define and test behavior for zero predicate arguments.
- Add conformance tests and function metadata/documentation.
Notes
majority is intentionally a named logical concept rather than a special case of the predicate-cardinality functions. Its threshold depends on the number of supplied predicates and is therefore useful enough to express directly.
Summary
Add a variadic
majoritypredicate combinator.The same input is evaluated against each supplied predicate. The result is
truewhen strictly more than half of the predicates are satisfied.Semantics
For
npredicates,majoritysucceeds when more thann / 2predicates succeed.Examples:
Requirements
Notes
majorityis intentionally a named logical concept rather than a special case of the predicate-cardinality functions. Its threshold depends on the number of supplied predicates and is therefore useful enough to express directly.