Ocaml list.map错误此函数适用于太多参数

时间:2014-02-05 16:22:54

标签: ocaml

您好我是Ocaml的新手,我正在尝试使用List和list.map。所以我写了一个函数助手,它接受一个列表并创建一个列表列表。

let rec helper l= 
  match l with 
  | []->[[]]
  | x::xs -> [x]::helper xs;;

现在,当我尝试使用list.map连接到此列表列表的每个成员时,我收到错误。

List.map(fun y->[1]@y) helper [1;2;3];;

Error: This function is applied to too many arguments; maybe you forgot a;'`

我无法理解为什么会出现此错误。任何帮助将不胜感激。

谢谢

1 个答案:

答案 0 :(得分:1)

()

需要helper [1;2;3]

即,List.map(fun y->[1]@y) (helper [1;2;3])

这将删除错误。

相关问题