2
$\begingroup$

We want to delete redundant elements of a list, we consider that the tuples {a,b} and {b,a} are equivalent.

Input : {{1, 2}, {2, 1}, {1, 3}, {3, 1}, {2, 1}, {2, 1}, {1, 4}}

Desired Output : {{1,2},{1,3},{1,4}}

$\endgroup$
0
8
$\begingroup$
DeleteDuplicatesBy[Sort] @ {{1, 2}, {2, 1}, {1, 3}, {3, 1}, {2, 1}, {2, 1}, {1, 4}}
 {{1, 2}, {1, 3}, {1, 4}}
DeleteDuplicates[{{1, 2}, {2, 1}, {1, 3}, {3, 1}, {2, 1}, {2, 1}, {1,  4}}, 
   Sort @ # == Sort @ #2 &]
 {{1, 2}, {1, 3}, {1, 4}}
$\endgroup$
3
$\begingroup$
alist = {{1, 2}, {2, 1}, {1, 3}, {3, 1}, {2, 1}, {2, 1}, {1, 4}}

Union@(Sort /@ alist)

{{1, 2}, {1, 3}, {1, 4}}

$\endgroup$

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