<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 06 Apr 2016, at 23:17, Dave Abrahams via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Menlo-Regular; font-size: 11px;" class="">I don't think you can fix counterintuitive behavior with guidance. </span><br class=""><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: 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: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: 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="">(1..<199).striding(by: -2) is the first way I'd reach for to express</span><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: 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: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: 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="">197, 195, ..., 3, 1</span><br style="font-family: Menlo-Regular; font-size: 11px; font-style: normal; font-variant-caps: 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=""></div></blockquote></div><br class=""><div class="">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 class=""><br class=""></div><div class=""><font face="Menlo" style="font-size: 11px;" class=""> (0 ... 9).striding(by: 2) == [0, 2, 4, 6, 8]</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class=""> (0 ..< 9).striding(by: 2) == [0, 2, 4, 6, 8]</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class=""> (0 <.. 9).striding(by: 2) == [2, 4, 6, 8]</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class=""> (0 <.< 9).striding(by: 2) == [2, 4, 6, 8]</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class=""><br class=""></font></div><div class=""><div class=""><font face="Menlo" style="font-size: 11px;" class=""> (0 ... 9).striding(by: 3) == [0, 3, 6, 9]</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class=""> (0 ..< 9).striding(by: 3) == [0, 3, 6]</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class=""> (0 <.. 9).striding(by: 3) == [3, 6, 9]</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class=""> (0 <.< 9).striding(by: 3) == [3, 6]</font></div></div><div class=""><font face="Menlo" style="font-size: 11px;" class=""><br class=""></font></div><div class=""><div class=""><font face="Menlo" style="font-size: 11px;" class=""> (0 ... 9).striding(by: -2) == [9, 7, 5, 3, 1]</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class=""> (0 ..< 9).striding(by: -2) == [7, 5, 3, 1]</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class=""> (0 <.. 9).striding(by: -2) == [9, 7, 5, 3, 1]</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class=""> (0 <.< 9).striding(by: -2) == [7, 5, 3, 1]</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class=""><br class=""></font></div><div class=""><div class=""><font face="Menlo" style="font-size: 11px;" class=""> (0 ... 9).striding(by: -3) == [9, 6, 3, 0]</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class=""> (0 ..< 9).striding(by: -3) == [6, 3, 0]</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class=""> (0 <.. 9).striding(by: -3) == [9, 6, 3]</font></div><div class=""><font face="Menlo" style="font-size: 11px;" class=""> (0 <.< 9).striding(by: -3) == [6, 3]</font></div></div></div><div class=""><br class=""></div><div class="">Lastly, if you want the positive stride reversed, you'd do just that:</div><div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" style="font-size: 11px;" class=""> (0 ... 9).striding(by: 2).reverse() == [8, 6, 4, 2, 0]</font></div></div><div class=""><br class=""></div><div class="">— Pyry</div></body></html>