View source code
Display the source code in std/algorithm/searching.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Template std.algorithm.searching.any
Checks if any of the elements verifies pred
.
!any
can be used to verify that none of the elements verify
pred
.
This is sometimes called exists
in other languages.
template any(alias pred)
;
Contained Functions
Name | Description |
---|---|
any | Returns true if and only if any value v found in the
input range range satisfies the predicate pred .
Performs (at most) Ο(range ) evaluations of pred .
|
Example
import std .ascii : isWhite;
assert( all!(any!isWhite)(["a a", "b b"]));
assert(!any!(all!isWhite)(["a a", "b b"]));
Example
any
can also be used without a predicate, if its items can be
evaluated to true or false in a conditional statement. !any
can be a
convenient way to quickly test that none of the elements of a range
evaluate to true.
int[3] vals1 = [0, 0, 0];
assert(!any(vals1[])); //none of vals1 evaluate to true
int[3] vals2 = [2, 0, 2];
assert( any(vals2[]));
assert(!all(vals2[]));
int[3] vals3 = [3, 3, 3];
assert( any(vals3[]));
assert( all(vals3[]));
Authors
License
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.