TagSetDelayed and UpValues
- To: mathgroup at smc.vnet.net
- Subject: [mg62332] TagSetDelayed and UpValues
- From: "Steven T. Hatton" <hattons at globalsymmetry.com>
- Date: Mon, 21 Nov 2005 03:54:15 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
The first example below is from The Mathematica Book, and the second is from TMGB-P. Notice that g has an upvalue associated with it, whereas func still has the TagSetDelayed associated with it. Why is that? How are these values treated (differently) during evaluation? I'm confident that the upvalue for g will tried when g appears in an argument list, and if the head of the expression inwhich it appears is Plus, the rule will be applied. I'm not sure what will happen with func. In[1]:= g/:g[x_]+g[y_]:=gplus[x,y] In[2]:= ?g Global`g g[x_] + g[y_] ^:= gplus[x, y] In[3]:= func /: D[func[x_], {x_, n_}] := derivOfFunc[x, n] In[4]:= ?func Global`func func /: D[func[x_], {x_, n_}] := derivOfFunc[x, n] -- The Mathematica Wiki: http://www.mathematica-users.org/ Math for Comp Sci http://www.ifi.unizh.ch/math/bmwcs/master.html Math for the WWW: http://www.w3.org/Math/