Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #4501
| From | Simon <simonjtyler@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: A two part notation question |
| Date | 2011-08-21 09:31 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j2qjad$ctp$1@smc.vnet.net> (permalink) |
| References | <j2le74$ndf$1@smc.vnet.net> |
Sometimes with these things it's easiest to resort to the low level MakeBoxes and MakeExpression. E.g.
f /: MakeBoxes[f[x_], form_] := With[{boxes = ToBoxes[x]},
InterpretationBox[OverscriptBox[boxes, "_"], f[x]]]
Unprotect[OverscriptBox];
OverscriptBox /: MakeExpression[OverscriptBox[x_, "_"], form_] :=
MakeExpression[RowBox[{"f", "[", x, "]"}], form]
Protect[OverscriptBox];
These definitions are stored in FormatValues[f] and FormatValues[OverscriptBox].
Although they don't need to be defined with TagSet (/:). Also, the InterpretationBox is probably overkill since we have the MakeExpression definition.
You can check that things are working with
In[7]:= f[x] // ToBoxes
Out[7]= InterpretationBox[OverscriptBox["x", "_"], f[x]]
In[8]:= Overscript[a+b, _]//FullForm
Out[8]//FullForm= f[Plus[a,b]]
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread
A two part notation question Ethan Dyer <ethansdyer@gmail.com> - 2011-08-19 10:34 +0000 Re: A two part notation question Simon <simonjtyler@gmail.com> - 2011-08-21 09:31 +0000
csiph-web