I went back to coding in OCaml and I missed it so much. I missed it so that I completely lost my reasoning in this language, and today I hit the wall.
What I want to do is a combination of elements between a set of n lists. I decomposed the problem by first trying to merge the elements between two lists of arbitrary sizes.
Suppose we have lists: l1 = [1;2;3]and l2 = [10,20].
What I want to do is get the following list:
l_res = [10;20;20;40;30;60]
I know how to do this using loop structures, but I really want to solve this without them.
I tried the following:
let f l1 l2 =
List.map (fun y -> (List.map (fun x -> x * y) l1) l2
But this does not seem to work. The type that I get is f : int list -> int list -> int list list, but I wantf : int list -> int list -> int list
I have tried many different approaches already, I feel that I am complicating.
What did I miss?