Tally[list]
tallies the elements in list, listing all distinct elements together with their multiplicities.
Tally[list,test]
uses test to determine whether pairs of elements should be considered equivalent, and gives a list of the first representatives of each equivalence class, together with their multiplicities.
Tally
Tally[list]
tallies the elements in list, listing all distinct elements together with their multiplicities.
Tally[list,test]
uses test to determine whether pairs of elements should be considered equivalent, and gives a list of the first representatives of each equivalence class, together with their multiplicities.
Examples
open all close allBasic Examples (2)
Scope (3)
Results are returned in order of first occurrence in the list:
Tally[{b, a, b, a, c, b, a}]Count the instances of randomly generated integers:
Tally[RandomInteger[10, 50]]Elements of the list can be any expression:
Tally[{{a, b}, {w, x, y, z}, E, {w, x, y, z}, E}]Applications (1)
Properties & Relations (5)
Elements with highest frequencies are given by Commonest:
Tally[{b, a, c, b, a, c, b, a}]Commonest[{b, a, c, b, a, c, b, a}]A sorted Tally is equivalent to a list of counts for the Union:
Sort[Tally[{b, a, c, b, a, c, b, a}]]Map[{#, Count[{b, a, c, b, a, c, b, a}, #]}&, Union[{b, a, c, b, a, c, b, a}]]Tally is a discrete analog of BinCounts:
data = RandomReal[10, 20]Tally[Ceiling[data]]//SortBinCounts[data, {0, 10}]Counts[list] returns an association in which values are the tallies of their keys:
Counts[{b, a, c, b, a, c, b, a}]Tally[{b, a, c, b, a, c, b, a}]Use the second argument of Tally to construct its corresponding by-function:
tallyBy[list_, f_] := Tally[list, f[#1] === f[#2]&]Count odd and even numbers in a list:
tallyBy[{1, 2, 3, 2, 1, 1}, EvenQ]Related Guides
History
Text
Wolfram Research (2007), Tally, Wolfram Language function, https://reference.wolfram.com/language/ref/Tally.html.
CMS
Wolfram Language. 2007. "Tally." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Tally.html.
APA
Wolfram Language. (2007). Tally. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Tally.html
BibTeX
@misc{reference.wolfram_2026_tally, author="Wolfram Research", title="{Tally}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/Tally.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_tally, organization={Wolfram Research}, title={Tally}, year={2007}, url={https://reference.wolfram.com/language/ref/Tally.html}, note=[Accessed: 13-June-2026]}