Delete duplicates in a list, depending on the sequence of numbers
This should do the job:
DeleteDuplicates[list, SameQ[#1, #2] || SameQ[#1, Reverse@#2] &]
If your application allows for reversed elements to be interchangeable you can do this:
DeleteDuplicates[Sort[{#, Reverse@#}][[1]] & /@ list]
The advantage here is speed; this is perhaps two orders of magnitude faster on large sets than the methods already presented.
Update: in versions 10+, you can use DeleteDuplicatesBy
:
list = {{1, 2, 3}, {3, 2, 1}, {2, 1, 3}, {1, 2, 3}};
DeleteDuplicatesBy[list, Union[{#, Reverse@#}]&]
{{1, 2, 3}, {2, 1, 3}}
Original answer:
You can use your condition directly
DeleteDuplicates[list, (#1 == Reverse[#2] &)]
or use Union
with SameTest
Union[list, SameTest -> (#1 == Reverse[#2] &)]
Edit: For the new requirement, you need to Or
the conditions for "sameness" (as in @acl's answer)
DeleteDuplicates[list, (#1 == Reverse[#2] || #1 == #2 &)]
Union[list, SameTest -> (#1 == Reverse[#2] || #1 == #2&)]