AnyTrue

AnyTrue[{e1,e2,},test]
yields True if is True for any of the .

AnyTrue[expr,test,level]
tests parts of expr at level level.

AnyTrue[test]
represents an operator form of AnyTrue that can be applied to an expression.

DetailsDetails

  • AnyTrue[expr,test] and AnyTrue[expr,test,level] only evaluate as many as are necessary to determine the result.
  • AnyTrue[list,test] is equivalent to AnyTrue[list,test,1].
  • AnyTrue[test][list] is equivalent to AnyTrue[list,test].

ExamplesExamplesopen allclose all

Basic Examples  (4)Basic Examples  (4)

Check if any element of a list satisfies a condition:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Check if any element of a matrix satisfies a condition:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Check if any value of an association satisfies a condition:

In[1]:=
Click for copyable input
Out[1]=

A symbolic result may be returned:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

TrueQ may be used to avoid getting a symbolic result:

In[3]:=
Click for copyable input
Out[3]=
Introduced in 2014
(10.0)
Translate this page: