0
我要比较两个哈希表的平等:OCaml的 - 两个哈希表的平等和函数嵌套标记参数
open Core.Std
let hashtables_equal (x_tbl: ('a, 'b) Hashtbl.t) (y_tbl: ('a, 'b) Hashtbl.t) : bool =
(Hashtbl.length x_tbl = Hashtbl.length y_tbl)
&& Hashtbl.for_alli x_tbl ~f:(fun ~key ~data -> Hashtbl.existsi y_tbl ~f:(fun ~k ~d -> k = key && d = data))
在for_alli
功能f
和existsi
有两个标记参数~key
和~data
。
上面的代码由于使用了不正确的标签而无法编译。但是,我想在嵌套函数中引用~key
和~data
标记的参数。
我该怎么做?