MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Pattern Matching Question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg116738] Re: Pattern Matching Question
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Fri, 25 Feb 2011 06:37:36 -0500 (EST)

rule = x^_?AtomQ -> newform;

x^y /. rule

newform

x^(y + z) /. rule

x^(y + z)

x^(y*z) /. rule

x^(y*z)


Bob Hanlon

---- Just A Stranger <forpeopleidontknow at gmail.com> wrote: 

=============
I'm new to pattern matching, and am stuck on a seemingly simple probem:

If I want to transform a pattern like

(I)  Power[x,_]   i.e. x^_

but NOT

(II) Power[x,Plus[_,_]]   i.e. x^(_+_)

How would I go about making that rule?

x^_ -> NewForm

Applies the rule to (II), which I don't want.

Thank you for your help :)




  • Prev by Date: Re: Pattern Matching Question
  • Next by Date: Re: Simplification of equations
  • Previous by thread: Re: Pattern Matching Question
  • Next by thread: Re: Pattern Matching Question