Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

SML type of function (currying)?

$
0
0
Using ListPair.foldr I need to create a function zipWith that combines pairwise two lists. The type of the overall function should be:

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));


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>