Re: Q: DeleteCases
- To: mathgroup at smc.vnet.net
- Subject: [mg27922] Re: [mg27862] Q: DeleteCases
- From: Tomas Garza <tgarza01 at prodigy.net.mx>
- Date: Fri, 23 Mar 2001 04:32:01 -0500 (EST)
- References: <200103220930.EAA08448@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
The pattern must use a condition: In[1]:= DeleteCases[t, x_ /; x > 2] Out[2]= {1,2} But in this kind of problem I think Select performs slightly better: In[3]:= t = Table[Random[Integer, {0, 9}], {500000}]; In[4]:= DeleteCases[t, x_ /; x > 2]; // Timing Out[4]= {3.9 Second, Null} In[5]:= Select[t, # <= 2 &]; // Timing Out[5]= {2.47 Second, Null} But, then, this is even better In[6]:= Cases[t - 2, x_ /; PositiveQ[x]]; // Timing Out[6]= {2.09 Second, Null} Tomas Garza Mexico City ----- Original Message ----- From: "Robert Schuerhuber" <robert.schuerhuber at gmx.at> To: mathgroup at smc.vnet.net Subject: [mg27922] [mg27862] Q: DeleteCases > hi! > i've a rather simple question with the deletecases, but unfortunately i > couldn't find a clue in the mathematica-help (again ..): > > i want to to use DeleteCases to remove number of lists, which are > greater than a given limit, eg. > > t={1,2,3,4} > DeleteCases[t, ????] > > should remove all entries greater than 2, therefore > > t={1,2} > > which pattern do i have to use? > > regards, robert > >
- References:
- Q: DeleteCases
- From: Robert Schuerhuber <robert.schuerhuber@gmx.at>
- Q: DeleteCases