On Thursday, October 16, 2003, at 05:00 AM, Alex Martelli wrote: > Why not move the for loop, if needed, out of the hard-coded > infrastructure and just have accumulator display syntax such as: > acc[x*x for x in it] > be exactly equivalent to: > a = acc.__accum__(lambda x: x*x, iter(it)) > return a.result() > i.e., pass the callable corresponding to the expression, and the > iterator corresponding to the sequence, to the user-coded > accumulator. Seems simpler if you could get an iterator for [x*x for x in it] that returned (x*x, x), then call acc.__accum__(that_iter). I suppose for some accumulators you could sometimes avoid calling the expression, but that doesn't seem like a big feature. It seems like it complicates the semantics that you have to turn the list comprehension's expression into a function, where (I imagine) it doesn't get turned into a real function otherwise, but is executed without a new scope. -- Ian Bicking | ianb at colorstudy.com | http://blog.ianbicking.org
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