Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

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/


  • 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