基本上,F# 中的每个函数都有一个参数并返回一个值。该值可以是 unit 类型,由 () 指定,这在概念上类似于某些其他语言中的 void。
When you have a function that appears to have more than one parameter, F# treats it as several functions, each with one parameter, that are then "curried" to come up with the result you want. So, in your example, you have:
let addTwoNumbers x y = x + y
That is really two different functions. One takes x
and creates a new function that will add the value of x
to the value of the new function's parameter. The new function takes the parameter y
and returns an integer result.
So, addTwoNumbers 5 6
would indeed return 11. But, addTwoNumbers 5
is also syntactically valid and would return a function that adds 5 to its parameter. That is why add5ToNumber 6
is valid.