       Re: Just another Mathematica "Gotcha", and HoldForm bug

• To: mathgroup at smc.vnet.net
• Subject: [mg120796] Re: Just another Mathematica "Gotcha", and HoldForm bug
• From: Richard Fateman <fateman at cs.berkeley.edu>
• Date: Thu, 11 Aug 2011 05:09:42 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• References: <j1r5d3\$fi4\$1@smc.vnet.net> <j1tnpf\$pnu\$1@smc.vnet.net>

```Why one might be confused

In:= A + B /. x_ -> M[x]
Out= M[A + B]

In:= A + B // M
Out= M[A + B]

In:= A + B /. x_ -> M[x] // F
Out= F[M[A + B]]

In:= A + B // M /. x_ -> F[x]
Out= F[M][A + B]

Note the identicality of Out and Out.
Note that Out and Out are different.

Since neither //  nor /. are "traditional" mathematical
syntax, one's intuition may be unreliable. Simple examples
such as 6,7 above, might lead one to believe they have
equal precedence and are treated nominally from left to right.

Reading up on the details by looking at Mathematica's
description of syntax and operator precedence is difficult,
since it is simultaneously daunting and incomplete.
One is therefore left with experimentation. Simple experiments
are not enough, though, as shown by 6, which suggests that
/. applies rule(s) to everything to the left, and 7 which
suggests that // applies an operator to everything
to the left.  Both of these are false. See a=b/.f;  a=b//f.

In looking at examples, I think I found a bug, but maybe
it is a feature?

Did you know that

HoldForm[x //@ y]      returns  x//@y
but
HoldForm[x //  y]      returns  y[x]

?
(version 7.0).

While it is easy to place blame on "user error", I think "design error"
contributes to difficulties as well.

RJF

```

• Prev by Date: Re: Print Magnification?
• Next by Date: Re: Getting TraditionalForm to put in a multiplication sign.
• Previous by thread: Re: work?
• Next by thread: Re: Just another Mathematica "Gotcha", and HoldForm