On Thursday, 14 February 2013 at 19:54:28 UTC, Jacob Carlborg wrote:
D has "any" (previously an overload of "canFind") as an algorithm that finds whether at least one element of a range satisfies a condition,
otherwise writable as "!r.find!(a => condition).empty". The
convenience/mechanics/generality of the construct was enough
justification to add the algorithm. To claim that D already has the negation of empty because one can write "r.any(a => true)" is, in my
opinion, an ill-posed argument.

I just thought that we could add a default predicate to the "any" function.

Yes for a default predicate, BUT I think it should be "a => a" (that is, identity function) instead of "a => true". Same default predicate should be applied to "all" function as well. This way the behavior with boolean ranges would match the behavior of "any" and "all" at least in Python and Matlab (and apparently also Ruby).

Reply via email to