Ocaml 如何使用Jane Core对列表进行排序?

Ocaml 如何使用Jane Core对列表进行排序?,ocaml,ocaml-core,Ocaml,Ocaml Core,我正在努力做到这一点 open Core let%test _ = List.sort ~cmp:Int.compare [1;2;3] = [1;2;3] 但它失败了 61 | let%test _ = List.sort ~cmp:Int.compare [1;2;3] = [1;2;3] ^^^^^^^^^^^ Error: The function applied to this argument has type

我正在努力做到这一点

open Core
let%test _ = List.sort ~cmp:Int.compare [1;2;3] = [1;2;3]
但它失败了

61 | let%test _ = List.sort ~cmp:Int.compare [1;2;3] = [1;2;3]
                                 ^^^^^^^^^^^
Error: The function applied to this argument has type
         compare:('a -> 'a -> int) -> 'a list
This argument cannot be applied with label ~cmp
好吧,我知道了。问题是谷歌搜索ocaml核心列表会让我找到过时的文档。标签名为~compare

所以这是有效的

let%test _ = List.sort ~compare:Int.compare [1;2;3] = [1;2;3]

最新文档:这可能不是您正在搜索的,您可以在

上找到其他版本。Janestreet Core library正在随时间改变其界面。关键字参数的旧名称为cmp,并已更改为与库的其他部分进行一致性比较

 let%test _ = List.sort ~compare:Int.compare [1;2;3] = [1;2;3]
最新文件: 可以在此处找到旧版本: 这可能不是您要搜索的,您可以在
您可能希望将您的编辑移动到一个自我回答,以供将来的读者阅读。我已将您自己的回答稍微改写为一个正确的答案,以便so的其他用户也可以从中受益。