<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, Apr 6, 2016 at 1:29 PM Pyry Jahkola via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></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"><br><div><blockquote type="cite"><div>On 06 Apr 2016, at 23:17, Dave Abrahams via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br><div><span style="font-family:Menlo-Regular;font-size:11px">I don&#39;t think you can fix counterintuitive behavior with guidance.  </span><br><br style="font-family:Menlo-Regular;font-size:11px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Menlo-Regular;font-size:11px;font-style: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">(1..&lt;199).striding(by: -2) is the first way I&#39;d reach for to express</span><br style="font-family:Menlo-Regular;font-size:11px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Menlo-Regular;font-size:11px;font-style: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">197, 195, ..., 3, 1</span><br style="font-family:Menlo-Regular;font-size:11px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"></div></blockquote></div><br></div><div style="word-wrap:break-word"><div>I think a sensible specification would be that with a positive step size, the count starts from the lower bound, and with a negative one, it starts from the upper bound (inclusive or exclusive). Thus, the following examples should cover all the corner cases:</div><div><br></div><div><font face="Menlo" style="font-size:11px">    (0 ... 9).striding(by: 2) == [0, 2, 4, 6, 8]</font></div><div><font face="Menlo" style="font-size:11px">    (0 ..&lt; 9).striding(by: 2) == [0, 2, 4, 6, 8]</font></div><div><font face="Menlo" style="font-size:11px">    (0 &lt;.. 9).striding(by: 2) ==    [2, 4, 6, 8]</font></div><div><font face="Menlo" style="font-size:11px">    (0 &lt;.&lt; 9).striding(by: 2) ==    [2, 4, 6, 8]</font></div><div><font face="Menlo" style="font-size:11px"><br></font></div><div><div><font face="Menlo" style="font-size:11px">    (0 ... 9).striding(by: 3) == [0, 3, 6, 9]</font></div><div><font face="Menlo" style="font-size:11px">    (0 ..&lt; 9).striding(by: 3) == [0, 3, 6]</font></div><div><font face="Menlo" style="font-size:11px">    (0 &lt;.. 9).striding(by: 3) ==    [3, 6, 9]</font></div><div><font face="Menlo" style="font-size:11px">    (0 &lt;.&lt; 9).striding(by: 3) ==    [3, 6]</font></div></div><div><font face="Menlo" style="font-size:11px"><br></font></div><div><div><font face="Menlo" style="font-size:11px">    (0 ... 9).striding(by: -2) == [9, 7, 5, 3, 1]</font></div><div><font face="Menlo" style="font-size:11px">    (0 ..&lt; 9).striding(by: -2) ==    [7, 5, 3, 1]</font></div><div><font face="Menlo" style="font-size:11px">    (0 &lt;.. 9).striding(by: -2) == [9, 7, 5, 3, 1]</font></div><div><font face="Menlo" style="font-size:11px">    (0 &lt;.&lt; 9).striding(by: -2) ==    [7, 5, 3, 1]</font></div><div><font face="Menlo" style="font-size:11px"><br></font></div><div><div><font face="Menlo" style="font-size:11px">    (0 ... 9).striding(by: -3) == [9, 6, 3, 0]</font></div><div><font face="Menlo" style="font-size:11px">    (0 ..&lt; 9).striding(by: -3) ==    [6, 3, 0]</font></div><div><font face="Menlo" style="font-size:11px">    (0 &lt;.. 9).striding(by: -3) == [9, 6, 3]</font></div><div><font face="Menlo" style="font-size:11px">    (0 &lt;.&lt; 9).striding(by: -3) ==    [6, 3]</font></div></div></div><div><br></div><div>Lastly, if you want the positive stride reversed, you&#39;d do just that:</div><div><br></div><div><div><font face="Menlo" style="font-size:11px">    (0 ... 9).striding(by: 2).reverse() == [8, 6, 4, 2, 0]</font></div></div></div></blockquote><div><br></div><div>I have always desired for a complete set of range variants like you outlined above. I don&#39;t have current examples warranting a complete set but I could easily see having to work on a data set that may be best done by having a complete set of range variants so you don&#39;t need to transform the data set to get it to work with the language you happen to be using. It also better supports floating point ranges which may not have easy ways to transform the data.</div><div><br></div><div>I also like the suggestion of how striding and reverse should work.</div><div><br></div><div>-Shawn</div></div></div>