Re: Bug in ReplaceAll and ReplaceRepeated?
- To: mathgroup at smc.vnet.net
- Subject: [mg44028] Re: Bug in ReplaceAll and ReplaceRepeated?
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Sat, 18 Oct 2003 03:12:21 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <bmoe32$htd$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
Hi, have you ever considered to read the manual ? "A list of rules can be given. The rules are tried in order. The result of the first one that applies is returned. ..." The (a_ + b_)^c_ :> Expand[(a + b)^c] matches first because the pattern matcher works from outer to inner expressions, and so the Z->2 rule is never applied, because the second rule matches always first. Regards Jens Artþras Acus wrote: > > Hi, > > Sqrt[(X + Y + Z)^2] //. {Z -> 2, (a_ + b_)^c_ :> Expand[(a + b)^c]} > > don't replace Z with 2. If I remove c in right hand side of second rule, > works as expected. > > is the following behaviour bug or the feature? > In applies both to 4.1, and 5.0.