Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let zip (xs, ys) =
- List.rev( snd (List.fold_left (fun (tail_of_ys, list_of_pairs) hx -> match tail_of_ys with
- | h::t -> (t, (hx, h)::list_of_pairs)
- | [] -> ([], list_of_pairs)
- ) (ys, []) xs));;
- zip( ['a';'b';'c';'d'] ,['a';'b';'c';'d']);; (*xs.length = ys.length*)
- zip( [1;2;3] ,['a';'b';'c';'d']);; (*xs.length < ys.length*)
- zip( [1;2;3;4;5;6;7;8;9;10] ,['a';'b';'c';'d']);; (*xs.length > ys.length*)
- zip([], [1;2;3;45]);; (*xs.length = 0*)
- zip(['a';'b';'c';'d'], [1]); (*ys.length = 0*)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement