2

I am trying to find the function that converts the result of FullForm back into a standard pretty looking output. Here is what I mean:

expr = FullForm[2 + 2 Sin[x]]

> Plus[2,Times[2,Sin[x]]]

Normal[expr]
Evaluate[expr]
DisplayForm[expr]

> Plus[2,Times[2,Sin[x]]]   (* not good, it's still displays as text *)

% 

> 2+2Sin[x]  (* good, I have a pretty formula again *)

Ok, so evaluating % just after does the trick, but it's not a function call. I was wondering what is the proper function that does this:

ProperFunctionCall[expr]

> 2+2Sin[x]

The secondary question is: does ProperFunctionCall works on all types of inputs, for example, would it work on:

expr2=FullForm[Graphics[Disk[]]];
ProperFunctionCall[expr2]

and show the pretty black disk instead of the text ?

I had a look at the online help of all the entries of ?*Form that seemed meaningful but it did not help me. I also had a look at this post and a few others, but it does not seem to be the same problem so the answer did not help either.

Thanks.

1 Answers1

6

FullForm, as well as all other *Form functions are wrappers which display in a special way. They are meant for display only. Normally one never assigns them to a variable.

You should almost never need to do something like

expr = FullForm[2 + 2 Sin[x]]

This expression cannot even be computed with because Head[expr] === FullForm. (Consequently, you could extract the contents with First[expr].)

Instead, use

expr = 2 + 2 Sin[x]

Now you can re-use expr in calculations. If you need to look at its full form, use

expr // FullForm

This is also discussed in point (8) here. A very common mistake is to assign matrix = MatrixForm[...]. But then Head[matrix] === MatrixForm, so it cannot be used in typical computations such as matrix.matrix.

Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263