OCaml 错误未绑定值 List.unzip

OCaml Error Unbound value List.unzip

知道为什么会出现此错误:

utop # let (ints,strings) = List.unzip [(1,"one"); (2,"two"); (3,"three")];;
Error: Unbound value List.unzip 

标准库中没有List.unzip
我猜你正在寻找 List.split:

# let (ints,strings) = List.split [(1,"one"); (2,"two"); (3,"three")];;
val ints : int list = [1; 2; 3]
val strings : string list = ["one"; "two"; "three"]

注意:OCaml-Core 中有一个List.unzip函数。如果你正在使用它,你可能没有打开相应的模块。

List.unzip在Base库中提供,需要安装