Question: Ocaml TODO: Write a zip function that takes two lists of integers and combines them into a list of pairs of ints If the two
Ocaml
TODO: Write a zip function that takes two lists of integers and combines them into a list of pairs of ints If the two input list are of unequal lengths, combine as long as possible your method should be tail recursive.
For example, zip_int [1;2;3;5] [6;7;8;9] = [(1,6);(2,7);(3,8);(5,9)] zip_int [1] [2;4;6;8] = [(1,2)] zip_int (between 0 1000000) (between 0 1000000) does not stack overflow
(* TODO: Write a zip function that takes two lists of integers and combines them into a list of pairs of ints If the two input list are of unequal lengths, combine as long as possible your method should be tail recursive. For example, zip_int [1;2;3;5] [6;7;8;9] = [(1,6);(2,7);(3,8);(5,9)] zip_int [1] [2; 4; 6;8] [(1,2)) zip_int (between 0 1000000) (between 0 1000000) does not stack overflow *) let zip_int (a: int list) (b: int list): (int * int) list = ||
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
