TagSetDelayed¶
Defines a delayed upvalue assignment associated with a tag symbol. The
tag /: lhs := rhs shorthand is the usual way to write it.
Upvalues attached to Plus, Times and Power also apply to the arithmetic
shorthands that expand to those heads: a - b is Plus[a, Times[-1, b]],
a / b is Times[a, Power[b, -1]] and -a is Times[-1, a].
$ wo 'mytag /: mytag[a_] + mytag[b_] := mytag[a + b]; mytag /: i_Integer mytag[a_] := mytag[a i]; mytag[3] - mytag[3]'
mytag[0]
Together they implement modular arithmetic, where m[a, n] stands for
a modulo n: