[swift-evolution] Extending the for loop to have multiple clauses

Al Skipp al_skipp at fastmail.fm
Wed Dec 9 15:42:55 CST 2015

I like this idea, but would certainly prefer it to be an expression (your alternative suggestion, array comprehension) rather than a statement. Your example of building an array of tuples [(suit, rank)] could then be achieved without having to append to a var during iteration.

> Yes, it’d be great if you can combine it with where. Alternatively, it could be interesting to instead explore array comprehension syntax, rather than making `for` smarter. That’d allow for a more functional style. For example, Norvig’s spelling corrector (http://norvig.com/spell-correct.html <http://norvig.com/spell-correct.html>) would then be very straightforward to port.
> Re the x operator: it’s even easier if you define it with flatMap. However, the for syntax is different, because the second clause can depend on the first...
> Chris

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

More information about the swift-evolution mailing list