MathGroup Archive 2001

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

Search the Archive

Re: Evaluating expressions in pure functions


> I have a pure function with a product of numbers in it.
> Mathematica doesn't evaluate the product:
> 
> Exp[2*3*#]&
> 
> I just want to get
> 
> Exp[6*#]&
> 
> How can I make Mathematica do this?

Max,

Function (and Sum) keep their arguments unevaluated, presumably to
allow for non-standard simplification.

	In[1]:= Exp[2*3*#]&

	Out[1]= Exp[2 3 #1] & 

	In[2]:= Attributes[Function]

	Out[2]= {HoldAll, Protected}

This often gets in my way, though, so I simply remove the HoldAll
attribute (or in the case of Sum, I replace it with HoldRest):

	In[3]:= ClearAttributes[Function, HoldAll]

	In[4]:= Exp[2*3*#] &

	         6 #1
	Out[4]= E     & 

HTH,
Ralph

-- 
Ralph Benzinger          "This is my theory, it is mine, I own it,
Cornell University        and what it is, too." -- Ann Elk (Mrs.)


  • Prev by Date: RE: Evaluating expressions in pure functions
  • Next by Date: Re: Evaluating expressions in pure functions
  • Previous by thread: Evaluating expressions in pure functions
  • Next by thread: Re: Evaluating expressions in pure functions