Only advanced Sanctuary users would think of the expressions above; I don't consider them suitable substitutes for S.allPass (preds) (x) and S.anyPass (preds) (x).
My second idea was simpler:
S.all (S.T (x)) (preds)
S.any (S.T (x)) (preds)
The expressions above read well to me. When applied to x, do all of the predicates return true?When applied to x, do any of the predicates return true? This is exactly how I read the expressions featuring S.allPass and S.anyPass. :)
I've never been happy with these functions, but until now I've been unable to explain my discomfort.
Consider the following expressions:
My first idea was to fold the predicates into a single predicate:
If one is willing to unconditionally apply every predicate, one can replace the lambdas:
Only advanced Sanctuary users would think of the expressions above; I don't consider them suitable substitutes for
S.allPass (preds) (x)
andS.anyPass (preds) (x)
.My second idea was simpler:
The expressions above read well to me. When applied to
x
, do all of the predicates returntrue
? When applied tox
, do any of the predicates returntrue
? This is exactly how I read the expressions featuringS.allPass
andS.anyPass
. :)