> Most of us seem to agree that having list comprehensions > available as a replacement for map() and filter() is a good > thing. But what about reduce()? Are there equally strong > reasons for wanting an alternative to that, too? If not, > why not? If anything, the desire there is *more* pressing. Except for operator.add, expressions involving reduce() are notoriously hard to understand (except to experienced APL or Scheme hackers :-). Things like sum, max, average etc. are expressed very elegantly with iterator comprehensions. I think the question is more one of frequency of use. List comps have nothing over e.g. result = [] for x in S: result.append(x**2) except compactness of exprssion. How frequent is result = 0.0 for x in S: result += x**2 ??? (I've already said my -1 about your 'sum of ...' proposal.) --Guido van Rossum (home page: http://www.python.org/~guido/)
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