MathGroup Archive 1998

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

Search the Archive

Re: Function as an argument to a function


myFunction[expr_, sym_Symbol:x, param_:1] := 
	expr /. sym -> param

myFunction[f[x]]

f[1]

myFunction[f[y], y, z]

f[z]

myFunction[Exp[x]]

E

myFunction[y^2+3y+7, y]

11

myFunction[y^2+3y+7, y, 2]

17

Bob Hanlon

In a message dated 8/28/98 8:25:30 AM, jlakkako at jade.hut.fi wrote:

>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??


  • Prev by Date: Re: Importing CSV (comma separated values) files?
  • Next by Date: Re: FeynArts
  • Previous by thread: Function as an argument to a function
  • Next by thread: Re: Function as an argument to a function