[swift-evolution] Proposal: Python's list, generator, and dictionary comprehensions

Jordan Rose jordan_rose at apple.com
Fri Dec 18 23:03:36 CST 2015


-1 from me. I find list comprehensions, on average, roughly as concise as methods on SequenceType, and generally harder to understand as soon as you have more than one collection.

Jordan

> On Dec 17, 2015, at 8:26 , Amir Michail via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Python examples:
> 
> l = [x*x for x in range(10)] // list comprehension
> 
> l2 = [(x,y) for x in range(10) for y in range(10) if x + y < 8] // another list comprehension
> 
> g = (x*x for x in range(10)) // generator comprehension
> 
> d = {x:x*x for x in range(10)} // dictionary comprehension
> 
> 
> I think most programmers would like using these. They are concise and easy to understand.
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list