<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 19, 2015, at 11:44 AM, Donnacha Oisín Kidney via swift-dev &lt;<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: AvenirNext-Regular; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">You can define an extension on interval types:</span><div class="" style="font-family: AvenirNext-Regular; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: AvenirNext-Regular; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(187, 44, 162);">extension</span><span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(112, 61, 170);">HalfOpenInterval</span><span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(187, 44, 162);">where</span><span class="Apple-converted-space">&nbsp;</span>Bound: Strideable {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170);"><span class="" style="">&nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="color: rgb(187, 44, 162);">func</span><span class="" style=""><span class="Apple-converted-space">&nbsp;</span>by(n:<span class="Apple-converted-space">&nbsp;</span></span>Bound<span class="" style="">.</span>Stride<span class="" style="">) -&gt;<span class="Apple-converted-space">&nbsp;</span></span>StrideTo<span class="" style="">&lt;</span>Bound<span class="" style="">&gt; {</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(187, 44, 162);">return</span><span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(112, 61, 170);">start</span>.<span class="" style="color: rgb(61, 29, 129);">stride</span>(to:<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(112, 61, 170);">end</span>, by: n)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">}</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(187, 44, 162);">extension</span><span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(112, 61, 170);">ClosedInterval</span><span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(187, 44, 162);">where</span><span class="Apple-converted-space">&nbsp;</span>Bound: Strideable {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170);"><span class="" style="">&nbsp;<span class="Apple-converted-space">&nbsp;</span></span><span class="" style="color: rgb(187, 44, 162);">func</span><span class="" style=""><span class="Apple-converted-space">&nbsp;</span>by(n:<span class="Apple-converted-space">&nbsp;</span></span>Bound<span class="" style="">.</span>Stride<span class="" style="">) -&gt;<span class="Apple-converted-space">&nbsp;</span></span>StrideThrough<span class="" style="">&lt;</span>Bound<span class="" style="">&gt; {</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(187, 44, 162);">return</span><span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(112, 61, 170);">start</span>.<span class="" style="color: rgb(61, 29, 129);">stride</span>(through:<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(112, 61, 170);">end</span>, by: n)</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; }</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">}</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><br class=""></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-family: Helvetica; font-size: 12px;">Which maybe gives you slightly more elegant usage:</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-family: Helvetica; font-size: 12px;"><br class=""></span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><div class="" style="margin: 0px; line-height: normal;"><span class="" style="color: rgb(187, 44, 162);">for</span><span class="Apple-converted-space">&nbsp;</span>lat<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(187, 44, 162);">in</span><span class="Apple-converted-space">&nbsp;</span>(<span class="" style="color: rgb(112, 61, 170);">CGFloat</span>(-<span class="" style="color: rgb(49, 44, 221);">60</span>)...<span class="" style="color: rgb(49, 44, 221);">60</span>).<span class="" style="color: rgb(49, 89, 93);">by</span>(<span class="" style="color: rgb(49, 44, 221);">30</span>) {</div><div class="" style="margin: 0px; line-height: normal;">&nbsp;<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(61, 29, 129);">print</span>(lat)</div><div class="" style="margin: 0px; line-height: normal;">}</div><div class="" style="margin: 0px; line-height: normal; min-height: 13px;"><br class=""></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="color: rgb(187, 44, 162);">for</span><span class="Apple-converted-space">&nbsp;</span>lat<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(187, 44, 162);">in</span><span class="Apple-converted-space">&nbsp;</span>(<span class="" style="color: rgb(112, 61, 170);">CGFloat</span>(-<span class="" style="color: rgb(49, 44, 221);">60</span>)..&lt;<span class="" style="color: rgb(49, 44, 221);">60</span>).<span class="" style="color: rgb(49, 89, 93);">by</span>(<span class="" style="color: rgb(49, 44, 221);">30</span>) {</div><div class="" style="margin: 0px; line-height: normal;">&nbsp;<span class="Apple-converted-space">&nbsp;</span><span class="" style="color: rgb(61, 29, 129);">print</span>(lat)</div><div class="" style="margin: 0px; line-height: normal;">}</div></div></div></div></blockquote><div><br class=""></div>This is nice; why don't we put it in the standard library and get rid of the "stride" methods?</div><div><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="font-family: AvenirNext-Regular; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=""><blockquote type="cite" class=""><div class="">On 19 Dec 2015, at 18:59, Gavin Eadie via swift-dev &lt;<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">With C-style for loops to be removed from the language to general acclaim (including mine), is the following the best way to perform the required looping:<div class=""><br class=""></div><div class=""><font face="Courier" class=""><span class="" style="font-size: 11px;">&nbsp; &nbsp; for lat in (CGFloat(-60.0)).stride(through: +60.0, by: 30.0) {<br class="">&nbsp; &nbsp; &nbsp; &nbsp; path.moveToPoint(CGPointMake(-180.0, lat))<br class="">&nbsp; &nbsp; &nbsp; &nbsp; path.lineToPoint(CGPointMake(+180.0, lat))<br class="">&nbsp; &nbsp; }<br class=""><br class="">&nbsp; &nbsp; for lon in (CGFloat(-150.0)).stride(through: +150.0, by: 30.0) {<br class="">&nbsp; &nbsp; &nbsp; &nbsp; path.moveToPoint(CGPointMake(lon, +90.0))<br class="">&nbsp; &nbsp; &nbsp; &nbsp; path.lineToPoint(CGPointMake(lon, -90.0))<br class="">&nbsp; &nbsp; }<br class=""></span></font><br class=""></div><div class="">That seems a slightly cumbersome usage. &nbsp;Is there a better way to initialize the SequenceType I want to iterate over?</div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=Lo8TP3b1oIn3yQXUt9zA1UCQfR-2BMBCuqnubTuDg47-2B2JrWct5LdmVtzlyLW-2FdFy-2BgksNk2B1nhv7HyAz0CWOkz3uQImvpZhn0tb9ulJe09H7KnMvvQYuNn1jvNDTuRxES-2FE9NCn3AlgkmyF9n8EHZrSTZEYMdrE-2F-2B-2FIkSBhtNgf0z6l-2FLBFGr3QUlmpEk6MrCUh8Xw1CAyWJiIZPEP4Gw2Oq4-2FEB-2BVfb9jsek6Esir8-3D" alt="" width="1" height="1" border="0" class="" style="height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;"></div>_______________________________________________<br class="">swift-dev mailing list<br class=""><a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-dev" class="">https://lists.swift.org/mailman/listinfo/swift-dev</a><br class=""></div></blockquote></div><br class=""></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=JfMPa-2F7wwZPzsZ3QKA8NjtONIYX4SjbWuUxtpfsTY2hrIG45T1JEtKY7V6eRrtcZ-2Bm4c-2B-2Bx1lhNRnkz8xpKofoZeCTFrNYJ-2B9gocEcD8Urs2ePECe9YLUt02RsQqM4XfmPSGcbYNhsDDullHozIEdavdcjNarhuyuONNymkRWrrqGRv0XIxLoKsbNfSMp68jaE9VbluGDqA3-2F03l4y7j7byqI-2B3xMUYqndqHIb7oR74-3D" alt="" width="1" height="1" border="0" style="font-family: AvenirNext-Regular; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""><span style="font-family: AvenirNext-Regular; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""><span class="Apple-converted-space">&nbsp;</span>_______________________________________________</span><br style="font-family: AvenirNext-Regular; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: AvenirNext-Regular; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-dev mailing list</span><br style="font-family: AvenirNext-Regular; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-dev@swift.org" style="font-family: AvenirNext-Regular; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">swift-dev@swift.org</a><br style="font-family: AvenirNext-Regular; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-dev" style="font-family: AvenirNext-Regular; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-dev</a></div></blockquote></div><br class=""><div class="">
-Dave<div class=""><br class=""></div><br class="Apple-interchange-newline">

</div>
<br class=""></body></html>