next | previous | forward | backward | up | top | index | toc | home
Macaulay2 > The Macaulay2 language > lists and sequences > unique

unique -- eliminate duplicates from a list

Description

unique v yields the elements of the list v, without duplicates.

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
The order of elements is maintained. For something that might be slightly faster, but doesn't maintain the order of the elements, and may different answers, try making a set and then getting its elements.
i2 : toList set {3,2,1,3,2,4,a,3,2,3,-2,1,2,4}

o2 = {1, 2, 3, 4, a, -2}

o2 : List

See also

Ways to use unique :