1

I've got a table of tables: $A=\{\{a,b\},\{b,a\},...,\{a,b,c,d,e\},\{e,d,c,a,b\},...\}$. How do I do to remove backward duplicates, or more generally permutations of duplicates in the table?

For example in $A$ I want to erase one of $\{a,b\},\{b,a\}$, and $\{a,b,c,d,e\},\{e,d,c,a,b\}$. Which could be the shortest way to do that? I don't mind which is the erased element...

2 Answers2

4

Perhaps something as simple as

data = {{a, b}, {b, a}, {a, b, c, d, e}, {e, d, c, a, b}};
Union[Sort /@ data]
{{a, b}, {a, b, c, d, e}}
m_goldberg
  • 107,779
  • 16
  • 103
  • 257
0

Or this:

lst = {{a, b}, {b, a}, {a, b, c, d, e}, {e, d, c, a, b}};
DeleteDuplicates[Sort/@lst]
(* {{a, b}, {a, b, c, d, e}} *)
Mahdi
  • 1,619
  • 10
  • 23