ValueQ
Details and Options
- ValueQ has attribute HoldAll.
- ValueQ[expr,Methodm] uses the specified method to determine if the expression has a value defined for it.
- Possible values for the option Method include:
-
Automatic automatic behavior "SymbolDefinitionsPresent" one or more symbols have any sort of definition present "TrialEvaluation" test if the expression changes after evaluation "OwnValuesPresent" one or more symbols have a non-empty OwnValues "Legacy" match behavior in Version 12.1 and earlier - With the default method, Automatic, ValueQ[expr] effectively uses "OwnValuesPresent" if expr is a symbol and "SymbolDefinitionsPresent" for most other expressions.
Examples
open all close allBasic Examples (2)
Scope (4)
Check immediate and delayed values of symbols:
x = 5;y := RandomReal[];{ValueQ[x], ValueQ[y], ValueQ[z]}f[x_] := x ^ 2Expressions with head f give True whether or not they actually change:
{ValueQ[f[2]], f[2]}{ValueQ[f[a, b]], f[a, b]}Use a method that depends on the particular arguments:
f[x_ /; x > 0] := Sqrt[x]{ValueQ[f[1], Method -> "TrialEvaluation"], ValueQ[f[-1], Method -> "TrialEvaluation"]}ValueQ[LocalSymbol[…]] gives True if and only if the local symbol has a value:
LocalSymbol["documentation example symbol"] = 42ValueQ[LocalSymbol["documentation example symbol"]]LocalSymbol["documentation example symbol"]=.ValueQ[LocalSymbol["documentation example symbol"]]Options (4)
Method (4)
"SymbolDefinitionsPresent" tests if a symbol has any sort of evaluation definitions associated with it:
f = Function[x, x ^ 2];
g[x_] := x ^ 2;{ValueQ[f, Method -> "SymbolDefinitionsPresent"], ValueQ[g, Method -> "SymbolDefinitionsPresent"]}"OwnValuesPresent" tests whether any symbol has a direct assignment:
{ValueQ[f, Method -> "OwnValuesPresent"], ValueQ[g, Method -> "OwnValuesPresent"]}"TrialEvaluation" tests if the input expression will change:
ValueQ[Sin[2], Method -> "TrialEvaluation"]"SymbolDefinitionsPresent" tests whether any code will run, even if it leaves the value unchanged:
ValueQ[Sin[2], Method -> "SymbolDefinitionsPresent"]The Automatic method gives the same results as "OwnValuesPresent" for symbols:
f = Function[x, x ^ 2];
g[x_] := x ^ 2;{ValueQ[f, Method -> Automatic], ValueQ[f, Method -> "OwnValuesPresent"]}{ValueQ[g, Method -> Automatic], ValueQ[g, Method -> "OwnValuesPresent"]}It agrees with "SymbolDefinitionsPresent" for more general inputs:
{ValueQ[{g}, Method -> Automatic], ValueQ[{g}, Method -> "SymbolDefinitionsPresent"]}The Automatic method checks whether a LocalSymbol has an assigned value:
LocalSymbol["documentation example symbol"] = 42ValueQ[LocalSymbol["documentation example symbol"]]LocalSymbol["documentation example symbol"]=.ValueQ[LocalSymbol["documentation example symbol"]]Properties & Relations (3)
By default, ValueQ[symbol] only checks symbol for OwnValues, not other kinds of values:
x = 2;
f[x_] := x ^ 2ValueQ[x] is True because a value was assigned directly to x:
ValueQ[x]ValueQ[f] is False because f itself was not assigned a value:
ValueQ[f]For more general expressions, ValueQ checks for any kind of symbol definition:
ValueQ[{1, 2, f}]x = y;ValueQ[x]If x is allowed to evaluate prior to entering ValueQ, the result for y will be given:
{ValueQ[Evaluate[x]], ValueQ[y]}Pi evaluates to itself:
ValueQ[Pi]Use NumericQ to find out whether there is a numerical value defined:
NumericQ[Pi]Possible Issues (2)
ValueQ checks both user and built-in functions for definitions:
ValueQ[f[1 + 1]]While f has no definitions, Plus does:
{ValueQ[f, Method -> "SymbolDefinitionsPresent"], ValueQ[Plus, Method -> "SymbolDefinitionsPresent"]}x = y;{ValueQ[x], ValueQ[y]}Here x is evaluated before ValueQ sees it:
ValueQ /@ {x, y}Use Unevaluated to preserve the HoldAll attribute:
ValueQ /@ Unevaluated[{x, y}]See Also
Information OwnValues DownValues UpValues SubValues Set SetDelayed Clear ClearAll
Function Repository: HasDefinitionsQ
Tech Notes
Related Guides
Related Workflows
- Find All Defined Functions ▪
- Clear Definitions for Symbols and Functions
History
Introduced in 1988 (1.0) | Updated in 2020 (12.2)
Text
Wolfram Research (1988), ValueQ, Wolfram Language function, https://reference.wolfram.com/language/ref/ValueQ.html (updated 2020).
CMS
Wolfram Language. 1988. "ValueQ." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/ValueQ.html.
APA
Wolfram Language. (1988). ValueQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ValueQ.html
BibTeX
@misc{reference.wolfram_2026_valueq, author="Wolfram Research", title="{ValueQ}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/ValueQ.html}", note=[Accessed: 15-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_valueq, organization={Wolfram Research}, title={ValueQ}, year={2020}, url={https://reference.wolfram.com/language/ref/ValueQ.html}, note=[Accessed: 15-June-2026]}