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

Amir Michail a.michail at me.com
Thu Dec 17 14:44:02 CST 2015


> On Dec 17, 2015, at 3:27 PM, Adrian Kashivskyy <adrian.kashivskyy at me.com> wrote:
> 
> Amir, your proposal contradicts "clarity over brevity" principle. As pointed by Liam all those things are fairly easy to do without any major complexity.
> 

I think the comprehensions are very clear though.

> Pozdrawiam – Regards,
> Adrian Kashivskyy
> 
>> Wiadomość napisana przez Amir Michail via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> w dniu 17.12.2015, o godz. 17:26:
>> 
>> 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 <mailto:swift-evolution at swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151217/6d8febcc/attachment.html>


More information about the swift-evolution mailing list