Re: Is it possible to "pre-evaluate" parts of pure function?
- To: mathgroup at smc.vnet.net
- Subject: [mg70398] Re: Is it possible to "pre-evaluate" parts of pure function?
- From: Roland Franzius <roland.franzius at uos.de>
- Date: Sun, 15 Oct 2006 00:19:40 -0400 (EDT)
- Organization: Universitaet Hannover
- References: <egi22b$jd9$1@smc.vnet.net> <egn94d$1d9$1@smc.vnet.net>
Philpp schrieb:
> Thanks a lot for all answers (including emails). I suppose the correct
> solution
>
> SetOptions[f, MultiplierFunction -> (Evaluate[const #] &)]
>
> escaped me due to my lack of understanding of the pure function (body)&
> syntax. As Jon McLoone points out, "the Evaluate needs to be on the
> argument of Function not around the outside of it"
An easy solution for problems of this kind is always
f=Function@@{expression containing # and named symbols with values to be
used at definition time}
Using this definition the expression with Slot[] is evaluated first and
becomes a function then using Apply. For functions with named arguments
it works too.
f=Function@@{{x,y},expression containing x,y }
You only have to be cautious in order to avoid symbols you don't want to
get evaluated at definition time.
--
Roland Franzius
Roland Franzius