# commonest -- the most common elements of a list or tally

## Synopsis

• Usage:
commonest A
• Inputs:
• A,
• Outputs:
• L, a list, a list of the elements of A with the most repetitions

## Description

If a single element is the most common, a list of length one is the output.

 ```i1 : commonest {a,a,a,a,b,b,b,c,c,d,e} o1 = {a} o1 : List```

In the case of a tie, all commonest elements are returned.

 ```i2 : A = {a,a,a,a,b,b,b,b,c,c,c,c,d,e}; commonest A o3 = {c, a, b} o3 : List```

commonest works on Tallys and Sets as well.

 ```i4 : T = tally A o4 = Tally{a => 4} b => 4 c => 4 d => 1 e => 1 o4 : Tally``` ```i5 : commonest T o5 = {c, a, b} o5 : List``` ```i6 : S = set A o6 = set {a, b, c, d, e} o6 : Set``` ```i7 : commonest S o7 = {c, d, e, a, b} o7 : List```

(Since every element of a set is unique, it is unclear why one would need commonest(Set).)

## See also

• number -- count how many elements of a list satisfy a condition
• same -- whether everything in a list is the same
• set -- make a set
• tally -- tally the elements of a list or sequence
• unique -- eliminate duplicates from a list
• lists and sequences -- a detailed overview of lists and sequences in Macaulay2

## Ways to use commonest :

• commonest(Set)
• commonest(Tally)
• commonest(VisibleList)