The expression Head[Plot[x, {x, 0, 1}]]
returns Graphics
. Might it be possible to extract the original head of an expression without evaluation transforming it into something else?
My ultimate objective is to be able to pass any expression say, f[x]
as an argument arg
to another function g[arg]
and then within g
do something like this:
IN:: f[x]:= x; g[arg] := Module[{head}, **Some other stuff**; head = Head@arg; head]; g[f@x]
OUT:: f
However, doing:
IN:: g[arg] := Module[{head}, **Some other stuff**; head = Head@arg; head]; g[Plot[x, {x, 0, 1}]]]
I get:
OUT:: Graphics
This also happens when setting the Attributes of g
to HoldFirst
etc.
Head
. Try usingUnevaluated
:Head@Unevaluated@arg
$\endgroup$