Counts
Counts[list]
gives an association whose keys are the distinct elements of list, and whose values give the number of times those elements appear in list.
Counts[list,elems]
gives an association whose keys are the distinct elements in elems, and whose values give the number of times those elements appear in list.
Examples
open allclose allBasic Examples (2)
Scope (1)
Properties & Relations (5)
Counts[list] lists elements by the order in which the first appear in list:
Counts[list,elems] lists elements by the order in which the first appear in elems:
Counts[list,elems] will contain totals for all elements in elems, even if they do not appear in list:
CountsBy[list,f] is effectively Counts[Map[f,list]]:
Counts examines literal values:
Count tallies elements matching a pattern:
Text
Wolfram Research (2014), Counts, Wolfram Language function, https://reference.wolfram.com/language/ref/Counts.html (updated 2025).
CMS
Wolfram Language. 2014. "Counts." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/Counts.html.
APA
Wolfram Language. (2014). Counts. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Counts.html