Re: Delete elements from list..
- To: mathgroup at smc.vnet.net
- Subject: [mg117027] Re: Delete elements from list..
- From: Peter Pein <petsie at dordos.net>
- Date: Tue, 8 Mar 2011 05:34:11 -0500 (EST)
- References: <ijv047$68v$1@smc.vnet.net> <ik00i6$e6k$1@smc.vnet.net> <il2dau$66o$1@smc.vnet.net>
Am 07.03.2011 11:51, schrieb BoLe: > On Feb 22, 10:44 am, Ray Koopman<koop... at sfu.ca> wrote: >> >> Union@FoldList[Max,First@mylist,Rest@list] >> > > Wov, that is elegant to me, and fast. DeleteDuplicates speeds it a > tiny bit up. ;-) Since Union sorts the result (already sorted in this > case) or does it do something else too? > DeleteDuplicates is much slower here: In[9]:= mysecondlist=RandomInteger[{0,99},{2000}]; In[10]:= Timing[Do[u1=Union@FoldList[Max,First@mysecondlist,Rest@mysecondlist],{1000}];u1] Out[10]= {1.139,{79,98,99}} In[11]:= Timing[Do[u2=DeleteDuplicates[mysecondlist,#2<=#1&],{1000}];u2] Out[11]= {33.026,{79,98,99}} Peter P.S.: This computer has been slowed down due to thermal problems.