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.
The object unique is a method function with a single argument.