0

i am trying to define a curried function which takes a function and a list of tuples as input and returns a Boolean value

for example

values(fn (x,y:int)=>(x-y) [(5,0)];
val it = true:bool

but my problem is i don't know how to pass a dynamic function as an argument.is it possible???help me out.i am a beginner.

Thanks

4

1 回答 1

0

You can pass functions as values just like any other. For example:

fun values f []      = ...
  | values f (x::xs) = ...

Then f can be used as if it were a function defined outside of the function.

As a related example, here is a function that takes an x and a list of functions [f1, f2, ..., fn] and applies each function in the list to x:

fun values x [] = []
  | values x (f::fs) = f x :: values x fs
于 2013-09-27T07:15:06.957 回答