Normally, we write a function like this
let abs_diff x y = abs (x-y)
also we can have a curried version:
let abs_diff = fun x -> fun y -> abs(x-y)
I write this question here just want to confirm that I understand currying correctly.
Here is my understanding:
let abs_diff = fun x -> fun y -> abs(x-y)actually returns a function with one parameter which isfun y -> abs (x-y)and inside it, x is the parameterSo, when we apply
abs_diff 5 6, it firsts takes the first argument5, returns a functionfun y -> abs (5-y), then continue to apply to argument6, so the final result is(fun y -> abs (5-y)) 6
Am I correct?
Furthermore, to deal with an function application, is OCaml interpreter like utop, ocaml doing like point 2 above?