Ocaml 的atan2 -2。 3. 不解析

问题描述 投票:0回答:1

在 ocaml 中对负浮点数使用 atan2 时出现解析错误

# atan2 -2. 3. ;;

Line 1, characters 0-5:
Error: This expression has type float -> float -> float
but an expression was expected of type int

我必须使用

atan2 (-2.) 3.
为什么ocaml不能正确解析
-2.

ocaml
1个回答
1
投票

在 OCaml 中,空格在标记化之外并不重要。此外,

-
始终被视为单独的标记。换句话说,

atan2 -2.

被解析为

atan2 - 2.

确实是类型错误。

© www.soinside.com 2019 - 2024. All rights reserved.