Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #4603
| From | Richard Fateman <fateman@cs.berkeley.edu> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Just another Mathematica "Gotcha", and HoldForm bug |
| Date | 2011-08-27 12:18 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j3ana5$hcb$1@smc.vnet.net> (permalink) |
| References | <j1r5d3$fi4$1@smc.vnet.net> <j1tnpf$pnu$1@smc.vnet.net> <j22qe4$gop$1@smc.vnet.net> |
On 8/12/2011 2:06 AM, Oleksandr Rasputinov wrote: >>> >>>(RJF) Did you know that >>> >>> HoldForm[x //@ y] returns x//@y >>> but >>> HoldForm[x // y] returns y[x] >>> >>> ? >>> (version 7.0). >>> >> .. snip.. > > On further consideration it strikes me that I may have misunderstood what > you meant here. Yes. but you got it right, below. HoldForm is simply printing the expressions in InputForm, > so for example we also have > > HoldForm[MapAll[x,y]] > > printing: > > x //@ y > > Conversion between two equivalent syntactic forms (postfix notation, and > InputForm) is not considered to be a form of evaluation; I agree. it is simply the > way in which the expressions are parsed. Not really parsed, but displayed. a[b] , a@b, and b//a are parsed into the same thing. I view Postfix, Prefix, InputForm as output specifiers; hints to the display program on what to do, not actual conversions. I suppose Mathematica could be doing something else, but this is the way I'd do it. That is, I'd store Postfix[a[b]], but write the display program to show it as b//a. I find the specifications defective, anyway. For instance, Postfix[f[a,b]] comes out as Postfix[f[a,b]] instead of the form Sequence[a,b]//f, which is in fact a postfix version of f[a,b]. If you want an expression that > prints in a particular way you can use > > HoldForm@Postfix[x // y] Not really useful. That expression is not x//y. It is HoldForm[Postfix[y[x]]]. ... The point of my posting is that there is an inconsistency in Mathematica that says that x//y is normally displayed as y[x]. x/.y is normally displayed as x/.y not ReplaceAll[x,y] doing FullForm[everything] is probably the only way to consistently reduce the clutter of mystery, and the display program is clearly able to make more or less informed choices on preferred formats for any construct. I think that f[a,b] is much preferable to Sequence[a,b]//f. I think that, especially for novices, ReplaceAll[x,y] has more mnemonic content than x/.y. Someone's note (DanL?) raised the Dot issue. More gotchas, but not nearly as likely to occur, are these puzzles. One might wonder how to parse x . y x .. y x...y x . .. y x.. . y x....y x.....y x......y x.......y All of which are syntactically valid. Of lines 3,4,5, two of them have the same meaning. Can you tell which? Also consider the confusing lines below 3. ..4 3.. .4 3....4 3... .4 3. ...4 which are NOT the same at all when 3, 4 are x, y. Hint. FullForm[x..] is Repeated[x], and FullForm[x...] is RepeatedNull[x]. RJF
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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