MathGroup Archive 2011

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

Search the Archive

Re: Just another Mathematica "Gotcha"

  • To: mathgroup at smc.vnet.net
  • Subject: [mg120832] Re: Just another Mathematica "Gotcha"
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Fri, 12 Aug 2011 05:04:50 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201108110912.FAA07274@smc.vnet.net>
  • Reply-to: drmajorbob at yahoo.com

That's not what operator precedence means, at all.

Put the original expression:

Series[a + (b1 + b2) x, {x, 0, 1}] // Normal /. {b2 -> 0}

into Mathematica and

1) triple-click on /. and watch the selection become Normal /. {b -> 0}.  
(If you quadruple-click, you get the entire statement.)

2) triple-click on // and the selection expands to the whole statement.

Hence, /. binds its arguments (Normal and the replacement rule) first,  
then // binds its arguments (Series and Normal).

Bobby

On Thu, 11 Aug 2011 04:12:41 -0500, Glenn Carlson <g.crlsn at gmail.com>  
wrote:

> It seems not simply a matter of operator precedence since [7] evaluates  
> to neither [3] nor [6].
>
> In[1]:= Series[a + (b1 + b2) x, {x, 0, 1}];
> % // Normal;
> % /. {b2 -> 0}
>
> Out[3]:= a+b1 x
>
> In[4]:= Series[a + (b1 + b2) x, {x, 0, 1}];
> % /. {b2 -> 0};
> % // Normal
>
> Out[6]:= a+b1 x
>
> In[7]:= Series[a + (b1 + b2) x, {x, 0, 1}] // Normal /. {b2 -> 0}
>
> Out[7]:= a + (b1+b2) x
>


-- 
DrMajorBob at yahoo.com




  • Prev by Date: Re: FunctionInterpolation and NIntegrate
  • Next by Date: Re: Memory leak or flawed garbage collector
  • Previous by thread: Re: Just another Mathematica "Gotcha"
  • Next by thread: Re: Just another Mathematica "Gotcha"