Re: DeleteCases

• To: mathgroup at smc.vnet.net
• Subject: [mg98167] Re: [mg98144] DeleteCases
• From: Fred Simons <f.h.simons at tue.nl>
• Date: Wed, 1 Apr 2009 05:56:04 -0500 (EST)
• References: <200903310919.EAA03943@smc.vnet.net>

```Filippo Miatto wrote:
> Dear all,
> Given this example list:
>
> {{0, 0, 1, 1}, {0, 0, 2, 2}, {0, 0, 3, 3}, {1, 1, 0, 0}, {1, 1, 2, 2},
> {1, 1, 3, 3}, {2, 2, 0, 0}, {2, 2, 1, 1}, {2, 2, 3, 3}, {3, 3, 0, 0},
> {3, 3, 1, 1}, {3, 3, 2, 2}}
>
> I need the elements {a,a,b,b} and {b,b,a,a} to be the same, i.e. i
> want to delete one of the two occurrences from the list. (or all but
> one if the condition is more complicated, say {a,b,c,d} and {b,a,c,d}
> or {a,b,c,d} and {a,b,d,c})
> How can i do that? Can i use DeleteCases? if so, what conditional
> should I use to compare different elements in the list?
> I tried without success for all the night.. (it's 6.15AM now!)
> Thank you,
>
> Filippo
>
>
>
Filippo,

If I understand you right, you want to take only one occurence ot those
elements from your list having the same union. That can be done as follows:

In[1]:=
lst={{0,0,1,1},{0,0,2,2},{0,0,3,3},{1,1,0,0},{1,1,2,2},{1,1,3,3},{2,2,0,0},{2,2,1,1},{2,2,3,3},{3,3,0,0},{3,3,1,1},{3,3,2,2}};

In[3]:= GatherBy[lst, Union][[All,1]]
Out[3]= {{0,0,1,1},{0,0,2,2},{0,0,3,3},{1,1,2,2},{1,1,3,3},{2,2,3,3}}

Regards,

Fred Simons
Eindhoven University of Technology

```

• Prev by Date: Re: DeleteCases
• Next by Date: Re: DeleteCases
• Previous by thread: Re: DeleteCases
• Next by thread: Re: DeleteCases