Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2003
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*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 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.


  • 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?