Re: Just another Mathematica "Gotcha", and HoldForm bug
- To: mathgroup at smc.vnet.net
- Subject: [mg120827] Re: Just another Mathematica "Gotcha", and HoldForm bug
- From: "Oleksandr Rasputinov" <oleksandr_rasputinov at hmamail.com>
- Date: Fri, 12 Aug 2011 05:03:55 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <j1r5d3$fi4$1@smc.vnet.net> <j1tnpf$pnu$1@smc.vnet.net>
On Thu, 11 Aug 2011 10:12:07 +0100, Richard Fateman <fateman at cs.berkeley.edu> wrote: > 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. > Looking at the FullForm is simple, albeit not an experiment. Also simple (though for some reason not documented) is querying the precedence of the operators directly: Precedence[ReplaceAll] = 110. Precedence[Postfix] = 70. which is to say, of course, that Precedence[ReplaceAll] > Precedence[Postfix] = True which is as direct a statement of this fact as I think you'll ever find. > 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). > //@ is a sigil representing the infix form of MapAll. An interpretation of the first expression as postfix immediately followed by prefix function application which you seem to be suggesting as a possibility would not be meaningful: what would its (syntactically correct) FullForm be? > While it is easy to place blame on "user error", I think "design error" > contributes to difficulties as well. > Yes, I dare say that many practically-minded users would find it easier to solve their real-world problems in Mathematica if it were based on Prolog or some similarly widely used language in which the order in which relations are stated is inconsequential. (Being serious for a moment, users do have the option to code in FullForm if they wish precedence to be explicit. For some reason, though, most seem not to prefer this...)