Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

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

Search the Archive

Re: passing functions as parameters

  • To: mathgroup at
  • Subject: [mg34005] Re: [mg33988] passing functions as parameters
  • From: Sseziwa Mukasa <mukasa at>
  • Date: Fri, 26 Apr 2002 03:27:29 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

On Thursday, April 25, 2002, at 03:00 AM, GoranG wrote:

> 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","Waiting"
> )
> 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...
f[x_] := x^3-x+1

g[x_,y_,f_] := If[f[x] > f[y],"Done","Waiting"]

Will work.  Note that f can be any function ie., g[2,3,Sin] will do what 
you expect.



  • Prev by Date: Re: any package for quantum mechnics
  • Next by Date: Re: passing functions as parameters
  • Previous by thread: passing functions as parameters
  • Next by thread: Re: passing functions as parameters