WOLFRAM

AllMatch
AllMatch

New in 14.1

AllMatch[{e1,e2,},form]

yields True if ei matches the pattern form for all of the ei.

AllMatch[expr,form,level]

tests parts of expr at level level.

AllMatch[form]

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

Details

Examples

open allclose all

Basic Examples  (4)Summary of the most common use cases

Check if all elements of a list match a pattern:

Out[1]=1
Out[2]=2

Check if all elements of a matrix match a pattern:

Out[1]=1
Out[2]=2

Use the operator form of AllMatch:

Out[1]=1

Check if all values of an association match a pattern:

Out[1]=1

Scope  (4)Survey of the scope of standard use cases

AllMatch may be applied to expressions with any head:

Out[1]=1

AllMatch can operate on ragged expressions:

Out[1]=1
Out[2]=2

By default, AllMatch operates at level 1:

Out[1]=1
Out[2]=2
Out[3]=3

Use Verbatim to test for a literal blank:

Out[1]=1

Properties & Relations  (6)Properties of the function, and connections to other functions

AllMatch[list,form] is equivalent to NoneMatch[list,Except[form]]:

Out[2]=2

AllMatch[list,form] works efficiently on sparse vectors:

Out[1]=1

AllMatch[list,form] checks the parts of list in order, stopping as soon as form does not match:

Out[1]=1

AllMatch[list,form] is equivalent to AllTrue[list,MatchQ[form]]:

Out[1]=1

AllMatch[{e1,e2,},form] is equivalent to And[MatchQ[e1,form],MatchQ[e2,form],]:

Out[1]=1

AllMatch[list,e1|e2|] is equivalent to ContainsOnly[list,{e1,e2,}]:

Out[1]=1

Possible Issues  (1)Common pitfalls and unexpected behavior

For associations, AllMatch tests only values:

Out[1]=1
Out[2]=2
Wolfram Research (2024), AllMatch, Wolfram Language function, https://reference.wolfram.com/language/ref/AllMatch.html.
Wolfram Research (2024), AllMatch, Wolfram Language function, https://reference.wolfram.com/language/ref/AllMatch.html.

Text

Wolfram Research (2024), AllMatch, Wolfram Language function, https://reference.wolfram.com/language/ref/AllMatch.html.

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.

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

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

BibTeX

@misc{reference.wolfram_2025_allmatch, author="Wolfram Research", title="{AllMatch}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/AllMatch.html}", note=[Accessed: 17-May-2025 ]}

@misc{reference.wolfram_2025_allmatch, author="Wolfram Research", title="{AllMatch}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/AllMatch.html}", note=[Accessed: 17-May-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_allmatch, organization={Wolfram Research}, title={AllMatch}, year={2024}, url={https://reference.wolfram.com/language/ref/AllMatch.html}, note=[Accessed: 17-May-2025 ]}

@online{reference.wolfram_2025_allmatch, organization={Wolfram Research}, title={AllMatch}, year={2024}, url={https://reference.wolfram.com/language/ref/AllMatch.html}, note=[Accessed: 17-May-2025 ]}