Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ocaml _int-3的float_是如何计算的?_Ocaml - Fatal编程技术网

Ocaml _int-3的float_是如何计算的?

Ocaml _int-3的float_是如何计算的?,ocaml,Ocaml,我认为函数应用程序具有最高的优先级,因此float\u of_int-3等于float\u of_int(-3)。为什么我需要显式地将括号放在那里以抑制错误?正是因为这个原因,函数应用程序的优先级高于中缀运算符,所以必须添加括号 换句话说,函数应用程序是贪婪的,它将使用所有项,直到它到达中缀运算符,例如 # float_of_int -3;; Error: This expression has type int -> float but an expression was

我认为函数应用程序具有最高的优先级,因此
float\u of_int-3
等于
float\u of_int(-3)
。为什么我需要显式地将括号放在那里以抑制错误?

正是因为这个原因,函数应用程序的优先级高于中缀运算符,所以必须添加括号

换句话说,函数应用程序是贪婪的,它将使用所有项,直到它到达中缀运算符,例如

# float_of_int -3;;
Error: This expression has type int -> float
       but an expression was expected of type int
被解析为
(fxyz)+(gpqr)

你的例子也是如此

 f x y z + g p q r
被解析为

 float_of_int - 3
另一种选择是使用特殊的前缀运算符
~-
,例如

(float_of_int) - (3)
比函数应用程序的绑定更紧密

float_of_int ~-1