MathGroup Archive 2009

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

Search the Archive

pure function with optional number of arguments

  • To: mathgroup at smc.vnet.net
  • Subject: [mg98942] pure function with optional number of arguments
  • From: Ruth Lazcoz Saez <wtplasar at lg.ehu.es>
  • Date: Wed, 22 Apr 2009 05:12:43 -0400 (EDT)

Hi,

I have two definitions for a function, one in the case it has one  
argument and another one if it has two.

Efun[x_]:=x^2
Efun[x_,y_]:=x^2+y^2

Then I want to construct a pure function that does the same thing as  
this non-pure function

myint[params__] := Integrate[z*Efun[params], {z, 0, #}] & /@ {1, 2, 3}

I tried to accomplish it with

myintpure= Function[params, Integrate[z*Efun[params], {z, 0, #}] & /@  
{1, 2, 3}],

but myintpure[x,y] gives not the same as myint[x,y], so this pure  
function I have constructed seems to be not right.

Help will be much appreciated. Thanks,

Ruth Lazkoz




  • Prev by Date: Application GUI in Mathematica
  • Next by Date: Looking for a custom control example that support dynamic arguments
  • Previous by thread: Re: Application GUI in Mathematica
  • Next by thread: Re: pure function with optional number of arguments