小编R. *_*nks的帖子

在Haskell中写Zipwith

我正在尝试Zipwith在Haskell中编写该函数.

如果我使用以下值运行它,它应该返回以下结果:

Prelude> zipWith (+) [10,20,30] [33,44,94]
[43,64,124]
Run Code Online (Sandbox Code Playgroud)

到目前为止我的代码是:

Zipwith f [] [] = []
Zipwith f [] _ = []
Zipwith f _ [] = []
Zipwith f (x:xs) (y:ys) = (f x y) : (Zipwith f xs ys)
Run Code Online (Sandbox Code Playgroud)

但是,编译器告诉我,我有多个函数,all Zipwith,没有数据定义,但我认为在Haskell中没有必要.此外,它说我有f的多个声明,但它只是一个参数,我认为参数有多个定义并不重要.

有什么想法吗?

haskell

3
推荐指数
2
解决办法
2118
查看次数

标签 统计

haskell ×1