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