TagSet
TagSet(f, expr, value)
or
f /: expr = value
assigns the evaluated
value
toexpr
and associates the corresponding rule with the symbolf
.
Examples
Create an upvalue without using UpSet
:
>> x /: f(x) = 22
>> f(x)2
>> DownValues(f){}
>> UpValues(x){HoldPattern(f(x)):>2}
The symbol f
must appear as the ultimate head of lhs
or as the head of a leaf in lhs
:
>> x /: f(g(x)) = 3 : Tag x not found or too deep for an assigned rule.
>> g /: f(g(x)) = 3;
>> f(g(x))3
Related terms
Set, SetDelayed, TagSetDelayed
Implementation status
- ✅ - full supported