gpt4 book ai didi

python - zipWith Python中的模拟?

转载 作者:IT老高 更新时间:2023-10-28 20:32:34 26 4
gpt4 key购买 nike

Haskell 的 zipWith 的类似物是什么? Python 中的函数?

zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]

最佳答案

map()

map(operator.add, [1, 2, 3], [3, 2, 1])

虽然通常使用带有 zip() 的 LC。

[x + y for (x, y) in zip([1, 2, 3], [3, 2, 1])]

关于python - zipWith Python中的模拟?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9766608/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com