If I give Mathematica the input
TreeForm[Unevaluated[4^5]]
I expect to see three boxes -- power, 4, and 5.
Instead I see a single box with 1024. Can anyone explain?
A level of Unevaluated
is stripped off with every evaluation, so you can get what you want with:
TreeForm[Unevaluated@Unevaluated[4^5]]
Compare
TreeForm@Unevaluated[4^5]
with
TreeForm@Hold[4^5]
From the help:
Unevaluated[expr] represents the unevaluated form of expr when it appears as the argument to a function.
and
Hold[expr] maintains expr in an unevaluated form.
so, as Unevaluated[4^5] gets to TreeForm ... it gets evaluated ...
It works like this:
f[x_+y_]:=x^y;
f[3+4]
(*
-> f[7]
*)
f[Unevaluated[3+4]]
(*
->81
*)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With