Re: Literal

*Subject*: Re: Literal*From*: uunet!cello.hpl.hp.com!jacobson*Date*: Fri, 09 Mar 90 10:33:58 PST*Apparently-to*: mathgroup-send at yoda.ncsa.uiuc.edu

jack at sun.acs.udel.edu writes: I want to define a function of Mathematica built-in function. I can do this but to evaluate it seems a little awkward. I must be doing something wrong!? In[1]:= f[Literal[Integrate[g_,x_]]]:=Integrate[g,x] + Sin[x] r[t_]:=t^3 ... In[9]:= f[Integrate[r[t],t]] 4 t Out[9]= f[--] 4 The problem has nothing to do with literal, but rather with the fact that f[] evaluates its argument. Since Integrate[r[t],t] evaluates to t^4/4, all f ever gets to see is f[t^4/4], and that won't evaluate, so that is what it gives you. If before defining f you make f have the HoldAll attribute, everything will work fine. ---------------------- In[1]:= SetAttributes[f,HoldAll] In[2]:= f[Literal[Integrate[g_,x_]]]:=Integrate[g,x] + Sin[x] In[3]:= r[t_] := t^3 In[4]:= f[Integrate[r[t],t]] 4 t Out[4]= -- + Sin[t] 4 --------------- -- David Jacobson