AllMatch
Details
Examples
open all close allBasic Examples (4)
Check if all elements of a list match a pattern:
AllMatch[{x ^ 2, x ^ 3, x ^ 5, x ^ 6}, x ^ _]AllMatch[{x ^ 2, y ^ 3, x ^ 5, x ^ 6}, x ^ _]Check if all elements of a matrix match a pattern:
AllMatch[{{1, 2, 3}, {4, 5, 6}}, _Integer, 2]AllMatch[{{a, 2, c}, {4, e, 6}}, _Integer, 2]Use the operator form of AllMatch:
AllMatch[_Integer][{1, 2, 3, 4, 5}]Check if all values of an association match a pattern:
AllMatch[<|"a" -> 1, "b" -> 2, "c" -> 3|>, _Integer]Scope (4)
AllMatch may be applied to expressions with any head:
AllMatch[f[1, 2, 3], _Integer]AllMatch can operate on ragged expressions:
AllMatch[{{1, 2, 3}, {4, 5}}, _Integer, 2]AllMatch[f[{1, 2, 3}, {4, 5}], _Integer, 2]By default, AllMatch operates at level 1:
AllMatch[4, _String]AllMatch[{}, _String]AllMatch[4, _String, 0]Use Verbatim to test for a literal blank:
AllMatch[f[_, _, _], Verbatim[_]]Properties & Relations (6)
AllMatch[list,form] is equivalent to NoneMatch[list,Except[form]]:
{AllMatch[{1, 2, 3, 4, 5}, _Integer], NoneMatch[{1, 2, 3, 4, 5}, Except[_Integer]]}AllMatch[list,form] works efficiently on sparse vectors:
AllMatch[SparseArray[{1000 -> 2}, {1000000000000}], _Integer]AllMatch[list,form] checks the parts of list in order, stopping as soon as form does not match:
AllMatch[{1, 2, 3, 4, 5}, _ ? (OddQ @* Echo)]AllMatch[list,form] is equivalent to AllTrue[list,MatchQ[form]]:
{AllMatch[{1, 2, 3, 4, 5}, _Integer], AllTrue[{1, 2, 3, 4, 5}, MatchQ[_Integer]]}AllMatch[{e1,e2,…},form] is equivalent to And[MatchQ[e1,form],MatchQ[e2,form],…]:
{AllMatch[{1, 2, 3}, _Integer], MatchQ[1, _Integer] && MatchQ[2, _Integer] && MatchQ[3, _Integer]}AllMatch[list,e1|e2|…] is equivalent to ContainsOnly[list,{e1,e2,…}]:
{AllMatch[{a, a, b, a, b}, a | b], ContainsOnly[{a, a, b, a, b}, {a, b}]}Possible Issues (1)
For associations, AllMatch tests only values:
AllMatch[<|a -> 1|>, 1]AllMatch[<|a -> 1|>, a]History
Text
Wolfram Research (2024), AllMatch, Wolfram Language function, https://reference.wolfram.com/language/ref/AllMatch.html.
CMS
Wolfram Language. 2024. "AllMatch." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/AllMatch.html.
APA
Wolfram Language. (2024). AllMatch. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/AllMatch.html
BibTeX
@misc{reference.wolfram_2026_allmatch, author="Wolfram Research", title="{AllMatch}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/AllMatch.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_allmatch, organization={Wolfram Research}, title={AllMatch}, year={2024}, url={https://reference.wolfram.com/language/ref/AllMatch.html}, note=[Accessed: 13-June-2026]}