MathGroup Archive 1990

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

Search the Archive

Re: Literal

  • Subject: Re: Literal
  • From: uunet!!jacobson
  • Date: Fri, 09 Mar 90 10:33:58 PST
  • Apparently-to: mathgroup-send at

jack at 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]

    In[9]:= f[Integrate[r[t],t]]

    Out[9]= f[--]

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]]

Out[4]= -- + Sin[t]
  -- David Jacobson

  • Prev by Date: DSolve
  • Next by Date: Re: Use of Literal
  • Previous by thread: Re: Use of Literal
  • Next by thread: Plotting two surfaces