The following code
Cases[Function[{x}, x + 1], a_?ValueQ :> Hold[a], ∞, Heads -> True]
unexpectedly returns
{Hold[x + 1]}
According to the manual, "ValueQ[expr] gives True if a value has been defined for expr, and gives False otherwise."
In the example above, what is the expression that was assigned the value x+1?
Trace
to see thatValueQ[expr]
is in fact! Hold[Evaluate[expr]] === Hold[expr]
, and sinceEvaluate[x+1]
is1+x
it passes the test. It is strange to me, maybe someone else can confirm it's desired behaviour or a bug. $\endgroup$ – Kuba♦ Nov 7 '13 at 13:33