I have been trying to understand Higher Order Functions in SML. I know how to write simple higher order functions and also understand the signature. One example is:
fun increment list = map (fn x=> x + 1) list;
val it = fn: int list -> int list
However, I cannot understand the signature of the following higher order function:
fun add x y = x + y;
val add = fn: int -> int -> int
The function could be written as:
fun add (x,y) = x+y;
val add: fn : (int * int) -> int
which I understand. But in the previous function, I fail to understand how the order of operations work. Does the function take two parameters at once, or does it take one at a time producing a new function which then produces the required result? How would it work for any other higher order function?
I need to build the concept about the signature of higher order functions for my homework as well as my exams coming up in a few weeks.