Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1990
*January
*February
*March
*April
*May
*June
*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 1990

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

Search the Archive

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



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