> > sum([lazy x*x for x in sequence]) > > I like this the best of suggestions so far. Easy to understand, easy > to teach: > [lazy ...] = iter([...]) but produced more efficiently -1. An iterator is not a lazy list. A lazy list would support indexing, slicing, etc. while calculating its items on demand. An iterator is inherently sequential and single-use -- a different concept. But maybe some other keyword could be added to ease any syntactic problems, such as "all" or "every": sum(all x*x for x in xlist) sum(every x*x for x in xlist) The presence of the extra keyword would then distinguish an iterator comprehension from the innards of a list comprehension. Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+
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