[Date Index] [Thread Index] [Author Index]
Re: Collecting Positive and Negative Terms
On Sep 7, 9:59 pm, Michael Knudsen <micknud... at gmail.com> wrote: > On Aug 14, 12:32 pm, Bob Hanlon <hanl... at cox.net> wrote: > >> myExpression = a + b - c; >> >> DeleteCases[myExpression, Times[-1, ___]] >> >> a+b > > Dammit! I was a little too fast with my reply. For some reason, it > fails when I apply to one of my big expressions. Both postive and > negative terms survive then. > > Here is an example of when it goes wrong: > > http://commondatastorage.googleapis.com/michael_knudsen_various/SplitExpression.nb > > -- > Michael Knudsen Try Cases[myExpression,Times[_?Negative,__]] and DeleteCases[myExpression,Times[_?Negative,__]] .