next up previous contents
Next: Output as strings Up: Construction Previous: Construction

Output formats

 A print form (or output form) in Mathematica is a printing specification. This is independent of the evaluation of an expression, since evaluation is performed without regard to the print form. For example, reformatting an expression has no effect on the value of the expression itself. In this sense, print forms are referred to as wrappers. The format type specifies how expressions are to be formatted; FormatValues[f] specifies the print forms associated with a symbol f. A label attached to Out (e.g. //FortranForm) is used to indicate special formatting associated with an expression.
In[1]:= expr = FortranForm[1 + Sin[x]^2]
Out[1]//FortranForm=
1 + Sin(x)**2
The result of the previous computation is the expression inside the print form (without FortranForm wrapped around it) :
In[2]:= %
Out[2]:=
           2
1 + Sin[x]
The value of expr includes the wrapper:
In[3]:= expr
Out[3]//FortranForm=
1 + Sin(x)**2

Maeder [15] gives an example of the use of Format to print arguments as indices and thus mimic subscripted mathematical notation. A list of available print forms may be obtained by issuing the command $PrintForms. Other output formats exist, such as TreeForm[expr] which returns a tree representation of expr with different levels printed at different depths. A list of output forms may be obtained using $OutputForms. The formatting functions proved difficult to extend for our purposes and an alternative strategy, outlined in the next section, has been adopted.


next up previous contents
Next: Output as strings Up: Construction Previous: Construction

Jorge Romao
5/14/1998