MathGroup Archive 2001

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

Search the Archive

Re: Evaluating expressions in pure functions


Max,
Here are some techniques:

Evaluate/@(Exp[2*3*#]&)

        E^(6*#1) &

{2*3+4,#}&/.x_Times:>RuleCondition[x]

        {6+5,#1}&

{2*3+4*5,#}&/.x_Times:>RuleCondition[x]

        {6+20,#1}&

[
(!) But note that RuleCondition is an internal symbol and is barely
documented:

?RuleCondition

        RuleCondition is an internal symbol.

RuleCondition[a] is equivalent to RuleCondition[a,True]
]

To avoid evaluationg both the products, we can use

ReplacePart[{2*3+4*5, #}&,{2*3+3*4, #}&[[1,1,1]], {1,1,1}]

        {6+4 5,#1}&

--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

"Max Ulbrich" <ulbrich at biochem.mpg.de> wrote in message
news:9bm576$j3j at smc.vnet.net...
> Hi,
>
> I have the following problem:
> 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?
> Thanks,
>
> Max
>
>




  • Prev by Date: Re: plotting question
  • Next by Date: AW: Rearrangement of a sequence into random order
  • Previous by thread: Re: Evaluating expressions in pure functions
  • Next by thread: Re: Evaluating expressions in pure functions