2014-02-05 40 views
0

你好,我是Ocaml的新手,我正在嘗試使用List和list.map。所以我寫了一個函數幫助器,它需要一個列表並創建一個列表列表。Ocaml 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

你需要()helper [1;2;3]

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

這將刪除錯誤。