zip与模拟Python? [英] zipWith analogue in Python?
本文介绍了zip与模拟Python?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Haskell的模拟 zipWith 功能?
zipWith ::(a - > b - > c) - > [a] - > [b] - > [c]
解决方案
,但是在Python中,我们大多做的是
list_c = [f(a,b)for zip(list_a因为Python不具有内在的功能性,所以我们可以将它们作为一个单独的函数来使用。它恰好支持一些便利的成语。
What is the analogue of Haskell's zipWith function in Python?
zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]
解决方案 You can create yours, if you wish, but in Python we mostly do
list_c = [ f(a,b) for (a,b) in zip(list_a,list_b) ]
as Python is not inherently functional. It just happens to support a few convenience idioms.
这篇关于zip与模拟Python?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文