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 allclose allBasic Examples (2)
Scope (4)
Check immediate and delayed values of symbols:
Expressions with head f give True whether or not they actually change:
Use a method that depends on the particular arguments:
ValueQ[LocalSymbol[…]] gives True if and only if the local symbol has a value:
Options (4)
Method (4)
"SymbolDefinitionsPresent" tests if a symbol has any sort of evaluation definitions associated with it:
"OwnValuesPresent" tests whether any symbol has a direct assignment:
"TrialEvaluation" tests if the input expression will change:
"SymbolDefinitionsPresent" tests whether any code will run, even if it leaves the value unchanged:
The Automatic method gives the same results as "OwnValuesPresent" for symbols:
It agrees with "SymbolDefinitionsPresent" for more general inputs:
The Automatic method checks whether a LocalSymbol has an assigned value:
Properties & Relations (3)
By default, ValueQ[symbol] only checks symbol for OwnValues, not other kinds of values:
ValueQ[x] is True because a value was assigned directory to x:
ValueQ[f] is False because f itself was not assigned a value:
For more general expressions, ValueQ checks for any kind of symbol definition:
If x is allowed to evaluate prior to entering ValueQ, the result for y will be given:
Pi evaluates to itself:
Use NumericQ to find out whether there is a numerical value defined:
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