Re: Function as an argument to a function
- To: mathgroup at smc.vnet.net
- Subject: [mg13838] Re: Function as an argument to a function
- From: Tobias Oed <tobias at physics.odu.edu>
- Date: Sat, 29 Aug 1998 04:41:15 -0400
- Organization: Old Dominion University
- References: <6s5msa$ccu@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
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