AllMatch
范例
打开所有单元 关闭所有单元基本范例 (4)
AllMatch[{x ^ 2, x ^ 3, x ^ 5, x ^ 6}, x ^ _]AllMatch[{x ^ 2, y ^ 3, x ^ 5, x ^ 6}, x ^ _]AllMatch[{{1, 2, 3}, {4, 5, 6}}, _Integer, 2]AllMatch[{{a, 2, c}, {4, e, 6}}, _Integer, 2]使用 AllMatch 的运算符形式:
AllMatch[_Integer][{1, 2, 3, 4, 5}]AllMatch[<|"a" -> 1, "b" -> 2, "c" -> 3|>, _Integer]范围 (4)
AllMatch 可以应用于具有任何头部的表达式:
AllMatch[f[1, 2, 3], _Integer]AllMatch 可以对不规则表达式进行操作:
AllMatch[{{1, 2, 3}, {4, 5}}, _Integer, 2]AllMatch[f[{1, 2, 3}, {4, 5}], _Integer, 2]默认情况下,AllMatch 在第 1 层运行:
AllMatch[4, _String]AllMatch[{}, _String]AllMatch[4, _String, 0]使用 Verbatim 测试文字空白:
AllMatch[f[_, _, _], Verbatim[_]]属性和关系 (6)
AllMatch[list,form] 等价于 NoneMatch[list,Except[form]]:
{AllMatch[{1, 2, 3, 4, 5}, _Integer], NoneMatch[{1, 2, 3, 4, 5}, Except[_Integer]]}AllMatch[list,form] 有效地处理稀疏向量:
AllMatch[SparseArray[{1000 -> 2}, {1000000000000}], _Integer]AllMatch[list,form] 按顺序检查 list 的各个部分,一旦不匹配 form 即立即停止:
AllMatch[{1, 2, 3, 4, 5}, _ ? (OddQ @* Echo)]AllMatch[list,form] 等价于 AllTrue[list,MatchQ[form]]:
{AllMatch[{1, 2, 3, 4, 5}, _Integer], AllTrue[{1, 2, 3, 4, 5}, MatchQ[_Integer]]}AllMatch[{e1,e2,…},form] 等价于 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|…] 等价于 ContainsOnly[list,{e1,e2,…}]:
{AllMatch[{a, a, b, a, b}, a | b], ContainsOnly[{a, a, b, a, b}, {a, b}]}可能存在的问题 (1)
对于关联,AllMatch 仅测试值:
AllMatch[<|a -> 1|>, 1]AllMatch[<|a -> 1|>, a]文本
Wolfram Research (2024),AllMatch,Wolfram 语言函数,https://reference.wolfram.com/language/ref/AllMatch.html.
CMS
Wolfram 语言. 2024. "AllMatch." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/AllMatch.html.
APA
Wolfram 语言. (2024). AllMatch. Wolfram 语言与系统参考资料中心. 追溯自 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: 04-September-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: 04-September-2026]}