I'm learning OCaml (OCaml 5.0.0).
I defined the function below.
let make_pair x ls = List.map (fun y -> (x,y)) ls;;
I expected make_pair 1 ["a","b"];;
returns [(1,"a");(1,"b")]
, but actually the function returns (int * (string * string)) list = [(1, ("a", "b"))]
.
How do I solve the issue?
You entered ["a","b"]
, which is a list consisting of a single pair, ("a","b")
. You need a semicolon instead of a comma: ["a";"b"]
.