Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #9570 > unrolled thread
| Started by | Brentt <brenttnewman@gmail.com> |
|---|---|
| First post | 2012-04-11 22:26 +0000 |
| Last post | 2012-04-12 08:46 +0000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Deleting expressions containing a certain head Brentt <brenttnewman@gmail.com> - 2012-04-11 22:26 +0000
Re: Deleting expressions containing a certain head A Retey <awnl@gmx-topmail.de> - 2012-04-12 08:44 +0000
Re: Deleting expressions containing a certain head Ray Koopman <koopman@sfu.ca> - 2012-04-12 08:46 +0000
| From | Brentt <brenttnewman@gmail.com> |
|---|---|
| Date | 2012-04-11 22:26 +0000 |
| Subject | Deleting expressions containing a certain head |
| Message-ID | <jm50e9$2q0$1@smc.vnet.net> |
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] | [next] | [standalone]
| From | A Retey <awnl@gmx-topmail.de> |
|---|---|
| Date | 2012-04-12 08:44 +0000 |
| Message-ID | <jm64m5$6lt$1@smc.vnet.net> |
| In reply to | #9570 |
Am 12.04.2012 00:26, schrieb Brentt:
> 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?
>
list = {2^(Complex[2, 3]) + 3, 2, 3 x};
Select[list, FreeQ[#, Complex] &]
hth,
albert
[toc] | [prev] | [next] | [standalone]
| From | Ray Koopman <koopman@sfu.ca> |
|---|---|
| Date | 2012-04-12 08:46 +0000 |
| Message-ID | <jm64p1$6mm$1@smc.vnet.net> |
| In reply to | #9570 |
On Apr 11, 3:26 pm, Brentt <brenttnew...@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?
Cases[{2^(Complex[2,3])+3 , 2 , 3x }, _?(FreeQ[#,Complex]&)]
{2, 3 x}
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web