Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > Core Language > List Manipulation > Math & Counting Operations on Lists >
Mathematica > Data Manipulation > Handling Arrays of Data > Math & Counting Operations on Lists >

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.
  • Tally[list] lists distinct elements in the order they appear in list.
Obtain tallies for a list of symbols:
Use test argument to count expressions with the same Head:
Obtain tallies for a list of symbols:
In[1]:=
Click for copyable input
Out[1]=
 
Use test argument to count expressions with the same Head:
In[1]:=
Click for copyable input
Out[1]=
Results are returned in order of first occurrence in the list:
Count the instances of randomly generated integers:
Elements of the list can be any expression:
Count occurrences of characters in a string:
Elements with highest frequencies are given by Commonest:
A sorted Tally is equivalent to a list of counts for the Union:
Tally is a discrete analog of BinCounts:
New in 6
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team