I have a list of integer, and I want to know if the list contains any duplicates. My code is working, but I feel there is a more straightforward way of doing this
list1 = Range[10];
list2 = {1,2,3,4,1,6};
DoublesQ[list_] := Count[Tally[list], {_,n_} /; n >1 ] == 0]
DoublesQ[list1]
=> True
DoublesQ[list2]
=> False
EDIT: So appears that Mathematica 10 has a function for that. I guess that now my question is: how can I do that without the build-in function?
Length@Union@list1==Length@list1
for xample $\endgroup$DuplicateFreeQ
. $\endgroup$