【发布时间】:2017-06-05 16:39:07
【问题描述】:
我在运行 Real World OCaml 一书中的一些代码时遇到了问题。代码 sn-p 在github 上。特别是,我在第 6 行遇到类型错误:
List.Assoc.find counts line
我使用的是 OCaml 4.04.1,根据 utop,List.Assoc.find 的类型签名是:
('a, 'b) List.Assoc.t -> equal:('a -> 'a -> bool) -> 'a -> 'b option =
<fun
请注意上面的代码 sn-p 中缺少的非可选参数 equal。但是,根据最新的(截至 2017 年 6 月)documentation for List.Assoc.find,equal 参数是可选的。
equal 参数的用途是什么?
【问题讨论】:
标签: ocaml