Vir*_*ile 7

号如在解释OCaml的手册,中缀运算符只能包含特殊字符,即!,$,%,&,*,+,-,.,/,:,<,=,>,?,@,^,|,~(或者#但仅在第一位置),不能与启动!,?~.

要定义中缀操作,必须将符号放在括号中:

# let (+++) x y = x + 2 * y;;
...
# 3 +++ 4;;

- : int = 11
Run Code Online (Sandbox Code Playgroud)