【发布时间】:2015-07-06 16:14:27
【问题描述】:
到目前为止我有:
miZipWith f [] [] = []
miZipWith f (x:xs) [] = []
miZipWith f [] (y:ys) = []
miZipWith f (x:xs) (y:ys) = f y: miZipWith f xs ys
----miZipWith f (x:xs) (y:ys) = f x : f y : miZipWith f xs ys
但这只会将函数 f 与第二个列表“压缩”。我如何也包含第一个列表?
*Main> miZipWith (*2) [1,2,3,4] [5,6,1]
[10,12,2]
【问题讨论】:
-
你缺少的是
f的类型是(a -> b -> c)
标签: list function haskell recursion