<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=""><div class="">Hi Milos</div><div class=""><br class=""></div>Yes, (v1…v2).by(v3) it can determine the going of either in + or - direction,<div class="">but only at run time! because the contents of v1, v2, v3 are of course unknown at compile time. <div class="">Ergo: it cannot expected be an absolute value.</div><div class=""><br class=""></div><div class="">however, I suggested (coded) that here on 4.3.2016… Works in Playground Xcode 7.3</div><div class="">look in the struct its “init” where the direction is determined</div><div class="">by wether “from” or “to” is bigger” </div><div class="">implemented like this (and also with a floating point number tolerance)</div><div class="">(The struct should be numerical generic, but I didn’t manage to change it to generic,) </div><div class="">Anyway, should be compilerized/hand coded in asm perhaps (I can’t do that)</div><div class=""><br class=""></div><div class="">TedvG</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">public</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">struct</span> StriderGenerator : <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">GeneratorType</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;">{</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">private</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">let</span> low: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Double</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">private</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">let</span> high: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Double</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">private</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">var</span> step : <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Double</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">private</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">var</span> tol : <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Double</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;"><br class=""></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">private</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">var</span> iterator = <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">0</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;"><br class=""></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">private</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">let</span> moveForward: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Bool</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> </span>private<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> </span>var<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> done = </span>false</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> </div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">public</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">init</span>(from: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Double</span>, to: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Double</span>, by: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Double</span>, tolerance: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Double</span>)</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> {</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">step</span> = by</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">if</span> from < to</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> {</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">low</span> = from</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">high</span> = to</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">moveForward</span> = <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">true</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> }</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">else</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> {</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">low</span> = to</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">high</span> = from</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">moveForward</span> = <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">false</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> }</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">self</span>.<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">tol</span> = tolerance * <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">0.5</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 132, 0);">// center it.</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> }</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> </span>/// return next value or nil, if no next</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> </span>/// element exists.</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">public</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">mutating</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">func</span> next() -> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Double</span>?</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> {</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">let</span> current:<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Double</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">if</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">done</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> {</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">return</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">nil</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> }</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(79, 129, 135);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">if</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> </span>moveForward</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> {</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> current = <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">low</span> + <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Double</span>(<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">iterator</span>) * <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">step</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> }</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">else</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> {</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> current = <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">high</span> - <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Double</span>(<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">iterator</span>) * <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">step</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> }</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">iterator</span> += <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">1</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""> <br class="webkit-block-placeholder"></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> </span>// done if exceeding low or high limits + tolerance</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">done</span> = current > <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">high</span> + <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">tol</span> ||</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> current < <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">low</span> - <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">tol</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">if</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">done</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> {</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">return</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">nil</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> }</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">else</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> {</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">return</span> current</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> }</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> }</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;">}</div></div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">public</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">struct</span> Strider : <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">SequenceType</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 132, 0);">// Aragorn</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;">{</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">private</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">let</span> start: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Double</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">private</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">let</span> end: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Double</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">private</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">let</span> step: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Double</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">private</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">let</span> tol: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Double</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;"><br class=""></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">init</span>(from: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Double</span>, to: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Double</span>, by: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Double</span>, tolerance : <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Double</span>)</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> {</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(61, 29, 129);">_precondition</span>(by > <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">0.0</span> ,</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> </span>"Init of struct Strider: 'by:...' value must be > 0.0."<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">)</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(61, 29, 129);">_precondition</span>(<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(61, 29, 129);">abs</span>(by) > tolerance,</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> </span>"Init of struct Strider: 'by:...' value must be > tolerance."<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">)</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(61, 29, 129);">_precondition</span>(tolerance >= <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">0.0</span>,</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> </span>"Init of struct Strider: tolerance:... value must be >= 0.0"<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">)</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">start</span> = from</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">end</span> = to;</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">step</span> = by</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">tol</span> = tolerance</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> }</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> </span>/// Return a *generator* over the elements of this *sequence*.</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">public</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">func</span> generate() -> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">StriderGenerator</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> {</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">return</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">StriderGenerator</span>(from: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">start</span>, to: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">end</span>, by: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">step</span>, tolerance: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">tol</span>)</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> }</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;">}</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;"><br class=""></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);">public<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> </span>extension<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Double</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;">{</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">public</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">func</span> strider(to to: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Double</span>, by: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Double</span>, tolerance: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Double</span> ) -> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">Strider</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> {</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">return</span> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">Strider</span>( from: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">self</span>, to: to, by: by, tolerance: tolerance)</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> }</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;">}</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;"><br class=""></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(61, 29, 129);">print</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">(</span>"Testing the new .strider extension"<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">)</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;"><br class=""></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">let</span> testvalues =</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;">[</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> </span>// fr: to: by: tolerance:</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> [ <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">0.0</span>, <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">5.0</span>, <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">1.0</span>, <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">0.0</span> ],</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> [-<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">3.0</span>, <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">4.0</span>, <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">0.12</span>, <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">0.1</span> ],</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> [ <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">2.0</span>, -<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">1.0</span>, <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">0.34</span>, <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">0.1</span> ],</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(39, 42, 216);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> [ </span>0.001<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">, -</span>0.002<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">, </span>0.0001<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">, </span>0.00001<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> ]</span></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;">]</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;"><br class=""></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(79, 129, 135);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">for</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> parm </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">in</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> </span>testvalues</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;">{</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"> </span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(61, 29, 129);">print</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">(</span>"==============Stride from: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">\</span>(<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">parm[</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">0</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">]</span>) to: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">\</span>(<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">parm[</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">1</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">]</span>) by: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">\</span>(<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">parm[</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">2</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">]</span>) tolerance: <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">\</span>(<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">parm[</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">3</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">]</span>)\n"<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">)</span></div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo; min-height: 19px;" class=""> <br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">for</span> val <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">in</span> parm[<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">0</span>].<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(49, 89, 93);">strider</span>(to: parm[<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">1</span>], by: parm[<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">2</span>], tolerance: parm[<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);">3</span>])</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> {</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(61, 29, 129);">print</span>(<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(209, 47, 27);">"</span>\<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(209, 47, 27);">(</span>val<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(209, 47, 27);">) "</span>, terminator:<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(209, 47, 27);">""</span>)</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> }</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;"> <span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(61, 29, 129);">print</span>(<span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(209, 47, 27);">"\n\n"</span>)</div><div class="" style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;">}</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">TedvG</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class=""><br class=""><div class=""><div><blockquote type="cite" class=""><div class="">On 06.04.2016, at 23:15, Milos Rankovic <<a href="mailto:milos@milos-and-slavica.net" class="">milos@milos-and-slavica.net</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Ted,<div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="">that would imply the ‘by”value should/must always be an absolute value?</div></div></blockquote></div><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><br class=""></div><div class="">In a way: Instead of `Strideable.Stride` I would suggest `Strideable.Distance`.</div><div class=""><br class=""></div></div></div><div class="">At any rate, leaving the sign to be direction indicator makes it forever necessary for everyone to make this counterintuitive metal gymnastics, since most of the time in life we do not walk backwards, even when we are returning back whence we came from!</div><div class=""><br class=""></div><div class="">What do you think?</div><div class=""><br class=""></div><div class="">milos</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class=""><blockquote type="cite" class=""><div class="">On 6 Apr 2016, at 21:34, Ted F.A. van Gaalen <<a href="mailto:tedvgiosdev@gmail.com" class="">tedvgiosdev@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hello Milos,</div>Good question<div class="">was thinking about this too.</div><div class="">that would imply the ‘by”value should/must always be an absolute value?</div><div class="">however (if it is a var) it cannot be guaranteed to be + or - </div><div class="">that’s why I thought to leave it as is.</div><div class="">?</div><div class="">TedvG</div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 06.04.2016, at 22:18, Milos Rankovic <<a href="mailto:milos@milos-and-slavica.net" class="">milos@milos-and-slavica.net</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 6 Apr 2016, at 21:08, Ted F.A. van Gaalen 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: -webkit-standard; font-size: inherit; 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="">v1 > v2: is allowed and correctly evaluated. e.g. (8.0…-3.14159).by(-0.0001) </span></div></blockquote></div><br class=""><div class="">If the range does not assume `start >= end`, is it still necessary to also indicate the traversal direction with the sign of the step (`-0.0001`)?</div><div class=""><br class=""></div><div class="">milos</div></div></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></div></div></div></body></html>