MathGroup Archive 1998

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

Search the Archive

Re: Function as an argument to a function


Jani Eerikki Lakkakorpi wrote:
> 
> Hello,
> 
> I want to pass a function as an argument to a function I am developing.
> For example: Myfunction[Exp[x]]
> 
> I would like Myfunction to return the value of it's parameter function
> when (for example) x=1.
> 
> Here's what I have tried:
> 
> Myfunction[f_] :=
>         f[1]
> 
> Doesn't work. Any suggestions??

You are nearly there:

In[1]:= MyFunction[f_]:=f&[1]

In[2]:= MyFunction[Exp[#]]

Out[2]= E

In[3]:= MyFunction[(#+1)^2]

Out[3]= 4

Tobias


  • Prev by Date: Re: Disappearing variables
  • Next by Date: Re: Defining differential operators question
  • Previous by thread: Re: Function as an argument to a function
  • Next by thread: Re: Function as an argument to a function