Skip to content

ValueQ

Status: Stable

documented, exercised by the test suite and/or worked examples, with no known limitations recorded.

Description

ValueQ[expr]

gives True if a value has been defined for expr, False otherwise.

Notes HoldAll: inspects the symbol itself, not its evaluated value. A bare symbol tests OwnValues; f\[...\] tests whether head f has any DownValues.

Examples (5)

Every input below was run against the current Mathilda build and its output recorded.

Basic examples (5)

In[1]:= ValueQ[x]
Out[1]= False

In[2]:= x = 5; ValueQ[x]
Out[2]= True

Head has DownValues

In[3]:= f[x_] := x^2; {ValueQ[f[2]], ValueQ[f[a, b]]}
Out[3]= {True, True}

Bare symbol, only DownValues

In[4]:= ValueQ[f]
Out[4]= False

HoldAll preserved via Unevaluated

In[5]:= ValueQ /@ Unevaluated[{x, y}]
Out[5]= {True, False}

Implementation notes

Attributes: HoldAll, Protected.

References

See also: HoldAll