Reputation: 11
Hello I am new to Ocaml and I am trying to play around with List and list.map. So I write a function helper which takes a list and creates a list of lists.
let rec helper l=
match l with
| []->[[]]
| x::xs -> [x]::helper xs;;
Now when i try to use list.map to concatenate to each member of this list of list i get an error.
List.map(fun y->[1]@y) helper [1;2;3];;
Error: This function is applied to too many arguments;
maybe you forgot a
;'`
I am unable to understand why is this error causes. Any help would be appreciated.
Thank you
Upvotes: 1
Views: 734
Reputation: 25812
You need ()
for helper [1;2;3]
i.e., List.map(fun y->[1]@y) (helper [1;2;3])
.
This will remove the error.
Upvotes: 1