Using ListPair.foldr I need to create a function zipWith that combines pairwise two lists. The type of the overall function should be:
My attempt:
zipWith : ('a * 'b -> 'c) -> 'a list -> 'b list -> 'c list
ListPair.foldr : ('a * 'b * 'c -> 'c) -> 'c -> 'a list * 'b list -> 'c
- zipWith (fn (x, y) => x + y) [1,2,3,4] [10,20,30,40];
val it = [11,22,33,44] : int list
My attempt:
fun zipWith f [] [] = [] | ListPair.foldr f (x::xs) (y::ys) = f(x,(zipWith f ys d));