As a beginner in OCaml, I'm trying to write a function who takes two int arguments (a and b), and should return a list which contains all tuples (i,j) where i is between 0 and a, and j is between 0 and b, order doesn't matter. The function should be like this : myfunc: int -> int -> (int*int) list And result must be something like [(0,1);(0,2)]...
I already wrote a function who takes two int argument and return a list between those two. For example, 1 and 5 give me this list : [1;2;3;4;5]. This is what i've done :
let rec btwn = fun a b -> if a>b then []
else if a = b then [a]
else a :: btwn (a+1) b ;;
My idea was to reuse this function, and create two list : one list with the range 0 ; a and one another with the range 0 ; b, and then making all tuples with these two lists. I've heard of List.fold_left/right, List.map but I can't get it work... Do you have any ideas ? Thanks!