Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2003

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

Search the Archive

Re: Bug in ReplaceAll and ReplaceRepeated?

  • To: mathgroup at
  • Subject: [mg44028] Re: Bug in ReplaceAll and ReplaceRepeated?
  • From: Jens-Peer Kuska <kuska at>
  • Date: Sat, 18 Oct 2003 03:12:21 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <bmoe32$htd$>
  • Reply-to: kuska at
  • Sender: owner-wri-mathgroup at


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.


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.

  • Prev by Date: Re: Running The Combinatorica GraphEditor
  • Next by Date: recode procedural algorithm to faster functional module
  • Previous by thread: Bug in ReplaceAll and ReplaceRepeated?
  • Next by thread: Re: Bug in ReplaceAll and ReplaceRepeated?