Help with custom Format
- To: mathgroup at smc.vnet.net
- Subject: [mg8456] Help with custom Format
- From: Ersek_Ted%PAX1A at mr.nawcad.navy.mil
- Date: Sat, 30 Aug 1997 00:43:10 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Hello Math Group,
Consider the following:
In[1]:= poly=2+a*x+b*x+z*x^2+y*x^2+e*x^3+d*x^3 ;
In[2]:= Collect[poly, x]
Out[2]= 2 + (a+b) x + (d+e) x^3 + x^2 (y+z)
I want to change Collect so the result is displayed in a non-standard order.
In particular I want the Output above to show as follows:
Out[2]= 2 + (a+b) x + (y+z) x^2 + (d+e) x^3
The tricky part is that I don't want anything like HoldForm to show-up in
the FullForm of the result. The reason is that I want to be able to use
the result later on without making use of ReleaseHold[] or anything like
that. This way the use of the format I prefer will be transparent to the
user.
I did figure out how to make a function I call "TemporaryHold" that helps
get the results I want. A few months ago I discussed in the mathgroup my
work with TemporaryHold.
However, I think it's better to use a custom Rule for MakeBoxes to do what I
want.
The problem is that after Collect is done with poly, the FullForm looks the
same as it does for any other polynomial. Now I don't know how I can only
use my custom Rule for expressions that come from Collect[], but not for
other expressions.
I think InterpretationBox[boxes, expr]
was made for this sort of thing. But I don't understand how to use it.
Any solutions greatly appreciated.
Ted Ersek