Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

How can I select the duplicate values in a list?

Example:

{1, 2, 1, 1, 1, 1}
share|improve this question

marked as duplicate by Öskå, Leonid Shifrin, m_goldberg, tkott, RunnyKine Jun 9 '14 at 16:22

This question was marked as an exact duplicate of an existing question.

    
I need to return the duplicate values. – Developer2000 Jun 9 '14 at 15:07
    
So in your example what do you need to return? – Öskå Jun 9 '14 at 15:08
    
I need to return {1} – Developer2000 Jun 9 '14 at 15:15
    
Have you even looked at the link above? It returns {1}. Please make an effort. – Öskå Jun 9 '14 at 15:17
    
@Öskå, I am so sorry! thanks – Developer2000 Jun 9 '14 at 15:20

If you want all duplicates then:

list = {1, 2, 1, 1, 1, 1}

Select[Split@Sort@list, Length@# > 1 &]

if you want one from each duplicate then

Select[Split@Sort@list, Length@# > 1 &][[;;,1]]
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.