The notation for functions of several arguments is a bit different in OCaml and in mathematics, which could be the cause of a little confusion here.
In OCaml the function notation makes it easy to partially apply functions. For instance we can write something like
# let add x y = x + y;;
val add : int -> int -> int = <fun>
(* The addition of integers as we know it. *)
and specialise the first argument x to a 1, to define the successor operation:
# let successor = add 1;;
val successor : int -> int = <fun>
(* successor y is equivalent to add 1 x *)
so that we can try
# successor 2;;
- : int = 3
Note that in OCaml the function add we defined above is a different function than the function
# let add' (x, y) = x + y;;
val add' : int * int -> int = <fun>
See how the signature differs. In mathematics, we usually do not need to emphasise the difference and hence identify the two functions. The add' function is, from OCaml perspective, a function of one argument, which is a pair.
In your analysis, you correctly state that f is a function of two arguments, x and y. It does not actually depend on the value of x, since the identifier x does not appear right to the equal sign in let f x = …. Instead for any value of x, f x returns the function defined by
function
| 0 -> 0
| y -> 1
So any of the expressions f (), f "whatever", f 0, f 7, f (0, 1) will evaluate to the function
function
| 0 -> 0
| y -> 1
(In these expressions x is bound to () or "whatever" or 0 or 7 or (0, 1) but that specific value does not participate to the actual computation of f x.)
We can try this out:
# let f x = function
| 0 -> 0
| y -> 1;;
val f : 'a -> int -> int = <fun>
# f ();;
- : int -> int = <fun>
# f "whatever";;
- : int -> int = <fun>
# f 0;;
- : int -> int = <fun>
# f 7;;
- : int -> int = <fun>
# f (0, 1);;
- : int -> int = <fun>
If we add a second argument, this will actually return a 0 or a 1 according to that function definition:
# f () 0;;
- : int = 0
# f () 11;;
- : int = 1
# f (0,1) 0;;
- : int = 0
# f (0,1) 11;;
- : int = 1
(* etc. *)
We can also use parenthesis to emphasise how OCaml is actually reading these expressions
# (f ()) 0;;
- : int = 0
# (f (0,1)) 11;;
- : int = 1