AnyTrue
Examples
open all close allBasic Examples (4)
Check if any element of a list satisfies a condition:
AnyTrue[{1, 2, 3, 4, 5, 6}, EvenQ]AnyTrue[{1, 3, 5, 7, 9}, EvenQ]Check if any element of a matrix satisfies a condition:
AnyTrue[{{1, 2, 3}, {4, 5, 6}}, EvenQ, 2]AnyTrue[{{1, 3, 5}, {7, 9, 11}}, EvenQ, 2]Check if any value of an association satisfies a condition:
AnyTrue[<|"a" -> 2, "b" -> 3, "c" -> 6|>, OddQ]A symbolic result may be returned:
AnyTrue[{12, 16, x, 14, y}, # < 10&]% /. {x -> 3, y -> 7}TrueQ may be used to avoid getting a symbolic result:
AnyTrue[{12, 16, x, 14, y}, TrueQ[# < 10]&]Scope (3)
AnyTrue may be applied to expressions with any head:
AnyTrue[f[2, 7, 6], OddQ]AnyTrue[f[x, y, z], # < 10&]AnyTrue can operate on ragged expressions:
AnyTrue[{{1, 2, 3}, {4, 5}}, EvenQ, 2]AnyTrue[f[{1, 2, 3}, {4, 5}], EvenQ, 2]By default, AnyTrue operates at level 1:
AnyTrue[4, EvenQ]AnyTrue[{}, EvenQ]AnyTrue[4, EvenQ, 0]Properties & Relations (4)
Compose the predicate with TrueQ to make the predicate stronger:
AnyTrue[{x, y, z}, Composition[TrueQ, f]]AnyTrue[list,f] is equivalent to !NoneTrue[list,f]:
LogicalExpand /@ {AnyTrue[{x, y, z}, f], !NoneTrue[{x, y, z}, f]}AnyTrue[list,f] works efficiently on sparse vectors:
AnyTrue[SparseArray[{1000 -> 3}, {1000000000000}], OddQ]AnyTrue[list,test] checks the parts of list in order, stopping as soon as test returns True:
AnyTrue[{1, 2, 3, 4, 5}, (Print[#];EvenQ[#])&]Text
Wolfram Research (2014), AnyTrue, Wolfram Language function, https://reference.wolfram.com/language/ref/AnyTrue.html (updated 2015).
CMS
Wolfram Language. 2014. "AnyTrue." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/AnyTrue.html.
APA
Wolfram Language. (2014). AnyTrue. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/AnyTrue.html
BibTeX
@misc{reference.wolfram_2026_anytrue, author="Wolfram Research", title="{AnyTrue}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/AnyTrue.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_anytrue, organization={Wolfram Research}, title={AnyTrue}, year={2015}, url={https://reference.wolfram.com/language/ref/AnyTrue.html}, note=[Accessed: 12-June-2026]}