Re: List-Operations on Heads other than List
- To: mathgroup at smc.vnet.net
- Subject: [mg29739] Re: List-Operations on Heads other than List
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Fri, 6 Jul 2001 03:24:34 -0400 (EDT)
- References: <9i068k$h0i$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
"Detlef Mueller" <dmueller at mathematik.uni-kassel.de> wrote in message news:9i068k$h0i$1 at smc.vnet.net... > Hello, > > The Help Browser says: > > Select[list, crit] picks out all elements ... > > Now this works fin for other Haeders thal List > too. > > Select[Expand[P], ! NumberQ[#] &] removes the > absolute Part of the Poynomial P > (in my Version). > > Is this a dangerous Way of Programming? > > Greetings > Detlef This is fine as long as 1) the expanded polynomial has more than one term 2) the absolute part is a number. Re 1) x+3 has full form Plus[x,3] and so is the same shape as {x,3} (which has full form List[x,3] But x and 3 are not of this form. Re 2) If the polynomial is in the variables x we could use Select[Expand[P], ! FreeQ[#,x] &] but we still run into the problem 1); and we have to use Alternatives[x,y, ...] in place of x for a polynomial in variables x,y, ... One way out of both 1) and 2) is . Select[Expand[P]+Unique[], ! FreeQ[#, Alternatives[x,y...]] &] Another way is (# - #/. {x->0,y->0, ...})&P For dealing with many variables note that Thread[{x,y,...}->0] gives {x->0, y->0, ...} -- Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565