0
我無法從書籍Real World OCaml運行一些代碼。代碼片段位於github。具體地講,我得到一個類型的錯誤在第6行:OCaml Core List.Assoc.find
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
注意上面代碼片段中缺少的非可選參數equal
。但是,根據最新(截至2017年6月)documentation對於List.Assoc.find
,equal
參數是可選的。
equal
參數的用途是什麼?
此代碼的工作對我來說: '讓ASSOC = [( 「一」,1); ( 「二」,2); (「three」,3)] ;;' 'List.Assoc.find assoc「two」〜equal:(=);;' –