lhs^:=rhs
把 rhs 赋为 lhs 的延迟值,并将这种赋值和在 lhs 中层 1 出现的符号相关联.
UpSetDelayed 
lhs^:=rhs
把 rhs 赋为 lhs 的延迟值,并将这种赋值和在 lhs 中层 1 出现的符号相关联.
范例
打开所有单元 关闭所有单元基本范例 (1)
范围 (6)
左边 (5)
rand[int] ^:= RandomInteger[]
Table[rand[int], {5}]f[h[0]] ^= h0;
f[h[x_]] ^:= 2f[h[x - 1]]
f[h[10]]area[sq, s_] ^:= s ^ 2
area[sq, 2]area[sq[s_]] ^:= s ^ 2
area[sq[3]]如果有几个符号出现在左边,定义所有符号的上值 (upvalue):
method[g[x_], h[y_]] ^:= fgh[x, y]Definition[g]Definition[h]属性和关系 (6)
^:= 定义上值(upvalue),它的方式和使用一个标签的相同:
g/:f[g[x_]] := f1[x]
f[h[x_]] ^:= f2[x]
{UpValues[g], UpValues[h]}一个标签仅定义一个上值(upvalue),^:= 执行所有符号的定义:
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]}rand[int] ^= RandomInteger[];
{rand[int], rand[int]}rand[real] ^:= RandomReal[]
{rand[real], rand[real]}f[h[x_]] ^:= f1[x]
f[h[x_]] ^:= f2[x]
Definition[h]Definition 显示与符号相关的定义:
a_mod + b_mod ^:= modPlus[a, b]
Definition[mod]Information 输出关于符号的不同信息,包括任何定义:
? modUpValues 返回对应定义的任何上值(upvalue)的规则列表:
UpValues[mod]x = 5;
f[h[x_]] ^:= x ^ 2
{f[h[2]], x}g[h[x_]] ^= x ^ 2;
{g[h[2]], x}技术笔记
相关指南
-
▪
- 赋值
相关的工作流程
- 清除符号和函数的定义 ▪
- 查找所有定义的函数
历史
1988年引入 (1.0)
文本
Wolfram Research (1988),UpSetDelayed,Wolfram 语言函数,https://reference.wolfram.com/language/ref/UpSetDelayed.html.
CMS
Wolfram 语言. 1988. "UpSetDelayed." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/UpSetDelayed.html.
APA
Wolfram 语言. (1988). UpSetDelayed. Wolfram 语言与系统参考资料中心. 追溯自 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: 07-November-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: 07-November-2026]}