|
[Date Index]
[Thread Index]
[Author Index]
Re: ReplaceAll behavour
- To: mathgroup at smc.vnet.net
- Subject: [mg82161] Re: ReplaceAll behavour
- From: Bill Rowe <readnewsciv at sbcglobal.net>
- Date: Sat, 13 Oct 2007 04:00:09 -0400 (EDT)
On 10/12/07 at 2:59 AM, maderri2 at gmail.com (magma) wrote:
>I do not understand what Mathematica 6 is doing here:
>a=5
>a/.a->3
>gives 3
>But...
>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
5+2/.5->3
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
Trace[a+2/.a->3]
--
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
|