Wolfram Research

Function Repository Resource:

DuplicatesList

Source Notebook

Give the elements that appear more than once in the input list

Contributed by: Wolfram Staff

ResourceFunction["DuplicatesList"][list]

gives those elements in list that appear more than once.

ResourceFunction["DuplicatesList"][list,test]

applies test to pairs of elements to determine if they should be considered identical.

Details and Options

The default function used to test whether elements are identical is SameQ.

Examples

Basic Examples

Find the duplicates in a list:

In[1]:=
ResourceFunction["DuplicatesList"][{x, y, x, z, y, w}]
Out[1]=

Properties and Relations

DuplicatesList[list] is equivalent to Map[First,DeleteCases[Gather[list],{_}]]:

In[2]:=
list = RandomInteger[20, 100];
In[3]:=
ResourceFunction["DuplicatesList"][list]
Out[3]=
In[4]:=
Map[First, DeleteCases[Gather[list], {_}]]
Out[4]=

Resource History

License Information