Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #15700

Re: Help with Delete cases

From KenR <ramsey2879@msn.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Help with Delete cases
Date 2011-02-09 07:10 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <iitekg$jiv$1@smc.vnet.net> (permalink)
References <iir4h6$6kh$1@smc.vnet.net>

Show all headers | View raw


On Feb 8, 5:05 am, Bob Hanlon <hanl...@cox.net> wrote:
> list = Range[3003];
>
> sol1 = With[{m = 5, p = 7},
>    DeleteCases[list, _?(Mod[# - m (m + 1)/2, p] == 0 &)]];
>
> sol2 = With[{m = 5, p = 7},
>    Cases[list, Except[_?(Mod[# - m (m + 1)/2, p] == 0 &)]]];
>
> sol3 = With[{m = 5, p = 7},
>    Cases[list, _?(Mod[# - m (m + 1)/2, p] != 0 &)]];
>
> sol4 = With[{m = 5, p = 7},
>    Select[list, Mod[# - m (m + 1)/2, p] != 0 &]];
>
> sol5 = With[{m = 5, p = 7},
>    list //. _?(Mod[# - m (m + 1)/2, p] == 0 &) :> Sequence[]];
>
> sol1 == sol2 == sol3 == sol4 == sol5
>
> True
>
> 3003 - Length[sol1]
>
> 429
>
> Bob Hanlon
>
> ---- KenR <ramsey2...@msn.com> wrote:
>
> =============
> I have a list= Range[3003]  I want todeletecasesof n = m(m+1) mod P
> from the list, butDeletecasesonly deletescasesmatching a pattern,
> i.e.
>
> list = DeleteCases[list,Mod[N - m(m+1)/2,P] = 0] will definitely not
> work.  I want to keep list, as the same identifier, throughout since
> this is within a looping process. Any suggestions?

I read all of the responses to my post and greatly appreciate the many
ideas that were provided to me for adding a logical test to the
DeleteCases function. I think I have more than enough to complete my
task thanks to all that posted. Bob Hanlon's post was right on and
Sjoerd C. de Vries and others gave me a name for the Select  _?  and /
functions so I could look up more documentation which I did not find
under DeleteCases or Cases.  Thanks to all that posted.  I am
definitely glad that I joined this group. In a few days I will receive
a few books on Mathematica and hope my posts will be less demanding or
vague in their nature.

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Help with Delete cases KenR <ramsey2879@msn.com> - 2011-02-09 07:10 +0000

csiph-web