lhs^:=rhs
assigns rhs to be the delayed value of lhs, and associates the assignment with symbols that occur at level one in lhs.
UpSetDelayed 
lhs^:=rhs
assigns rhs to be the delayed value of lhs, and associates the assignment with symbols that occur at level one in lhs.
Examples
open all close allBasic Examples (1)
f[g[x_]] ^:= fg[x]Check that it only applies when the correct symbol appears at level one in the expression:
{f[g[2]], f[h[2]]}Check that the definition is not associated to the outer symbol f:
Definition[f]Check that it is associated with the symbol g at level one:
Definition[g]Scope (6)
Left-Hand Sides (5)
An expression with a delayed definition is evaluated every time it is used:
rand[int] ^:= RandomInteger[]
Table[rand[int], {5}]Make definitions for special and general cases using immediate and delayed assignments:
f[h[0]] ^= h0;
f[h[x_]] ^:= 2f[h[x - 1]]
f[h[10]]The definition can be associated with a symbol appearing as an argument of the left side:
area[sq, s_] ^:= s ^ 2
area[sq, 2]The definition can be associated with the head of an argument of the left side:
area[sq[s_]] ^:= s ^ 2
area[sq[3]]If several symbols appear in the left-hand side, upvalues for all of them are defined:
method[g[x_], h[y_]] ^:= fgh[x, y]So it is associated to the symbol g:
Definition[g]And it is also associated to the symbol h:
Definition[h]Properties & Relations (6)
^:= defines upvalues in the same way as using a tag does:
g/:f[g[x_]] := f1[x]
f[h[x_]] ^:= f2[x]
{UpValues[g], UpValues[h]}A tag defines only one upvalue; ^:= makes definitions for all symbols:
g/:f1[g[x_], h[y_]] := gh[x y]
f2[g[x_], h[y_]] ^:= gh[x y]So g has an upvalue from both definitions, but h only has one from the second definition:
{UpValues[g], UpValues[h]}The right side of an immediate definition is evaluated when the definition is made:
rand[int] ^= RandomInteger[];
{rand[int], rand[int]}The right side of a delayed definition is evaluated each time the definition is used:
rand[real] ^:= RandomReal[]
{rand[real], rand[real]}Definitions with the same left side overwrite earlier ones:
f[h[x_]] ^:= f1[x]
f[h[x_]] ^:= f2[x]
Definition[h]Definition prints definitions associated with a symbol:
a_mod + b_mod ^:= modPlus[a, b]
Definition[mod]Information prints various information about a symbol, including any definitions:
? modUpValues returns a list of rules corresponding to any upvalues defined:
UpValues[mod]Delayed assignment introduces a scope that is not affected by global variables:
x = 5;
f[h[x_]] ^:= x ^ 2
{f[h[2]], x}Immediate assignment does not introduce a scope:
g[h[x_]] ^= x ^ 2;
{g[h[2]], x}See Also
Tech Notes
Related Guides
Related Workflows
- Clear Definitions for Symbols and Functions ▪
- Find All Defined Functions
History
Introduced in 1988 (1.0)
Text
Wolfram Research (1988), UpSetDelayed, Wolfram Language function, https://reference.wolfram.com/language/ref/UpSetDelayed.html.
CMS
Wolfram Language. 1988. "UpSetDelayed." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/UpSetDelayed.html.
APA
Wolfram Language. (1988). UpSetDelayed. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/UpSetDelayed.html
BibTeX
@misc{reference.wolfram_2026_upsetdelayed, author="Wolfram Research", title="{UpSetDelayed}", year="1988", howpublished="\url{https://reference.wolfram.com/language/ref/UpSetDelayed.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_upsetdelayed, organization={Wolfram Research}, title={UpSetDelayed}, year={1988}, url={https://reference.wolfram.com/language/ref/UpSetDelayed.html}, note=[Accessed: 13-June-2026]}