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


Groups > comp.soft-sys.math.mathematica > #9618 > unrolled thread

Re: Deleting expressions containing a certain head

Started byBob Hanlon <hanlonr357@gmail.com>
First post2012-04-13 08:45 +0000
Last post2012-04-13 08:45 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Deleting expressions containing a certain head Bob Hanlon <hanlonr357@gmail.com> - 2012-04-13 08:45 +0000

#9618 — Re: Deleting expressions containing a certain head

FromBob Hanlon <hanlonr357@gmail.com>
Date2012-04-13 08:45 +0000
SubjectRe: Deleting expressions containing a certain head
Message-ID<jm8p2h$imf$1@smc.vnet.net>
expr = {2^(Complex[2, 3]) + 3, 2, 3 x};

Select[expr, FreeQ[#, Complex] &]

{2, 3 x}

Cases[expr, _?(FreeQ[#, Complex] &)]

{2, 3 x}

DeleteCases[expr, _?(Not[FreeQ[#, Complex]] &)]

{2, 3 x}


Bob Hanlon


On Wed, Apr 11, 2012 at 6:22 PM, Brentt <brenttnewman@gmail.com> wrote:
> Hello, I have a list of expressions, and I am trying to use DeleteCases to
> delete expressions in the list which contain a certain head *anywhere* in
> the expression. Setting the levelspec for DeleteCases to Infinity almost
> works, except I want to delete the entire expression containing the head
> from the list as opposed to just the head itself while leaving the rest of
> the expression in the list.
>
> e.g.
> I want this
> DeleteCases[{2^(Complex[2,3])+3 , 2 ,3x }, Complex[_,_], Infinity ]
>
> to output this
> {2,3x}
> Getting rid of any expression that has a complex number in it.
>
>  How does one go about this?
>

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web