Show duplicates in Mathematica
Posted
by Martin Janiczek
on Stack Overflow
See other posts from Stack Overflow
or by Martin Janiczek
Published on 2009-10-27T14:11:10Z
Indexed on
2010/04/17
15:13 UTC
Read the original article
Hit count: 336
In Mathematica I have a list:
x = {1,2,3,3,4,5,5,6}
How will I make a list with the duplicates? Like:
{3,5}
I have been looking at Lists as Sets, if there is something like Except[] for lists, so I could do:
unique = Union[x]
duplicates = MyExcept[x,unique]
(Of course, if the x would have more than two duplicates - say, {1,2,2,2,3,4,4}, there the output would be {2,2,4}, but additional Union[] would solve this.)
But there wasn't anything like that (if I did understand all the functions there well).
So, how to do that?
© Stack Overflow or respective owner