Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Why does

Map[Unevaluated, Table[PauliMatrix[i], {i, 1, 3}]


{Unevaluated[{{0, 1}, {1, 0}}], Unevaluated[{{0, -I}, {I, 0}}], Unevaluated[{{1, 0}, {0, -1}}]}


Table[Unevaluated[PauliMatrix[i]], {i, 1, 3}]


{{{0, 1}, {1, 0}}, {{0, -I}, {I, 0}}, {{1, 0}, {0, -1}}}

I think they should give the same result! Why not?

share|improve this question
It's just that 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. – Mark McClure May 5 '13 at 2:14
@MarkMcClure But according to the docs of Map. Map always effectively constructs a complete new expression and then evaluates it. And use Trace, I found in the last three steps, mathematica actually remove the Unevaluated, and finally bring back the Unevaluated head, why? – matheorem May 5 '13 at 2:49
I'm just saying that Table evaluates it's arguments in a non-standard way and (by implication) that Map does not. Thus, when the documentation says that Map "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]}. – Mark McClure May 5 '13 at 2:58
@MarkMcClure You're telling me that the step "then evaluate it" in Map and the step 'substitutes values ....explicitly evaluates the first argument at those values' in Table is two kind of evaluate?!! I still don't understand, Now that Table has the attributes HoldAll, it should hold the Unevaluated. It seems that "expr, shift+Enter" and "Evaluate[expr]" is different ? And Map use the first one Table use the second? – matheorem May 5 '13 at 3:17
Yes. Try your "two kinds of evaluate" with Unevaluated[1+1] as input vs Evaluate[Unevaluated[1+1]] as the input. – Mark McClure May 5 '13 at 3:23
up vote 3 down vote accepted

The answer isn't so much related to Map or Table, but to Unevalauted and the evaluation sequence.

The first one

Map[Unevaluated, {1, 2}]

(* {Unevaluated[1], Unevaluated[2]} *)

All the heads and arguments are inert, and none has heads Evaluate or Unevaluated to worry about. Note that the symbol Unevaluated doesn't have head Unevaluated. Just apply the mapping downvalue to get {Unevalauted[1], Unevaluated[2]}


Table[Unevaluated@i, {i, 2}]

(* {1, 2} *)

Strip Unevaluated from the head of the argument Unevaluated@i. Now it's just like Table[i, {i,2}] giving {1, 2}.

share|improve this answer
yeah! I notice it from Trace. Mathematica just simply strip Unevaluated away in the Table in the first step. But why? – matheorem May 5 '13 at 6:48
@matheorem that's equivalent to asking why MMA evaluates first the head. It's part of the evaluation sequence to strip the Unevaluateds. It's useful when you want to pass arguments to functions before they are evaluated. For example, Map[Hold, Unevaluated@{2+2, 3+7}] – Rojo May 5 '13 at 6:54
Well, you mean the result of evaluating the head Unevaluated is just strip it, right? – matheorem May 5 '13 at 8:36
@matheorem. No. Unevaluated[something] is inert. I'm mean it gets stripped. Unevaluated is very special, you couldn't replace it with, for example, Identity. – Rojo May 5 '13 at 8:41
@matheorem with inert I just meant that it evaluates to itself, it doesn't change when evaluated. Just like {2, 3}, or Hold[5], Unevaluated[whatever] evaluates to itself. Identity, on the other hand, evaluates to its contents, or "strips Identity upon evaluation". Unevaluated isn't stripped when the Unevaluated[something] is evaluated. It is stripped when something that has it as argument is evaluated. That is very special behaviour, unique to Unevaluated – Rojo May 5 '13 at 8:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.