The problem is not new in stackoverflow, but I am not able to comprehend the behavior of let
binding with patterns and of the in
keyword.
My textbook prefers the uncommon function definition format:
let foo = fun x -> let f = (fun x y -> x +y ) in f x
So that I translated in #light syntax:
let foo x =
let f y =
x + y
f x
If I set foo 4
it returns me 8
. Why? I cannot comprehend what actually happens inside the function, even with the elegant explications from here. Why 4
becomes argument for both x
and y
?