>>>>> "AM" == Alex Martelli <aleax@aleax.it> writes: [summing a sequence] AM> Now, I think the obvious approach would be to have a function AM> sum, callable with any non-empty homogeneous sequence AM> (sequence of items such that + can apply between them), AM> returning the sequence's summation -- now THAT might help for AM> simplicity, clarity AND power. FWIW, Numeric provides a sum function that mostly does what you want: >>> from Numeric import * >>> sum(range(999)) 498501 >>> sum(['a', 'b', 'c']) 'abc' # this one produces a slightly surprising result >>> sum(['aaa', 'b', 'c']) array([abc , a , a ],'O') # but is easily explained in the context of multi-dimensional arrays. Anyway, my point is most Numeric users are already comfortable with the idea of a sum function. However, as someone already said, if you argue that sum is necessary, what about product (which again Numeric provides along with a host of other useful functions)? cheers, prabhu
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4