f/:lhs:=rhs
rhs を lhs の遅延型の値として割り当てて,この割当てをシンボル f に関連付ける.
TagSetDelayed 
f/:lhs:=rhs
rhs を lhs の遅延型の値として割り当てて,この割当てをシンボル f に関連付ける.
詳細
- TagSetDelayedは,上向の値,下向きの値,部分値を適切に定義する.
- f/:lhs:=rhs のシンボル f は,lhs 中に,lhs の頭部,頭部の頭部,lhs の要素の一つ,あるいは要素の一つの頭部として現れなければならない.
- よく見られる例として f/:h[f[args]]:=rhs がある.
- ?symbol を使って特定のシンボルに関連付けられたすべての規則を見ることができる.
- f が lhs の中に複数回出現する場合,f/:lhs:=rhs は各出現に割当てを関連付ける.
- TagSetDelayedは,未評価の記号形式内にある場合は,ネスト構造内の変数名が必要に応じて変更されるように,スコーピング構造として扱われる.
例題
すべて開く すべて閉じる例 (1)
g/:f[g[x_]] := fg[x]{f[g[2]], f[h[2]]}スコープ (7)
左辺 (4)
int/:rand[int] := RandomInteger[]Table[rand[int], {5}]即時的割当てと遅延的割当てとを使って特殊ケースと一般ケースについての定義をする:
h/:f[h[0]] = h0;
h/:f[h[x_]] := 2f[h[x - 1]]f[h[10]]sq/:area[sq, s_] := s ^ 2area[sq, 2]sq/:area[sq[s_]] := s ^ 2area[sq[3]]さまざまな種類の値 (3)
x/:x := RandomReal[]
y := RandomReal[]{OwnValues[x], OwnValues[y]}f/:f[x_] := x ^ 2;
g[x_] := x ^ 2{DownValues[f], DownValues[g]}g/:f[g[x_]] := f1[x]
f[h[x_]] := f2[x]{UpValues[g], DownValues[f]}アプリケーション (1)
特性と関係 (7)
^:=は,タグを使った場合と同じように上向きの値を定義する:
g/:f[g[x_]] := f1[x]f[h[x_]] ^:= f2[x]{UpValues[g], UpValues[h]}タグは上向きの値1つのみを定義する.^:=はすべての記号を定義する:
g/:f1[g[x_], h[y_]] := gh[x y]f2[g[x_], h[y_]] ^:= gh[x y]{UpValues[g], UpValues[h]}int/:rand[int] = RandomInteger[];{rand[int], rand[int]}real/:rand[real] := RandomReal[]{rand[real], rand[real]}h/:f[h[x_]] := f1[x]h/:f[h[x_]] := f2[x]Definition[h]Definitionは記号に関連した定義を出力する:
mod/:a_mod + b_mod := modPlus[a, b]Definition[mod]Informationは定義を含む記号に関連したさまざまな情報を出力する:
? modUpValuesは定義された任意の上向きの値に対応する規則のリストを返す:
UpValues[mod]h/:f[h[x_]] := f1[x];
h/:g[h[x_]] := g1[x];h/:f[h[x_]]=.{f[h[1]], g[h[1]]}Clear[h]Definition[h]x = 5;h/:f[h[x_]] := x ^ 2{f[h[2]], x}h/:g[h[x_]] = x ^ 2;{g[h[2]], x}テクニカルノート
関連するガイド
-
▪
- 割当て
履歴
1988 で導入 (1.0)
テキスト
Wolfram Research (1988), TagSetDelayed, Wolfram言語関数, https://reference.wolfram.com/language/ref/TagSetDelayed.html.
CMS
Wolfram Language. 1988. "TagSetDelayed." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TagSetDelayed.html.
APA
Wolfram Language. (1988). TagSetDelayed. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TagSetDelayed.html
BibTeX
@misc{reference.wolfram_2026_tagsetdelayed, author="Wolfram Research", title="{TagSetDelayed}", year="1988", howpublished="\url{https://reference.wolfram.com/language/ref/TagSetDelayed.html}", note=[Accessed: 06-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_tagsetdelayed, organization={Wolfram Research}, title={TagSetDelayed}, year={1988}, url={https://reference.wolfram.com/language/ref/TagSetDelayed.html}, note=[Accessed: 06-September-2026]}