小编brz*_*ski的帖子

如何将每对中的两个元素从对列表中相乘 - Haskell

我想制作从对列表中返回每对中的乘法元素列表的函数.例如:

>product [1,2] [3,4]
[3,8]
Run Code Online (Sandbox Code Playgroud)

我想用这个来做list comprehension.我试过这样的事情:

product :: Num a => [a] -> [a] -> [a]
product xs ys = [x*y | z<-zip xs ys, (x, _)<-z, (_, y)<-z]
Run Code Online (Sandbox Code Playgroud)

但它不起作用.应该改变什么?

haskell list-comprehension

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

标签 统计

haskell ×1

list-comprehension ×1