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 satisfies pred.
!any can be used to verify that none of the elements satisfy
pred.
This is sometimes called exists in other languages.
						
				template any(alias pred)
				;
						
					
				Contained Functions
| Name | Description | 
|---|---|
| any | Returns trueif and only if the input rangerangeis non-empty
    and any value found inrangesatisfies the predicatepred.
    Performs (at most) Ο(range) evaluations ofpred. | 
Example
import stdExample
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-2024 by the D Language Foundation | Page generated by ddox.