RE: passing functions as parameters
- To: mathgroup at smc.vnet.net
- Subject: [mg34019] RE: [mg33988] passing functions as parameters
- From: "DrBob" <majort at cox-internet.com>
- Date: Fri, 26 Apr 2002 03:28:03 -0400 (EDT)
- Reply-to: <drbob at bigfoot.com>
- Sender: owner-wri-mathgroup at wolfram.com
How's this? f[x_]:=x^3-x+1 g[x_,y_,s_]:=Which[ Or[x==y,s[x]==s[y]],"Unknown", Xor[s[x]>s[y],x>y],"Decreasing", True,"Increasing" ] g[2,3,f] g[2,3,-#&] g[2,2,f] g[2,-2,#^2&] "Increasing" "Decreasing" "Unknown" "Unknown" Bobby Treat -----Original Message----- From: GoranG [mailto:icmc2MAKNUTIOVO at pop.tel.hr] To: mathgroup at smc.vnet.net Subject: [mg34019] [mg33988] passing functions as parameters How would one pass one function to another? I need to be able to define functions in the following fashion: f[x_]:=x^3-x+1 g[x_,y_,somefunction?]:=If[somefunction[x]>somefunction[y],"Done","Waiti ng") to be able to later on evaluate g[2.,3., f?] I have tried couple of paths with no success and would really like to avoid using global function in function g. All the best...