I have seen some implementation as follows:
let rec fact =
fun n ->
if n <= 0 then 1 else n * fact (n - 1)
Another implementation is:
let rec fact n =
if n <= 0 then 1 else n * fact (n - 1)
Could anyone tell me if there is any difference between these 2 styles?
These definitions are equivalent. The notation
is a handy way of writing (syntactic sugar for):
You can find this described in section 6.7.1 of the OCaml manual, under the heading Local definitions.