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

Thu Dec 17 15:52:25 CST 2015

```Yup, I thought it zips them (creates pairs of (1, 1), (2, 2), (3, 3), etc.).

Pozdrawiam – Regards,

> Wiadomość napisana przez Alex Popov via swift-evolution <swift-evolution at swift.org> w dniu 17.12.2015, o godz. 22:50:
>
> 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".
>
>
> —
> Alex Popov Jr.
> Principal iOS Developer | Shelfie
>
>
> On Dec 17 2015, at 12:44 pm, Amir Michail via swift-evolution <swift-evolution at swift.org> wrote:
>
>> On Dec 17, 2015, at 3:27 PM, Adrian Kashivskyy <adrian.kashivskyy at me.com <mailto: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,
>>
>>> 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 <https://lists.swift.org/mailman/listinfo/swift-evolution>
>>
>
>
>
> _______________________________________________
> swift-evolution mailing list
> 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/63e2f745/attachment.html>
```