des*_*gix 7 ocaml function infix-notation
OCaml是否支持明文定义的中缀函数?
arg1 `plus` arg2 = arg1 + arg2
Run Code Online (Sandbox Code Playgroud)
谢谢
号如在解释OCaml的手册,中缀运算符只能包含特殊字符,即!,$,%,&,*,+,-,.,/,:,<,=,>,?,@,^,|,~(或者#但仅在第一位置),不能与启动!,?或~.
要定义中缀操作,必须将符号放在括号中:
# let (+++) x y = x + 2 * y;;
...
# 3 +++ 4;;
- : int = 11
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2063 次 |
| 最近记录: |