MathGroup Archive 2007

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

Search the Archive

Re: ReplaceAll behavour

  • To: mathgroup at
  • Subject: [mg82161] Re: ReplaceAll behavour
  • From: Bill Rowe <readnewsciv at>
  • Date: Sat, 13 Oct 2007 04:00:09 -0400 (EDT)

On 10/12/07 at 2:59 AM, maderri2 at (magma) wrote:

>I do not understand what Mathematica 6 is doing here:


>gives 3


>a+2/. a->3

>gives 7

>Why is that?

What is happening in each case is evaluation occurs before replacement.

=46or a/.a-> evaluation causes this to become

5/.5->3 then the replacement occurs to give the result 3.

=46or a+2/.a->3 evaluation gives


Arithmetic operators such as + or - have higher precedence than
patter replacement. So, this becomes
7/.5->3. And finally since there is no 5 to replace, the result
is 7.

You can easily verify this is the way things work by looking at
the output from

Trace[a/.a->3] and
To reply via email subtract one hundred and four

  • Prev by Date: Locator in Manipulate's graphic.
  • Next by Date: Re: import function
  • Previous by thread: Re: ReplaceAll behavour
  • Next by thread: Re: ReplaceAll behavour