# unique -- eliminate duplicates from a list

## Synopsis

• Usage:
unique(L)
• Inputs:
• L, a list, or sequence
• Outputs:
• M, a list, the elements of L without duplicates

## Description

The output list maintains the order of elements in L.

 i1 : unique {3,2,1,3,2,4,a,3,2,3,-2,1,2,4} o1 = {3, 2, 1, 4, a, -2} o1 : List

Another way to list the unique elements of L is by creating a set from L and then listing its elements. This may be slightly faster than unique, but forgets the ordering of L.

 i2 : toList set {3,2,1,3,2,4,a,3,2,3,-2,1,2,4} o2 = {1, 2, 3, 4, -2, a} o2 : List

To count occurrences of each element, use tally. To create a sorted list, see sort. For an overview of lists and sequences, see lists and sequences.

• same -- whether everything in a list is the same
• sort -- sort a list or columns of a matrix
• set -- make a set
• tally -- tally the elements of a list, sequence, array, or string
• uniform -- whether all elements of a list are the same class
• lists and sequences -- a detailed overview of lists and sequences in Macaulay2

## Ways to use unique :

• "unique(Sequence)"
• "unique(VisibleList)"

## For the programmer

The object unique is .