On Sun, 03 Jul 2005 00:39:19 -0400, Christopher Subich wrote: > Devan L wrote: >> sum(sequence[0] + [1/element for element in sequence[1:]]) >> >> I think that should work. > > That won't work, because it misses the x*y part of the expression > (x[n]*x[n+1] + 1/x[n+1], for people who haven't immediately read the > grandparent). > > Personally, I think demanding that it be writable as a sum (or product, > or any, or all) is a false standard -- nobody's claimed that these would > replace all cases of reduce, just the most common ones.
Er, excuse me, but that is EXACTLY what Devan claimed. Quote: "With the exception of reduce(lambda x,y:x*y, sequence), reduce can be replaced with sum, and Guido wants to add a product function." -- Steven. -- http://mail.python.org/mailman/listinfo/python-list