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


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

Re: Help with Delete cases

From Bob Hanlon <hanlonr@cox.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Help with Delete cases
Date 2011-02-08 10:05 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <iir4h6$6kh$1@smc.vnet.net> (permalink)

Show all headers | View raw


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 <ramsey2879@msn.com> wrote: 

=============
I have a list= Range[3003]  I want to delete cases of n = m(m+1) mod P
from the list, but Delete cases only deletes cases matching 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?

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


Thread

Re: Help with Delete cases Bob Hanlon <hanlonr@cox.net> - 2011-02-08 10:05 +0000

csiph-web