AnyMatch
范例
打开所有单元 关闭所有单元基本范例 (4)
AnyMatch[{x ^ 2, y ^ 3, x ^ 5, x ^ 6}, y ^ _]AnyMatch[{a, b, b, a, a, a}, _Integer]AnyMatch[{{a, 1, c}, {2, e, 3}}, _Integer, 2]AnyMatch[{{a, b, c}, {d, e, f}}, _Integer, 2]使用 AnyMatch 的运算符形式:
AnyMatch[_Integer][{1, 1, f[a], 2, 3, y, f[8], 9, f[10]}]AnyMatch[<|"a" -> 1, "b" -> b, "c" -> 3|>, _Symbol]范围 (4)
AnyMatch 可以应用于具有任何头部的表达式:
AnyMatch[f[a, 1, b], _Integer]AnyMatch 可以对不规则表达式进行操作:
AnyMatch[{{a, 1, c}, {2, e}}, _Integer, 2]AnyMatch[f[{a, 1, c}, {2, e}], _Integer, 2]默认情况下,AnyMatch 在第 1 层运行:
AnyMatch[4, _Integer]AnyMatch[{}, _Integer]AnyMatch[4, _Integer, 0]使用 Verbatim 测试文字空白:
AnyMatch[f[a, _, c], Verbatim[_]]属性和关系 (6)
AnyMatch[list,form] 等价于 !NoneMatch[list,form]:
{AnyMatch[{a, 1, c, 2, e}, _Integer], !NoneMatch[{a, 1, c, 2, e}, _Integer]}AnyMatch[list,form] 有效地处理稀疏向量:
AnyMatch[SparseArray[{1000 -> a}, {1000000000000}], _Symbol]//EchoTimingAnyMatch[list,form] 按顺序检查 list 的各个部分,一旦匹配 form 即立即停止:
AnyMatch[{1, 2, 3, 4, 5}, _ ? (EvenQ @* Echo)]AnyMatch[list,form] 等价于 AnyTrue[list,MatchQ[form]]:
{AnyMatch[{1, 2, 3, 4, 5}, _Integer], AnyTrue[{1, 2, 3, 4, 5}, MatchQ[_Integer]]}AnyMatch[{e1,e2,…},form] 等价于 Or[MatchQ[e1,form],MatchQ[e2,form],…]:
{AnyMatch[{a, 1, b}, _Integer], MatchQ[a, _Integer] || MatchQ[1, _Integer] || MatchQ[b, _Integer]}AnyMatch[list,e1|e2|…] 等价于 ContainsAny[list,{e1,e2,…}]:
{AnyMatch[{a, a, b, c, a}, a | b], ContainsAny[{a, a, b, c, a}, {a, b}]}可能存在的问题 (1)
对于关联,AnyMatch 仅测试值:
AnyMatch[<|a -> 1|>, 1]AnyMatch[<|a -> 1|>, a]文本
Wolfram Research (2024),AnyMatch,Wolfram 语言函数,https://reference.wolfram.com/language/ref/AnyMatch.html.
CMS
Wolfram 语言. 2024. "AnyMatch." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/AnyMatch.html.
APA
Wolfram 语言. (2024). AnyMatch. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/AnyMatch.html 年
BibTeX
@misc{reference.wolfram_2026_anymatch, author="Wolfram Research", title="{AnyMatch}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/AnyMatch.html}", note=[Accessed: 13-August-2026]}
BibLaTeX
@online{reference.wolfram_2026_anymatch, organization={Wolfram Research}, title={AnyMatch}, year={2024}, url={https://reference.wolfram.com/language/ref/AnyMatch.html}, note=[Accessed: 13-August-2026]}