<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 1:20 PM, Wallacy &lt;<a href="mailto:wallacyf@gmail.com" class="">wallacyf@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Curiously I was analyzing this part of the library a few minutes ago.<div class="">It will probably be necessary to extend "Range":<br class=""></div><div class=""><br class=""></div><div class=""><div class="">extension Range where Element: Strideable {</div><div class="">&nbsp; &nbsp; func by(n: Element.Stride) -&gt; StrideThrough&lt;Element&gt; {</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; return startIndex.stride(through: endIndex, by: n)</div><div class="">&nbsp; &nbsp; }</div><div class="">}</div></div></div></div></blockquote><div><br class=""></div>Why?</div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">The first thing that came into my head was:<br class=""></div><div class=""><br class=""></div><div class=""><div class="">var rangeA = -150.0..&lt;150 // HalfOpenInterval&lt;Double&gt;</div><div class="">var rangeB = -150.0...150 // ClosedInterval&lt;Double&gt;</div><div class="">var rangeC = -150..&lt;150 // Range&lt;Int&gt;</div><div class="">var rangeD = -150...150 // Range&lt;Int&gt;</div></div><div class=""><br class=""></div><div class="">For "Range" we need to use startIndex and endIndex respectively, and with HalfOpenInterval/ClosedInterval only start and end.<br class=""></div><div class=""><br class=""></div><div class="">I do not know for you, but it seems inconsistent and redundant to me.</div></div></div></blockquote><div><br class=""></div>I don't understand most of what you're saying here, or why you're saying it. &nbsp;The extensions as shown in Donnacha's post work for me.</div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_quote"><div dir="ltr" class="">Em sáb, 19 de dez de 2015 às 18:39, Dave Abrahams via swift-dev &lt;<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a>&gt; escreveu:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><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" target="_blank" class="">swift-dev@swift.org</a>&gt; wrote:</div><br class=""><div class=""><span style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important" class="">You can define an extension on interval types:</span><div style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br class=""></div><div style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""><span style="color:rgb(187,44,162)" class="">extension</span><span class="">&nbsp;</span><span style="color:rgb(112,61,170)" class="">HalfOpenInterval</span><span class="">&nbsp;</span><span style="color:rgb(187,44,162)" class="">where</span><span class="">&nbsp;</span>Bound: Strideable {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(112,61,170)" class=""><span class="">&nbsp;<span class="">&nbsp;</span></span><span style="color:rgb(187,44,162)" class="">func</span><span class=""><span class="">&nbsp;</span>by(n:<span class="">&nbsp;</span></span>Bound<span class="">.</span>Stride<span class="">) -&gt;<span class="">&nbsp;</span></span>StrideTo<span class="">&lt;</span>Bound<span class="">&gt; {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">&nbsp; &nbsp;<span class="">&nbsp;</span><span style="color:rgb(187,44,162)" class="">return</span><span class="">&nbsp;</span><span style="color:rgb(112,61,170)" class="">start</span>.<span style="color:rgb(61,29,129)" class="">stride</span>(to:<span class="">&nbsp;</span><span style="color:rgb(112,61,170)" class="">end</span>, by: n)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">&nbsp; }</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">}</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px" class=""><br class=""></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""><span style="color:rgb(187,44,162)" class="">extension</span><span class="">&nbsp;</span><span style="color:rgb(112,61,170)" class="">ClosedInterval</span><span class="">&nbsp;</span><span style="color:rgb(187,44,162)" class="">where</span><span class="">&nbsp;</span>Bound: Strideable {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(112,61,170)" class=""><span class="">&nbsp;<span class="">&nbsp;</span></span><span style="color:rgb(187,44,162)" class="">func</span><span class=""><span class="">&nbsp;</span>by(n:<span class="">&nbsp;</span></span>Bound<span class="">.</span>Stride<span class="">) -&gt;<span class="">&nbsp;</span></span>StrideThrough<span class="">&lt;</span>Bound<span class="">&gt; {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">&nbsp; &nbsp;<span class="">&nbsp;</span><span style="color:rgb(187,44,162)" class="">return</span><span class="">&nbsp;</span><span style="color:rgb(112,61,170)" class="">start</span>.<span style="color:rgb(61,29,129)" class="">stride</span>(through:<span class="">&nbsp;</span><span style="color:rgb(112,61,170)" class="">end</span>, by: n)</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">&nbsp; }</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="">}</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""><br class=""></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""><span style="font-family:Helvetica;font-size:12px" class="">Which maybe gives you slightly more elegant usage:</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""><span style="font-family:Helvetica;font-size:12px" class=""><br class=""></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class=""><div style="margin:0px;line-height:normal" class=""><span style="color:rgb(187,44,162)" class="">for</span><span class="">&nbsp;</span>lat<span class="">&nbsp;</span><span style="color:rgb(187,44,162)" class="">in</span><span class="">&nbsp;</span>(<span style="color:rgb(112,61,170)" class="">CGFloat</span>(-<span style="color:rgb(49,44,221)" class="">60</span>)...<span style="color:rgb(49,44,221)" class="">60</span>).<span style="color:rgb(49,89,93)" class="">by</span>(<span style="color:rgb(49,44,221)" class="">30</span>) {</div><div style="margin:0px;line-height:normal" class="">&nbsp;<span class="">&nbsp;</span><span style="color:rgb(61,29,129)" class="">print</span>(lat)</div><div style="margin:0px;line-height:normal" class="">}</div><div style="margin:0px;line-height:normal;min-height:13px" class=""><br class=""></div><div style="margin:0px;line-height:normal" class=""><span style="color:rgb(187,44,162)" class="">for</span><span class="">&nbsp;</span>lat<span class="">&nbsp;</span><span style="color:rgb(187,44,162)" class="">in</span><span class="">&nbsp;</span>(<span style="color:rgb(112,61,170)" class="">CGFloat</span>(-<span style="color:rgb(49,44,221)" class="">60</span>)..&lt;<span style="color:rgb(49,44,221)" class="">60</span>).<span style="color:rgb(49,89,93)" class="">by</span>(<span style="color:rgb(49,44,221)" class="">30</span>) {</div><div style="margin:0px;line-height:normal" class="">&nbsp;<span class="">&nbsp;</span><span style="color:rgb(61,29,129)" class="">print</span>(lat)</div><div style="margin:0px;line-height:normal" class="">}</div></div></div></div></blockquote><div class=""><br class=""></div></div></div><div style="word-wrap:break-word" class=""><div class="">This is nice; why don't we put it in the standard library and get rid of the "stride" methods?</div></div><div style="word-wrap:break-word" class=""><div class=""><br class=""><blockquote type="cite" class=""><div class=""><div style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><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" target="_blank" class="">swift-dev@swift.org</a>&gt; wrote:</div><br class=""><div class=""><div style="word-wrap:break-word" class="">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 style="font-size:11px" class="">&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" style="min-height:1px!important;width:1px!important;border-width:0px!important;margin:0px!important;padding:0px!important" class=""></div>_______________________________________________<br class="">swift-dev mailing list<br class=""><a href="mailto:swift-dev@swift.org" target="_blank" class="">swift-dev@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-dev" target="_blank" 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;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;min-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;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important" class=""><span class="">&nbsp;</span>_______________________________________________</span><br style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><span style="font-family:AvenirNext-Regular;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing: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;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing: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;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" 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;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing: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;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-dev</a></div></blockquote></div><br class=""></div><div style="word-wrap:break-word" class=""><div class="">
-Dave<div class=""><br class=""></div><br class="">

</div>
<br class="">
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=fuWmDRE6-2FDdvdUHeLHruUfdigJaxz7nh99l6HfkulY9zc1AEBTCn0nA0fPpMPgi1unJE7Ep8HtxumrD1xylFuHnwzbBqVD4-2FeoRA4ErRpAmWHiVkCX6KTzplR64tYvNdtYK7-2B-2BhRYqtwiKP-2Ftgw4feBjMxBsEmzuDMyKkKXMWlNTZnQFvjGH9jt-2FLvNubEcgPytU3fzCyBW8ZisryS0zGVIihrZ7TOQoncDhIINovoA-3D" alt="" width="1" height="1" border="0" style="min-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-dev mailing list<br class="">
<a href="mailto:swift-dev@swift.org" target="_blank" class="">swift-dev@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-dev" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-dev</a><br class="">
</blockquote></div></div>
</div></blockquote></div><br class=""><div class="">
-Dave<div class=""><br class=""></div><br class="Apple-interchange-newline">

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