MathGroup Archive 2002

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

Search the Archive

Re: passing functions as parameters

  • To: mathgroup at smc.vnet.net
  • Subject: [mg34035] Re: passing functions as parameters
  • From: GoranG <icmc2MAKNUTIOVO at pop.tel.hr>
  • Date: Sat, 27 Apr 2002 00:56:50 -0400 (EDT)
  • Organization: HThinet
  • References: <aab113$mgj$1@smc.vnet.net>
  • Reply-to: icmc2MAKNUTIOVO at pop.tel.hr
  • Sender: owner-wri-mathgroup at wolfram.com

On Fri, 26 Apr 2002 07:53:07 +0000 (UTC), "DrBob"
<majort at cox-internet.com> wrote:

Thank you for your effort, it helped me realize that my original
example works as well. 
And I almost started to change the whole approach.

Anyway, sorry for wasting your time and thank you for setting me back
to the right track.

>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: [mg34035]  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...
>
>
>
>



  • Prev by Date: RE: Getting File Directory Using Any Platform
  • Next by Date: Re: Getting File Directory Using Any Platform
  • Previous by thread: RE: passing functions as parameters
  • Next by thread: Definite Integrals & Hidden Cells