We deliver solutions for the AI eraâcombining symbolic computation, data-driven insights and deep technology expertise.
lhs:=rhs
assigns rhs to be the delayed value of lhs. rhs is maintained in an unevaluated form. When lhs appears, it is replaced by rhs, evaluated afresh each time.
DetailsA variable defined with SetDelayed is evaluated every time it is used:
Make definitions for special and general cases using immediate and delayed assignments:
Define a function by several conditional cases:
Different Kinds of Values (5) Applications (3)Define a procedure that computes a square root with Newton's method:
Perform a calculation on demand and cache the result:
Definitions for unevaluated expressions can implement call-by-name semantics:
The global variable has been modified:
Properties & Relations (9)The right side of an immediate definition is evaluated when the definition is made:
The right side of a delayed definition is evaluated each time the definition is used:
The arguments of the left side of a definition are evaluated before the definition is made:
Definitions with the same left side overwrite earlier ones:
The pattern variable is renamed if necessary inside a nested scope:
Delayed assignment introduces a scope that is not affected by global variables:
Immediate assignment does not introduce a scope:
Use a rule to do a transformation to a particular expression:
Use a definition to do a transformation automatically for all expressions involving g:
More specific definitions are put in front of more general ones:
Definition prints definitions associated with a symbol:
Information prints various information about a symbol, including any definitions:
DownValues returns a list of rules corresponding to any downvalues defined:
Use Unset (=.) to clear definitions with a particular left-hand side:
Clear any definitions, but not attributes:
Use ClearAll to clear attributes, too:
Possible Issues (4)Omitting the _ defines a transformation only for a literal value, rather than a function:
Using delayed definitions may have unexpected consequences:
The definition actually made and its behavior:
Use Evaluate to force evaluation of the right-hand side:
Or use Set to force evaluation of the right-hand side:
An iterative runaway definition:
By providing a base case, the iteration terminates:
A recursive runaway definition:
By providing a base case, the recursion terminates:
Neat Examples (1)Dynamic programming for the Fibonacci sequence:
New definitions have been added during the calculation:
HistoryIntroduced in 1988 (1.0)
Wolfram Research (1988), SetDelayed, Wolfram Language function, https://reference.wolfram.com/language/ref/SetDelayed.html. TextWolfram Research (1988), SetDelayed, Wolfram Language function, https://reference.wolfram.com/language/ref/SetDelayed.html.
CMSWolfram Language. 1988. "SetDelayed." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SetDelayed.html.
APAWolfram Language. (1988). SetDelayed. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SetDelayed.html
BibTeX@misc{reference.wolfram_2025_setdelayed, author="Wolfram Research", title="{SetDelayed}", year="1988", howpublished="\url{https://reference.wolfram.com/language/ref/SetDelayed.html}", note=[Accessed: 12-July-2025 ]}
BibLaTeX@online{reference.wolfram_2025_setdelayed, organization={Wolfram Research}, title={SetDelayed}, year={1988}, url={https://reference.wolfram.com/language/ref/SetDelayed.html}, note=[Accessed: 12-July-2025 ]}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4