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

Alex Popov hello at alexpopov.ca
Thu Dec 17 15:50:23 CST 2015


Data of 1: I misunderstood the second comprehension until I saw it written in
Swift, and I do know about list comprehensions from Erlang.

  

I agree that this seems to contradict "clarity over brevity".

<br  
—

Alex Popov Jr.

Principal iOS Developer | Shelfie

> On Dec 17 2015, at 12:44 pm, Amir Michail via swift-evolution &lt;swift-
evolution at swift.org&gt; wrote:  
  

>

>> On Dec 17, 2015, at 3:27 PM, Adrian Kashivskyy
&lt;[adrian.kashivskyy at me.com](mailto:adrian.kashivskyy at me.com)&gt; 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 &lt;[swift-
evolution at swift.org](mailto:swift-evolution at swift.org)&gt; 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 &lt; 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>  

>>

>>  

>

>  
![](https://u2002410.ct.sendgrid.net/wf/open?upn=CmwAv3oRa0AH4Hd1bWC6X-
2BzbhPqo1YEo6mPHEujr90sblMts0lyHPlhqzvj-2Fp-2BC5OEMkczNuE6qNGof856voE-
2BZnswBliGIoLaS-2BjycYlE0gnxN5cGJ98YQMEUtmMgZFbBpSh1ddBJSm21Gb1SvtRV0
-2BUl5I9pgd4gfaSj3QH9liTjcXY0B-2FKLe-
2BGskz0t2ZkdLzgQYgLttL6QnIT6UrERxZgyT9dQfFRCqL1CVFzAU-3D)

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


More information about the swift-evolution mailing list