Re: Unsorted Union
- To: mathgroup at smc.vnet.net
- Subject: [mg61564] Re: Unsorted Union
- From: "Bill White" <minutiae at gmail.com>
- Date: Sat, 22 Oct 2005 03:24:04 -0400 (EDT)
- References: <dj4p6t$gpt$1@smc.vnet.net><dj721s$cpb$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Other interesting things can be done with this memoizing scheme. For
example, it can be used to collect the duplicate elements in a list:
In[11]:=
DuplicateElements[list_List]:=
Module[{f,dups={}},
f[n_]:=(f[n]:=AppendTo[dups,n]);
f/@list;
dups];
In[12]:=
list=Table[Random[Integer,{1,10}],{10}]
Out[12]=
{3,10,7,10,2,2,6,9,6,9}
In[13]:=
DuplicateElements[list]
Out[13]=
{10,2,6,9}
Cheers -
bw
- Follow-Ups:
- Re: Re: Unsorted Union
- From: Adriano Pascoletti <pascolet@dimi.uniud.it>
- Re: Re: Unsorted Union
- From: ggroup@sarj.ca
- Re: Re: Unsorted Union