# let rec nth l n =
match l with
[] -> []
|h::t -> if n = 0 then h
else nth t (n-1);;
val nth : 'a list list -> int -> 'a list = <fun>
# let rec drop n l =
if n = 0 then l else
match l with
[] -> []
|h::t -> drop (n-1) t;;
val drop : int -> 'a list -> 'a list = <fun>
# let rec zipper a b =
match a with
[] -> b
|h::t -> h :: nth b 0 :: zipper t (drop 1 b);;
val zipper : 'a list list -> 'a list list -> 'a list list = <fun>
# zipper [1;3;5] [2;4;6];;
Characters 8-9:
zipper [1;3;5] [2;4;6];;
^
Error: This expression has type int but an expression was expected of type
'a list
I was trying to combine two lists together. Each step seemed ok but when I typed the last sentence zipper [1;3;5] [2;4;6] the error emerged.
I learned type 'a in 'a list can be any type in Ocaml. Then, the expression type int is ok I thought.. I don't know whats wrong