I have a function called zip_with_2_fs. I am trying to make it tail recursive (zip_with_2_fs_tr) but I don't really understand what I am doing. I am new to Ocaml and would like to develop a deeper understanding of tail recursion and helper functions.
let rec zip_with_2_fs fx fy xs ys = match (xs, ys) with | ([], []) -> [] | ([], _) -> [] | (_, []) -> [] | (xh::xt, yh::yt) -> (fx xh, fy yh)::zip_with_2_fs fx fy xt yt;;
How would I go about fixing this?
let zip_with_2_fs_tr fx fy xs ys = let rec helper fxx fy xss yss = match (xs, ys) with | ([], []) -> [] | ([], _) -> [] | (_, []) -> [] | (xh::xt, yh::yt) -> (fx xh, fy yh)::helper fx fy xt yt in helper fx fy xs ys;;