AllTrue

AllTrue[{e1,e2,},test]

yields True if test[ei] is True for all of the ei.

AllTrue[expr,test,level]

tests parts of expr at level level.

AllTrue[test]

represents an operator form of AllTrue that can be applied to an expression.

Details

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

Examples

open allclose all

Basic Examples  (4)

Test if all elements of a list satisfy a condition:

Check if all elements of a matrix satisfy a condition:

Test if all values of an association satisfy a condition:

If the condition applied to no element produces False, a symbolic result may be returned:

Even when the condition applied to some elements is symbolic, a definitive result may be deduced:

TrueQ may be used to avoid getting a symbolic result:

Scope  (3)

AllTrue may be applied to expressions with any head:

AllTrue can operate on ragged expressions:

By default, AllTrue always operates at level 1:

Properties & Relations  (5)

Compose the predicate with TrueQ to make the predicate stronger:

AllTrue[list,f] is equivalent to NoneTrue[list,Composition[Not,f]]:

AllTrue[list,f] is equivalent to VectorQ[list,f] when f evaluates to True or False:

AllTrue[list,f] works efficiently on sparse vectors:

AllTrue[list,test] checks the parts of list in order, stopping as soon as test returns False:

Possible Issues  (1)

A symbolic result may be returned:

Wolfram Research (2014), AllTrue, Wolfram Language function, https://reference.wolfram.com/language/ref/AllTrue.html (updated 2015).

Text

Wolfram Research (2014), AllTrue, Wolfram Language function, https://reference.wolfram.com/language/ref/AllTrue.html (updated 2015).

BibTeX

@misc{reference.wolfram_2021_alltrue, author="Wolfram Research", title="{AllTrue}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/AllTrue.html}", note=[Accessed: 25-July-2021 ]}

BibLaTeX

@online{reference.wolfram_2021_alltrue, organization={Wolfram Research}, title={AllTrue}, year={2015}, url={https://reference.wolfram.com/language/ref/AllTrue.html}, note=[Accessed: 25-July-2021 ]}

CMS

Wolfram Language. 2014. "AllTrue." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/AllTrue.html.

APA

Wolfram Language. (2014). AllTrue. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/AllTrue.html