MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

TagSetDelayed and UpValues

  • To: mathgroup at
  • Subject: [mg62332] TagSetDelayed and UpValues
  • From: "Steven T. Hatton" <hattons at>
  • Date: Mon, 21 Nov 2005 03:54:15 -0500 (EST)
  • Sender: owner-wri-mathgroup at

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

g[x_] + g[y_] ^:= gplus[x, y]

In[3]:= func /: D[func[x_], {x_, n_}] := derivOfFunc[x, n]

In[4]:= ?func

func /: D[func[x_], {x_, n_}] := derivOfFunc[x, n]

The Mathematica Wiki:
Math for Comp Sci
Math for the WWW:

  • Prev by Date: Re: Newbie with simple questions (take 2)
  • Next by Date: Re: Intepolation of an array with missing points
  • Previous by thread: Re: Export[] to XLS
  • Next by thread: Re: TagSetDelayed and UpValues