Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Consider the following


We expect False and get it. Now consider

ValueQ[jd /. {foo -> Unique[]}]

which yields True. But

jd /. {foo -> Unique[]}

is just jd and has no value defined. What's going on here?

share|improve this question
ValueQ[] is a funny beast. Try {ValueQ@E, ValueQ@Sin@E, ValueQ@Pi, ValueQ@Sin@Pi, ValueQ@N@Pi} :) –  belisarius Dec 25 '13 at 19:10
some related questions on ValueQ –  rm -rf Dec 25 '13 at 19:18
According to the doc, "ValueQ gives False only if expr would not change if it were to be entered as Mathematica input.", so the Value in ValueQ does not mean numerical value I think. –  Silvia Dec 25 '13 at 19:31
See the definition for yourself: ClearAttributes[ValueQ, Protected]; ClearAttributes[ValueQ, ReadProtected]; ValueQ // Information; DownValues[ValueQ][[1]] /. {SystemDump`s -> s, System`Dump`h -> h}` –  Jacob Akkerboom Dec 25 '13 at 21:54
So in your case we have (both give True): ! Hold[Evaluate[jd /. {foo -> Unique[]}]] === Hold[jd /. {foo -> Unique[]}], as ! Hold[Evaluate[jd]] === Hold[jd /. {foo -> Unique[]}] –  Jacob Akkerboom Dec 25 '13 at 22:03
show 1 more comment

1 Answer

If, say, f has the HoldAll attribute, you should not assume f[2] to be the same as f[1+1]. ValueQ has such attribute.

ValueQ tests whether the expression changes upon evaluation.

jd /. {foo -> Unique[]} evaluates to jd which is different from the original unevaluated form jd /. {foo -> Unique[]}. Therefore, ValueQ[jd /. {foo -> Unique[]}] gives True

share|improve this answer
add comment

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.