<div dir="ltr">I think people are reading a ..< b as the mathematical notation [a, b) which means {}, null, or empty, not error, if b < a and {a} if b = a. <div><br></div><div>If Range was changed to be an Array like collection indexed from 0 to count and stride was how the indexed counted and was an Int > 0 then the following would make sense in terms of interval mathematics as described above (note how stride refers to how the index counts *not* how the values count): </div><div><br></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">(0 ... -1) == []<br>(0 ..< 0) == []<br><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"></blockquote>(0 ... 0) == [0]<br>(0 ..< 2) == [0, 1]<br></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"></blockquote></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>(0 ... 2) == [0, 1, 2]</div></blockquote><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"></blockquote><div>(0 ..< 4).strided(by: 2) == [0, 1, 2, 3].strided(by: 2) == [0, 2]</div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>(0 ... 4).strided(by: 2) == [0, 1, 2, 3, 4].strided(by: 2) == [0, 2, 4]</div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"></blockquote></div></blockquote></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"></blockquote></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">(0 ..< 2).reversed == [0, 1].reversed == [1, 0]</blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">(0 ..< 4).strided(by: 2).reversed == [0, 1, 2, 3].strided(by: 2).reversed == [0, 2].reversed == [2, 0]</blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"></blockquote></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">(-2 ..< 2).strided(by: 2).reversed == [-2, -1, 0, 1].strided(by: 2).reversed == [-2, 0].reversed == [0, -2]</blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">(-2 ..< 2).reversed.strided(by: 2) == [-2, -1, 0, 1].reversed.strided(by: 2) == [1, 0, -1, -2].strided(by: 2) == [1, -1]</blockquote><br><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"></blockquote><div>Then provide a very general init for Range to cope with difficult cases:</div><div><br></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>init(first: T, isFirstIncluded: Bool = true, last: T, isLastIncluded: Bool = true, stride: Int = 1)</div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>Range(first: 0, last: 0, stride: 0) // ERROR, stride must be > 0</div><div>Range(first: 0, last: 0) == [0]<br></div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>Range(first: 0, isFirstIncluded: false, last: 0) == [] // {x | first < x <= last }</div><div>Range(first: 0, last: 0, isLastIncluded: false) == [] // {x | first <= x < last }</div></blockquote><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">Range(first: -2, isFirstIncluded: false, last: 2, isLastIncluded: false) == [-1, 0, 1] <br>Range(first: -2, isFirstIncluded: false, last: 2, isLastIncluded: false, stride: 2) == [-1, 1] <br></blockquote><br></div><div>Note: only ForwardIndexType necessary.</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"> -- Howard.<br></div></div>
<br><div class="gmail_quote">On 6 April 2016 at 09:22, Dave Abrahams via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
on Tue Apr 05 2016, Erica Sadun <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>
<br>
>> On Apr 5, 2016, at 4:17 PM, Dave Abrahams via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>
>><br>
>><br>
>> on Tue Apr 05 2016, Erica Sadun <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>
>><br>
><br>
>>> On Apr 5, 2016, at 1:54 PM, Dave Abrahams<br>
>>> <<a href="mailto:dabrahams@apple.com">dabrahams@apple.com</a>> wrote:<br>
>>> IMO this:<br>
>>><br>
>>> (-9...0).reverse()<br>
>>><br>
>>> is better than<br>
>>><br>
>>> stride(from: 0, to: -10, by: -1)<br>
>>><br>
>>> What do you think?<br>
>>><br>
>>> The latter better reflects an author's actual intent. The former depends on<br>
>>> implementation details, which can be hazy, especially, around the edge cases. It<br>
>>> is quicker to read, understand, and verify that the latter is what is<br>
>>> meant.<br>
>><br>
>> Except that there seems to be some confusion over what "to:" means, right?<br>
><br>
> obviously (0..<-10).by(-2) would be best.<br>
<br>
</span>I don't think that's obvious at all, because 0 ≮ 10<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Dave<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</div></div></blockquote></div><br></div>