Re: Just another Mathematica "Gotcha"

• To: mathgroup at smc.vnet.net
• Subject: [mg120833] Re: Just another Mathematica "Gotcha"
• From: David Bailey <dave at removedbailey.co.uk>
• Date: Fri, 12 Aug 2011 05:05:02 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• References: <j2069b\$6vn\$1@smc.vnet.net>

```On 11/08/2011 10:10, Glenn Carlson wrote:
> Yes, I think it's a matter of precedence.  For example,
>
> In[1]:= Normal /. b2 ->  0
> Series[a + (b1 + b2) x, {x, 0, 1}] // %
>
> Out[1]= Normal
> Out[2]= a + (b1 + b2) x
>
> At my level of proficiency with Mathematica, I shy away from stringing together too many operations. I prefer smaller, more manageable portions.
>
> It took my brain some time before it allowed me to see [1] as a legitimate operation.  Is [1] just a curiosity? Or is there a situation that would call for such usage?
>
> Thanks and regards,
> Glenn
>
I would not describe this as a total curiosity.

1)    There are plenty of situations in which you might want to apply a
substitution whether or not it will actually 'fire'. You certainly would
not to have to write code to test if an expression contained b2 before
applying a replacement operation to remove b2!

2)    Creating a head of an expression that is, itself subject to
evaluation isn't that unusual. A simple use is to create a synonym of a
function:

In[673]:= sine=Sin

Out[673]= Sin

In[674]:= sine[0.2]

Out[674]= 0.198669

David Bailey
http://www.dbaileyconsultancy.co.uk

```

• Prev by Date: Re: Memory leak or flawed garbage collector
• Next by Date: Odd glitch opening Mathematica notebook on a Mac
• Previous by thread: Re: Just another Mathematica "Gotcha"
• Next by thread: Re: Just another Mathematica "Gotcha"