小编use*_*042的帖子

如何在Haskell中创建递归zipWith函数?

到目前为止,我有:

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
Run Code Online (Sandbox Code Playgroud)

但这只是用第二个列表"拉上"函数f.我如何包含第一个列表?

*Main> miZipWith (*2) [1,2,3,4] [5,6,1]
[10,12,2]
Run Code Online (Sandbox Code Playgroud)

recursion haskell function list

0
推荐指数
1
解决办法
662
查看次数

标签 统计

function ×1

haskell ×1

list ×1

recursion ×1