# FullForm applied to functions

I would have expected

FullForm[Cases[{a^2, a^3}, a_^1]]


to produce Cases[List[Power[a, 2], Power[a ,3]], Pattern[a, Blank[]]]

Instead it produces only List[Power[a, 2], Power[a ,3]]

In contrast,

FullForm[Log[10, x + y]]


produces a complete representation, Times[Power[Log[10],-1], Log[Plus[x, y]]]

I would appreciate a work-around for the first example, or at least an explanation. Thanks.

• FullForm shows the result of the calculation. It's not HoldAll. Jan 2, 2015 at 23:30
• To the close-voters: nowhere in the documentation of FullForm (that I can see) is a method given to show the unevaluated verbose form of an expression. I therefore contend that it is not "easily found in the documentation." Jan 3, 2015 at 6:31
• @Yves "I would appreciate a work-around for the first example ..." Jan 3, 2015 at 16:07

FullForm is a formatting wrapper(1)(2)(3). It does not change the way that the expression it contains evaluates but rather the way it is displayed by the Front End. You can combine it with HoldForm, which is another formatting wrapper that specifically holds its argument, to show the unevaluated full form of an expression:

Cases[{a^2, a^3}, a_^1] // FullForm // HoldForm

Cases[List[Power[a, 2], Power[a, 3]], Power[Pattern[a, Blank[]], 1]]


Note that as formatting wrappers neither of these is explicitly shown in the output, though they both affect it, and they both remain as part of the expression which can be seen with yet another wrapper, InputForm:

% // InputForm

HoldForm[FullForm[Cases[{a^2, a^3}, (a_)^1]]]


(See Out if you are unfamiliar with % notation.)

Somewhat related:

As already mentioned in the comment: FullForm is a function that evaluates in the standard way because it has no attribute saying otherwise. One consequence is that before FullForm acts on your input, it evaluates it, which leave only the result of cases.

None of this helps you to get your answer anyway. One easy way is to use Unevaluated on arguments to get what you like

FullForm[Unevaluated[Cases[{a^2,a^3},a_^1]]]
(* Unevaluated[Cases[List[Power[a,2],Power[a,3]],Power[Pattern[a,Blank[]],1]]] *)


This works, but you will have the Unevaluated in your output. Another way is to temporarily give FullForm an attribute to hold its argument. This can be achieved with InternalInheritedBlock.

InternalInheritedBlock[{FullForm},
SetAttributes[FullForm,{HoldFirst}];
Print[FullForm[Cases[{a^2,a^3},a_^1]]]
]

(* Cases[List[Power[a,2],Power[a,3]],Power[Pattern[a,Blank[]],1]] *)


You may ask why I print the output. The problem is that as soon as we leave the block, Mathematica restores the normal behavior of FullForm which leads to an evaluation like you have seen it. Another way of getting the ouput that looks like it doesn't evaluate anymore is to replace the last line in the block with

HoldForm[#] &[FullForm[Cases[{a^2, a^3}, a_^1]]]
`

This should give you a start how to handle those cases in future. I strongly recommend that you read the Tutorial on Non-Standard Evaluation and the references therein.