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.

Details

  • Tally[list] lists distinct elements in the order they appear in list.
  • Tally[list] is equivalent to Tally[list,SameQ].

Examples

open all close all

Basic Examples  (2)

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]=

Scope  (3)

Applications  (1)

Properties & Relations  (3)

Introduced in 2007
(6.0)