Re: Help with Delete cases

*To*: mathgroup at smc.vnet.net*Subject*: [mg116242] Re: Help with Delete cases*From*: Bob Hanlon <hanlonr at cox.net>*Date*: Tue, 8 Feb 2011 05:05:34 -0500 (EST)

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 at 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?