Re: How to select unique elements in a list?
- To: mathgroup at smc.vnet.net
- Subject: [mg7987] Re: How to select unique elements in a list?
- From: crose at c2.telstra-mm.net.au (Colin Rose)
- Date: Wed, 30 Jul 1997 23:57:38 -0400
- Organization: Theoretical Research Institute
- Sender: owner-wri-mathgroup at wolfram.com
"Carl Woll" <carlw at u.washington.edu> wrote: > First, let me say that Union does not do what I'm looking for! I am > interested in a function which returns the unique elements from a list. > Let's call the function Distinct. Then, I want > > Distinct[{i1,i2,i3,i2}] to return {i1,i3} FOLLOWING UP on my previous post: a neater (and faster) solution is: ________________________________ Y[x_] := Cases[ Split[Sort[x]], {_}]//Flatten eg: In[] test=Table[ i[Random[Integer,1000]],{1000}]; Y[test]; // Timing Out[] {0.0333333 Second,Null} PowerMac 8600/200 Cheerio Colin -- Colin Rose tr(I) - Theoretical Research Institute ______________________________________ crose at c2.telstra-mm.net.au http://www.usyd.edu.au/su/tri/