0

我经常有类似于以下内容(树的标准类型定义):

match tree with
    | Branch(v, Branch(vl, tll, tlr), _) = f Branch(vl, tll, tlr)

在其他语言中,可以执行以下操作:

match tree with
    | Branch(v, tl@Branch(_, _, _), _) = f tl

OCaml 有类似的东西吗?

4

1 回答 1

1

This is done using the as keyword in OCaml:

match tree with
| Branch(v, (Branch(_, _, _) as tl), _) = f tl
于 2018-11-11T18:16:19.843 回答