If I have an input of a tuple containing two lists of integers of the same length, and I want my output to be a list of these two lists zipped, after extracting these two lists from the tuple how do I zip each individual element into one list? For example, if my input is twolists= ([1;2;3], [4;5;6]), then I want my output to be [(1,4); (2,5); (3,6)]. How do I zip each element and add it to my output? The function name and type is as follows:
let rec pairlists twolists = ...val pairlists : 'a list * 'b list -> ('a * 'b) list = fun
So far I have:
let rec pairlists twolists = let (l1, l2) = twolists in let rec zip (l1,l2) = match l1 with |[] -> l2 |x :: xs -> x :: zip(l2, xs) in twolists ;;
but this is clearly not doing what I want.