Re:Python iteration
by Lycanthrope on Wednesday April 25, 2012 @04:23PM
(#3890872)
You can use map with several iterables:
sum(map(operator.mul, [1,2,3], [3,2,1]))
You are given two vectors v1=(x1,x2,...,xn) and v2=(y1,y2,...,yn). The scalar product of these vectors is a single number, calculated as x1y1+x2y2+...+xnyn.
Haskell:
Python is not inherently functional, just supports a few convenience idioms. It has zip, but no zipWith. As a result you have to use list comprehension to perform the same: