MathGroup Archive 2007

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

Search the Archive

Re: Function as an argument


On May 25, 3:22 am, "dXdYdZdu" <dxdyd... at gmail.com> wrote:
> Hi, I have problem. I want to do something like this:
>
> ss[x_] = 2 + x^3 ;
> MyFunction[expression_] := Module[{}, Return[expression[2]]]
> Calling MyFunction[ss] will produce 10 and this is working case.
>
> but this is what I can not do:
>
> MyFunction[2 + x^3]
>
> Is there a way to make this to work as well?

In[1]:= ss[x_] = 2 + x^3 ;

In[2]:= MyFunction[expression_] := Module[{}, Return[expression[2]]]

In[3]:= MyFunction[ss]
Out[3]= 10

In[4]:= MyFunction[2 + #^3 &]
Out[4]= 10



  • Prev by Date: Re: Antialiasing
  • Next by Date: Re: How to subtract two sets of data for a ListPlot
  • Previous by thread: Re: Function as an argument
  • Next by thread: Re: Function as an argument