<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I believe this is the same as Scala’s for-comprehension….. and Scala’s for-comprehension is actually just syntactic sugar for a combination of flatMap, map and withFilter.<div class=""><br class=""></div><div class="">Although harder to read for many… it likely could be written similarly in Swift. &nbsp;</div><div class=""><br class=""></div><div class="">i.e.&nbsp;</div><div class=""><br class=""><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><blockquote type="cite" class=""><div class=""><div class="">for row in 0..&lt;m { for col in 0..&lt;n where row+col &lt; 5 { yield (row,col) } }</div></div></blockquote></div></div></blockquote><div class=""><br class=""></div><div class="">in Scala is</div><div class=""><br class=""></div><div class="">for {</div><div class="">&nbsp; &nbsp;row &lt;- 0 to m&nbsp;</div><div class="">&nbsp; &nbsp;col &lt;- 0 to n</div><div class="">&nbsp; &nbsp;if row+col &lt; 5</div><div class="">} yield (row, col)</div><div class=""><br class=""></div><div class="">which is actually (after the compiler is done with it):</div><div class=""><br class=""></div><div class="">(0 to m).flatMap(x =&gt; (0 to n).withFilter(y =&gt; x + y &lt; 5).map(y =&gt; (x, y)))</div><div class=""><br class=""></div><div class="">I have not tried to do it in the playground but I would expect since I believe all the functions are available in Swift.</div><div class=""><br class=""></div><div class="">Note: 0 to m // is a range in Scala</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>withFilter is a filter which does not copy the contents of what it is filtering…. it is just applying the filter as needed when mapping.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 2016-01-15, at 3:35:23, Félix Cloutier via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">This has been proposed before and Chris said that it would be out of scope for Swift 3. There is definitely interest in this area though.<br class=""><div class="">
<br class="Apple-interchange-newline"><span style="font-family: 'Lucida Grande'; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Félix</span>
</div>

<br class=""><div class=""><blockquote type="cite" class=""><div class="">Le 14 janv. 2016 à 15:30:07, Amir Michail via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; a écrit :</div><br class="Apple-interchange-newline"><div class=""><div class="">These would be like the unrolled versions of Python’s generator expressions.<br class=""><br class="">Examples:<br class=""><br class="">let a:[Int] = for x in l { yield x*2 }<br class=""><br class="">let b:[(Int,Int)] = for row in 0..&lt;m { for col in 0..&lt;n { yield (row,col) } }<br class=""><br class="">let c:[(Int,Int)] = for row in 0..&lt;m { for col in 0..&lt;n where row+col &lt; 5 { yield (row,col) } }<br class=""><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></div></blockquote></div><br class="">
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=CGU22LnxbYa2EM3wKvzuC6syQDwKa0tMs5IyT5gL1wJtVJjrHLMpZ8eCa6gc-2BmuCrCCWV1dnMWQXeaD9yuBN328bT1BNYtsQVeugjG-2BoW4TnIKcKkJgl6b2g71UfswrNjawbKl2Ea-2FDNp45okBQMZ8e7fuD67YOmoc1MG76Njm0hyYjl7UU-2F5BBoWaS-2FIgqEFkuU8D5b-2FxxTejPCsDy9yMiSH2PxC7hFkBvjXaYkuWA-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
</div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></div></body></html>