我在code.google.com上阅读了关于模式保护的内容,其中显示了这种类型的警卫:
match x with
| pat with g = y -> z
| ...
| pat with g = y -> z
Run Code Online (Sandbox Code Playgroud)
然而,在OCaml 4.02中,似乎没有工作(Syntax error: pattern expected.),所以问题是:在模式匹配中有一种解决方法可以实现这种绑定吗?我想写那样的东西
match something with
| value with y = f x when y > 0 -> value + y
Run Code Online (Sandbox Code Playgroud)
在此先感谢,欢呼.
ocaml functional-programming pattern-matching pattern-guards