Re: Deleting duplicates from a list
- To: mathgroup at smc.vnet.net
- Subject: [mg76000] Re: [mg75940] Deleting duplicates from a list
- From: Adriano Pascoletti <adriano.pascoletti at dimi.uniud.it>
- Date: Mon, 14 May 2007 05:48:32 -0400 (EDT)
- References: <200705140725.DAA22641@smc.vnet.net>
This is the unsorted union problem, which can be efficiently solved
using Sow and Reap (see Help Browser > Reap > Further Examples)
In[8]:=UnsortedUnion[x_] := Reap[Sow[1, x], _, #1 & ][[2]]
In[9]:=UnsortedUnion[{8, 8, 11, 11, 19}]
Out[9]={8, 11, 19}
Adriano Pascoletti
On 14 mag 2007, at 09:25, Raul Martinez wrote:
> Hi all,
>
> I have a list, e.g., {8, 8, 11, 11, 19}. I want to eliminate all
> duplicates so the list becomes {8, 11, 19}. Can anyone suggest a
> command that will do this?
>
> TIA,
>
> Raul Martinez
>
- Follow-Ups:
- Re: Re: Deleting duplicates from a list
- From: Murray Eisenberg <murray@math.umass.edu>
- Re: Re: Deleting duplicates from a list
- References:
- Deleting duplicates from a list
- From: Raul Martinez <raulmart@mac.com>
- Deleting duplicates from a list