Re: Positions of Polynomials in expr?
- To: mathgroup at smc.vnet.net
- Subject: [mg109368] Re: Positions of Polynomials in expr?
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Fri, 23 Apr 2010 03:50:39 -0400 (EDT)
Any condition can be made a pattern expr = {E^x, x, x^2, Log[x]}; Position[expr, _?(! PolynomialQ[#, x] &), 1] {{1}, {4}} Bob Hanlon ---- Jack L Goldberg 1 <jackgold at umich.edu> wrote: ============= Hi Folks, "Select" and "Cases" are commands that do essentially the same thing, namely, pick out elements of a list which, in the first case matches a criterion, in the second case, matches a pattern. I call these parallel commands. Is there a command parallel to "Position" which uses criterion rather than pattern matching? If no such parallel function exists, can one easily construct one? I actually have a special case in mind. I want to find the position of all parts of expr which fail the test PolynomialQ[f_,x]. Naively, I thought one might Map Polynomial[#,x]& to all levels of expr and then find the positions of "False". I haven't tried it because I'm betting someone knows how to do this neatly and I do not like to re-invent the wheel. When I do so, the wheel tends to be more like an oval than a circle. Thanks! Jack