Counts
范例
打开所有单元 关闭所有单元基本范例 (2)
范围 (1)
属性和关系 (6)
Counts[list] 按元素在 list 中出现的先后顺序列出元素:
Counts[{c, a, c}]Counts[list,elems] 按元素在 elems 中出现的先后顺序列出元素:
Counts[{c, a, c}, {a, b, c}]即使这些元素没有出现在 list 中,Counts[list,elems] 也会包含 elems 中所有元素的总数:
Counts[{a, b, c}, {d, e}]CountsBy[list,f] 实际上就是 Counts[Map[f,list]]:
list = RandomInteger[{-1, 1}, 100];
CountsBy[list, Abs] === Counts[Map[Abs, list]]这里还要提到,CountsBy[list,Identity] 等价于 Counts[list]:
CountsBy[list, Identity] === Counts[list]Counts[expr] 等价于 GroupBy[expr,Identity,Length]:
Counts[{a, b, c, a}] == GroupBy[{a, b, c, a}, Identity, Length]Counts 检查字面数值:
list = {a, b, c, b, c, a, b};
Counts[list, {a, b, a | b}]Count 统计与模式匹配的元素:
Count[list, a | b]相关指南
-
▪
- 关联 ▪
- 计算结构化数据集 ▪
- 列表中的数学和统计运算 ▪
- 数据集上的类数据库操作 ▪
- 列表操作 ▪
- 科学数据分析 ▪
- 语言数据 ▪
- 大型数组的处理
相关链接
文本
Wolfram Research (2014),Counts,Wolfram 语言函数,https://reference.wolfram.com/language/ref/Counts.html (更新于 2025 年).
CMS
Wolfram 语言. 2014. "Counts." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2025. https://reference.wolfram.com/language/ref/Counts.html.
APA
Wolfram 语言. (2014). Counts. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/Counts.html 年
BibTeX
@misc{reference.wolfram_2026_counts, author="Wolfram Research", title="{Counts}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/Counts.html}", note=[Accessed: 12-October-2026]}
BibLaTeX
@online{reference.wolfram_2026_counts, organization={Wolfram Research}, title={Counts}, year={2025}, url={https://reference.wolfram.com/language/ref/Counts.html}, note=[Accessed: 12-October-2026]}