Why does
Map[Unevaluated, Table[PauliMatrix[i], {i, 1, 3}]
give
{Unevaluated[{{0, 1}, {1, 0}}], Unevaluated[{{0, -I}, {I, 0}}], Unevaluated[{{1, 0}, {0, -1}}]}
while
Table[Unevaluated[PauliMatrix[i]], {i, 1, 3}]
gives
{{{0, 1}, {1, 0}}, {{0, -I}, {I, 0}}, {{1, 0}, {0, -1}}}
I think they should give the same result! Why not?
Table
evaluates it's arguments in a non-standard way. In particular, it Holds it's arguments, explicitly evaluates the second argument (the iterator), substitutes values obtained from the iterator into the first argument and then (importantly!) explicitly evaluates the first argument at those values. $\endgroup$Map
. Map always effectively constructs a complete new expression and then evaluates it. And useTrace
, I found in the last three steps, mathematica actually remove theUnevaluated
, and finally bring back theUnevaluated
head, why? $\endgroup$Table
evaluates it's arguments in a non-standard way and (by implication) thatMap
does not. Thus, when the documentation says thatMap
"constructs a complete new expression and then evaluates it", it does so in the standard way. Thus,Map[Unevaluated,{1,2}]
produces the same output as{Unevaluated[1],Unevaluated[2]}
. $\endgroup$Map
and the step 'substitutes values ....explicitly evaluates the first argument at those values' inTable
is two kind of evaluate?!! I still don't understand, Now thatTable
has the attributesHoldAll
, it should hold theUnevaluated
. It seems that "expr, shift+Enter" and "Evaluate[expr]" is different ? And Map use the first oneTable
use the second? $\endgroup$Unevaluated[1+1]
as input vsEvaluate[Unevaluated[1+1]]
as the input. $\endgroup$