Favorite non-python language trick?
Christopher Subich
spam.csubich+block at block.subich.spam.com
Sun Jul 3 00:39:19 EDT 2005
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.
More information about the Python-list
mailing list