On Tue, 11 Jul 2000, Paul Prescod wrote: > > Parallel iteration and list comprehensions are separate. I do prefer a > parallel() (merge?) builtin to the semicolon syntax, myself. You could > even define xparallel which is the lazy version (as in xrange). I like this idea. This whole parallel iteration thing could be solved with a single built-in and no syntax changes. for x, y in parallel([10, 20, 30], [1, 2]): Or "zip", since you're zipping the lists together (i foresee potential geometric or concurrency-related interpretations of "parallel"): for x, y in zip([10, 20, 30], [1, 2]): [(x, y+z), for (x, y) in zip((1, 2, 3, 4, 5, 6), "abc"), for z in "de"] Taking this all together provides one coherent solution: - zip() built-in produces a lazy list-zipper object - list-comps are written [<expr>, <clause>, <clause>, ...] where each <clause> is "for x in y" or "if z" Advantages: - no semicolons; semicolons remain solely statement separators - no possible confusion between parallel and nested iteration - comma remains the top-level separator within lists, so grouping of list-comp clauses is clear - dict-comp is possible and straightforward if we really want it - looks much prettier than map/lambda :) How's that for a serious proposal? -- ?!ng
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