deletes all duplicates from list.
applies test to pairs of elements to determine whether they should be considered duplicates.
- DeleteDuplicates[list] deletes all but the first occurrence of each distinct element that appears in list.
- DeleteDuplicates also works on associations, removing entries whose values duplicate those earlier in the association.
- DeleteDuplicates never reorders elements, but only removes them.
- DeleteDuplicates[list] is equivalent to DeleteDuplicates[list,SameQ].
Examplesopen allclose all
Basic Examples (2)
Properties & Relations (2)
DeleteDuplicates is similar to Union without sorting:
Avoiding the sort improves the speed substantially:
Delete sublists that have the same total:
DeleteDuplicatesBy can be used to achieve the same result:
Wolfram Research (2008), DeleteDuplicates, Wolfram Language function, https://reference.wolfram.com/language/ref/DeleteDuplicates.html (updated 2014).
Wolfram Language. 2008. "DeleteDuplicates." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/DeleteDuplicates.html.
Wolfram Language. (2008). DeleteDuplicates. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DeleteDuplicates.html