How to implement vector sum, using functional programming in python.
This code work for n <100, but not for n > 1000.
from itertools import *
#n=10000 # do not try!!!
n=100
twin=((i,i**2,i**3) for i in xrange(1,n+1))
def sum(x=0,y=0):
return x+y
def dubsum(x,y):
return (reduce(sum,i) for i in izip(x,y) )
print [ i for i in reduce(dubsum,twin) ]