I really dislike the proposed way to do this. If this is "Swifty", give me something else.<p>The Haskell list comprehension made sense to me the first time I saw it, but there is no way I'd know what the mess in the article was doing until someone explained to me.<p>Design has to come first. You can't just go with what's "Swifty" if that doesn't convey what's happening in a reasonable fashion.
<i>List</i> comprehension is a bad idea, IMO. They were an improvement over not having anything like it, but python has improved over it (<a href="https://wiki.python.org/moin/Generators" rel="nofollow">https://wiki.python.org/moin/Generators</a>)<p>⇒ <i>Generator expressions</i> are the way to go. They would give you the sequence of elements without generating the (potentially enormous) data structure.<p>From there, methods to reify the items in a sequence would give you your list, array, or dictionary, where needed.<p>So, for Swift, I wouldn’t use<p><pre><code> Array(1..<5, 3..<5) { ($0, $1) }
</code></pre>
but the slightly longer<p><pre><code> Array(for i in 1..<5, j in 3..<5 yield (i,j))
</code></pre>
I’m not sure that is easy to fit in the existing parser, though. If it can be fit in, I would allow that code in ‘normal’ nested for loops, too.