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
標記的參數。
我該怎麼做?