Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #4351

Re: Just another Mathematica "Gotcha", and HoldForm

From Murray Eisenberg <murray@math.umass.edu>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Just another Mathematica "Gotcha", and HoldForm
Date 2011-08-12 09:13 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j22qrh$gtc$1@smc.vnet.net> (permalink)
References <j1r5d3$fi4$1@smc.vnet.net> <j1tnpf$pnu$1@smc.vnet.net> <201108110909.FAA07141@smc.vnet.net>

Show all headers | View raw


But in the first two examples, you have only one "postifx" operator in 
each case, whereas in the second two you have two such. Only there you 
have to deal with precedence, really.

Also, I find nothing especially difficult about looking up Mathematica's 
syntax and operator precedence with respect, at least, to this issue.

On 8/11/11 5:09 AM, Richard Fateman wrote:
> Why one might be confused
>
> In[6]:= A + B /. x_ ->  M[x]
> Out[6]= M[A + B]
>
> In[7]:= A + B // M
> Out[7]= M[A + B]
>
> In[8]:= A + B /. x_ ->  M[x] // F
> Out[8]= F[M[A + B]]
>
> In[9]:= A + B // M /. x_ ->  F[x]
> Out[9]= F[M][A + B]
>
>
> Note the identicality of Out[6] and Out[7].
> Note that Out[8] and Out[9] 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.
>

-- 
Murray Eisenberg                     murray@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Just another Mathematica "Gotcha" AES <siegman@stanford.edu> - 2011-08-09 11:24 +0000
  Re: Just another Mathematica "Gotcha" David Bailey <dave@removedbailey.co.uk> - 2011-08-10 10:45 +0000
  Re: Just another Mathematica "Gotcha" Richard Fateman <fateman@cs.berkeley.edu> - 2011-08-10 10:50 +0000
    Re: Just another Mathematica "Gotcha", and HoldForm bug Richard Fateman <fateman@cs.berkeley.edu> - 2011-08-11 09:12 +0000
    Re: Just another Mathematica "Gotcha", and HoldForm DrMajorBob <btreat1@austin.rr.com> - 2011-08-12 09:06 +0000
    Re: Just another Mathematica "Gotcha", and HoldForm bug "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-08-12 09:05 +0000
    Re: Just another Mathematica "Gotcha", and HoldForm bug "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-08-12 09:06 +0000
      Re: Just another Mathematica "Gotcha", and HoldForm bug Richard Fateman <fateman@cs.berkeley.edu> - 2011-08-27 12:18 +0000
    Re: Just another Mathematica "Gotcha", and HoldForm Murray Eisenberg <murray@math.umass.edu> - 2011-08-12 09:13 +0000
  Re: Just another Mathematica "Gotcha" "Kevin J. McCann" <kjm@KevinMcCann.com> - 2011-08-10 11:00 +0000
  Re: Just another Mathematica "Gotcha" Roger Wilson <rogerhw999@gmail.com> - 2011-08-11 07:26 +0000
  Re: Just another Mathematica "Gotcha" Simon <simonjtyler@gmail.com> - 2011-08-11 07:26 +0000
  Re: Just another Mathematica "Gotcha" DrMajorBob <btreat1@austin.rr.com> - 2011-08-11 09:11 +0000

csiph-web