<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 01.08.2016, at 17:45, Saagar Jha &lt;<a href="mailto:saagar@saagarjha.com" class="">saagar@saagarjha.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class="">With your method, don't you need to write a new method for every dimension?</div></blockquote>Hi Saagar,</div><div><br class=""></div><div>Yes, one could solve this by writing a function</div><div>that propagates though all iteration levels, possibly recursively,</div><div>I might try to implement that.</div><div>left “as an exercise to the astute reader” :o) &nbsp;&nbsp;</div><div><br class=""></div><div>Kind regards</div><div>Ted</div><div><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote"><div dir="ltr" class="">On Mon, Aug 1, 2016 at 08:43 Ted F.A. van Gaalen via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:<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="">Hi Erica</div><div class=""><br class=""></div><div class="">That would also be a workable solution, but imho still too tedious as&nbsp;</div><div class="">it has been so for many years, with nested iteration statements…</div><div class="">many times this is for;; for;; for tables and for;;for;;for;; for 3D structuring.</div><div class=""><span style="color:rgb(49,89,93);font-family:Menlo;font-size:16px" class="">&nbsp;&nbsp;</span></div><div class=""><br class=""></div><div class="">Swift offers nice features (like protocols and generics as you know) to improve this.&nbsp;</div><div class=""><br class=""></div><div class="">- I no longer have to nest for;; s &nbsp;so, Now I rather do this: &nbsp;</div><div class="">Your example can already be coded like this:</div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span style="color:#31595d" class="">&nbsp; &nbsp;iterate2D</span><span class="">(&nbsp;</span><span class="">1, 2</span><span class="">, { $0 &lt; 64 } ,</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1, 2</span><span class="">, { $0 &lt; 64 } ,</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {outerIndex,innerIndex in</div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print (outerIndex,InnerIndex)</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">return</span><span class=""> </span><span style="color:rgb(187,44,162)" class="">true // Obligatory. return “false" to break</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}&nbsp; )</span></div></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><br class=""></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span style="font-family:Helvetica;font-size:14px" class="">With no chances in Swift, this already works like a charm!</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span style="font-family:Helvetica;font-size:14px" class="">Imho much more readable and compact,</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span style="font-family:Helvetica;font-size:14px" class=""><br class=""></span></div><div style="margin:0px;line-height:normal" class="">Uses - AFAICS from a programmers’s perspective - no&nbsp;</div><div style="margin:0px;line-height:normal" class="">underlying deep collection based&nbsp;coding with Sequence. etc.</div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span style="font-family:Helvetica;font-size:14px" class=""><br class=""></span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span style="font-family:Helvetica;font-size:14px" class="">I am already deploying it in my own apps e.g. l</span></div><div style="margin:0px;line-height:normal" class="">(replaced for;; for;; for;; in the app) &nbsp;</div><div style="margin:0px;line-height:normal" class=""><br class=""></div><div style="margin:0px;line-height:normal" class="">By using this new iterator…() functions my coding gets leaner&nbsp;</div><div style="margin:0px;line-height:normal" class="">and errors are easier to spot.&nbsp;</div><div style="margin:0px;line-height:normal" class=""><br class=""></div><div style="margin:0px;line-height:normal" class="">Actual working code with Swift 2.x here:&nbsp;</div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span style="font-family:Helvetica;font-size:14px" class=""><br class=""></span></div><div style="margin:0px;line-height:normal" class=""><div style="font-family:Menlo;font-size:16px;margin:0px;line-height:normal" class=""><span class="">&nbsp;&nbsp;</span><span style="color:#bb2ca2" class="">func</span><span class=""> generateTiles()</span></div><div style="font-family:Menlo;font-size:16px;margin:0px;line-height:normal" class=""><span class="">&nbsp; {</span></div><div style="font-family:Menlo;font-size:16px;margin:0px;line-height:normal" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:#bb2ca2" class="">let</span><span class=""> w:&nbsp; &nbsp; &nbsp; </span><span style="color:#703daa" class="">Float</span><span class=""> = &nbsp; </span><span style="color:#272ad8" class="">20</span><span class="">&nbsp; </span><span style="color:#008400" class="">// tile size</span></div><div style="font-family:Menlo;font-size:16px;margin:0px;line-height:normal" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:#bb2ca2" class="">let</span><span class=""> h:&nbsp; &nbsp; &nbsp; </span><span style="color:#703daa" class="">Float</span><span class=""> =&nbsp; &nbsp; </span><span style="color:#272ad8" class="">5</span></div><div style="font-family:Menlo;font-size:16px;margin:0px;line-height:normal" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:#bb2ca2" class="">let</span><span class=""> l:&nbsp; &nbsp; &nbsp; </span><span style="color:#703daa" class="">Float</span><span class=""> =&nbsp; &nbsp; </span><span style="color:#272ad8" class="">5</span></div><div style="font-family: Menlo; font-size: 16px; margin: 0px; line-height: normal; min-height: 19px;" class=""><span class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><br class=""></div><div style="font-family:Menlo;font-size:16px;margin:0px;line-height:normal" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:#bb2ca2" class="">let</span><span class=""> xstart: </span><span style="color:#703daa" class="">Float</span><span class=""> = -</span><span style="color:#272ad8" class="">120</span></div><div style="font-family:Menlo;font-size:16px;margin:0px;line-height:normal" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:#bb2ca2" class="">let</span><span class=""> ystart: </span><span style="color:#703daa" class="">Float</span><span class=""> =&nbsp; -</span><span style="color:#272ad8" class="">60</span></div><div style="font-family:Menlo;font-size:16px;margin:0px;line-height:normal" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:#bb2ca2" class="">let</span><span class=""> zstart: </span><span style="color:#703daa" class="">Float</span><span class=""> =&nbsp; -</span><span style="color:#272ad8" class="">10</span></div><div style="font-family: Menlo; font-size: 16px; margin: 0px; line-height: normal; min-height: 19px;" class=""><span class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><br class=""></div><div style="font-family:Menlo;font-size:16px;margin:0px;line-height:normal" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:#bb2ca2" class="">let</span><span class=""> xend: </span><span style="color:#703daa" class="">Float</span><span class=""> = </span><span style="color:#272ad8" class="">120</span></div><div style="font-family:Menlo;font-size:16px;margin:0px;line-height:normal" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:#bb2ca2" class="">let</span><span class=""> yend: </span><span style="color:#703daa" class="">Float</span><span class=""> =&nbsp; </span><span style="color:#272ad8" class="">60</span></div><div style="font-family:Menlo;font-size:16px;margin:0px;line-height:normal" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:#bb2ca2" class="">let</span><span class=""> zend: </span><span style="color:#703daa" class="">Float</span><span class=""> =&nbsp; </span><span style="color:#272ad8" class="">10</span></div><div style="font-family: Menlo; font-size: 16px; margin: 0px; line-height: normal; min-height: 19px;" class=""><span class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><br class=""></div><div style="font-family:Menlo;font-size:16px;margin:0px;line-height:normal;color:rgb(0,132,0)" class=""><span style="" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:#bb2ca2" class="">let</span><span style="" class=""> tolerance:</span><span style="color:#703daa" class="">Float</span><span style="" class=""> = </span><span style="color:#272ad8" class="">0.001</span><span style="" class=""> </span><span class="">// float drift compensation</span></div><div style="font-family: Menlo; font-size: 16px; margin: 0px; line-height: normal; min-height: 19px;" class=""><span class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><br class=""></div><div style="font-family:Menlo;font-size:16px;margin:0px;line-height:normal" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:#31595d" class="">iterate3D</span><span class="">( xstart, w * </span><span style="color:#272ad8" class="">1.2</span><span class="">, { $0 &lt; xend + tolerance } ,</span></div><div style="font-family:Menlo;font-size:16px;margin:0px;line-height:normal" class=""><span class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ystart, h * </span><span style="color:#272ad8" class="">1.2</span><span class="">, { $0 &lt; yend + tolerance } ,</span></div><div style="font-family:Menlo;font-size:16px;margin:0px;line-height:normal" class=""><span class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; zstart, l * </span><span style="color:#272ad8" class="">1.2</span><span class="">, { $0 &lt; zend + tolerance } ,</span></div><div style="font-family:Menlo;font-size:16px;margin:0px;line-height:normal" class=""><span class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div><div style="font-family:Menlo;font-size:16px;margin:0px;line-height:normal" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x,y,z </span><span style="color:#bb2ca2" class="">in</span></div><div style="font-family:Menlo;font-size:16px;margin:0px;line-height:normal" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:#bb2ca2" class="">self</span><span class="">.</span><span style="color:#31595d" class="">addTile</span><span class="">(x,y,z, &nbsp;</span></div><div style="font-family:Menlo;font-size:16px;margin:0px;line-height:normal" class=""><span class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; w,h,l)</span></div><div style="font-family:Menlo;font-size:16px;margin:0px;line-height:normal" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color:#bb2ca2" class="">return</span><span class=""> </span><span style="color:#bb2ca2" class="">true</span></div><div style="font-family:Menlo;font-size:16px;margin:0px;line-height:normal" class=""><span class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; )</span></div><div style="font-family:Menlo;font-size:16px;margin:0px;line-height:normal" class=""><span class="">&nbsp; &nbsp; }</span></div><div style="font-family:Menlo;font-size:16px" class=""><span class=""><br class=""></span></div><div style="font-family:Menlo;font-size:16px" class=""><span style="font-family:Helvetica;font-size:14px" class="">This generates a group of blocks or tiles in my Apple TV app (under construction)</span></div><div class="">like the one you can see &nbsp;in the image&nbsp;“Cloinckz” on my website <a href="http://www.tedvg.com/" target="_blank" class="">www.tedvg.com</a>.</div><div class=""><br class=""></div><div class="">I also prefer the one dimensional iterate(.. &nbsp;too above the for;; or stride()</div><div class=""><br class=""></div><div class="">One could extend these iterator…() functions by adding closures for pre and post iteration handling,</div><div class="">like for printing headers and footers before and/or after a complete [inner] iteration.</div><div class=""><br class=""></div><div class="">Note that breaking with *return false* -which is equivalent to the “break” stmt in</div><div class="">a classical for;; - &nbsp;does not only leave a nested iteration, but also the outer ones.</div><div class="">(maybe a TODO to make individual level- break possible) &nbsp;As it is now, If one&nbsp;</div><div class="">wants to break at the deep iteration level, then one should nest this using 1D iterators.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Anyway, this is just a thought starting to think about multi-dimensional iterators,</div><div class="">and other (encapsulation?) of multi dimensional data as well.</div><div class="">In any case for 2D because table data is used very frequently in many apps. as</div><div class="">most data are in tables.</div><div class=""><br class=""></div><div class=""><div class="">You won’t believe this :o) but in a sense I might not make so much fuzz anymore</div><div class="">to keep the for;; &nbsp;as this proves to me that I can solve things much better that I thought.</div></div><div class="">So, I have to rethink this.</div><div class=""><br class=""></div><div class="">Kind Regards</div><div class="">Ted &nbsp;</div></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span style="font-family:Helvetica;font-size:14px" class=""><a href="http://www.ravelnotes.com/" target="_blank" class="">www.ravelnotes.com</a></span></div></div><div style="word-wrap:break-word" class=""><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span style="font-family:Helvetica;font-size:14px" class=""><br class=""></span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span style="font-family:Helvetica;font-size:14px" class="">&nbsp;</span></div><div class=""><span class=""><br class=""></span></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 31.07.2016, at 18:33, Erica Sadun &lt;<a href="mailto:erica@ericasadun.com" target="_blank" class="">erica@ericasadun.com</a>&gt; wrote:</div><br class=""><div class=""><div style="word-wrap:break-word" class=""><div class="">I'm replying on Swift-Users and bcc'ing in Swift-Evolution to comply with the core team's request to focus SE on the current mission statement.&nbsp;</div><div class=""><br class=""></div><div class="">At some point soon, Russ Bishop's PR&nbsp;<a href="https://github.com/apple/swift/pull/3600" target="_blank" class="">https://github.com/apple/swift/pull/3600</a>&nbsp;will be incorporated into Swift 3. This PR adds `prefix(while:)` and `drop(while:)` to finish implementing SE-0045.&nbsp; Once that's done, you can &nbsp;combine `sequence(first:, next:)` and `prefix(while:)` to into a single function `sequence(first:, next:, while:)` like this:</div><div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class="">public func sequence&lt;T&gt;(first: T, next: (T) -&gt; T?, while test: (T) -&gt; Bool) -&gt; UnfoldSequence&lt;T, UnfoldSequence&lt;T, (T?, Bool)&gt;&gt; {</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; return sequence(first: first, next: next).prefix(while: test)</font></div><div class=""><font face="Menlo" class="">}</font></div><div class=""><br class=""></div><div class="">The combined sequence/prefix call allows you to create loops like this:</div><div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class="">for outerIndex in sequence(first: 1, next: { $0 * 2 }, while: { $0 &lt;= 64 }) {</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; for innerIndex in sequence(first: 1, next: { $0 * 2 }, while: { $0 &lt;= 64 }) {</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; &nbsp; &nbsp; print(outerIndex, innerIndex)</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; }</font></div><div class=""><font face="Menlo" class="">}</font></div></div></div><div class=""><br class=""></div><div class="">These loops can be nested. break and continue work.&nbsp; You can use tuples for multiple arguments. While I'd like to see a combined form adopted into Swift 4b (the deferred "sugar"), it isn't a high priority.</div><div class=""><br class=""></div><div class="">-- E</div><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jul 31, 2016, at 7:18 AM, Ted F.A. van Gaalen via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class=""><div class=""><div style="word-wrap:break-word" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 31.07.2016, at 04:28, <a href="mailto:jaden.geller@gmail.com" target="_blank" class="">jaden.geller@gmail.com</a> wrote:</div><br class=""><div class=""><div dir="auto" class=""><div class=""></div><div class="">What benefit do Iterator2D and Iterator3D provide that nesting does not?</div></div></div></blockquote>Hi Jaden,</div><div class="">well, simply because of hiding/enclosing repetitive functionality</div><div class="">like with every other programming element is convenient,</div><div class="">prevents errors and from writing the same over and over again.</div><div class="">That is why there are functions.</div><div class="">but you already know that, of course.</div><div class="">Kind Regards</div><div class="">TedvG</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class=""><div dir="auto" class=""><div class=""><br class="">On Jul 30, 2016, at 1:48 PM, Ted F.A. van Gaalen via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class="">Hi Chris,<div class=""><br class=""><div class="">thanks for the tip about Hirundo app!</div></div><div class=""><br class=""></div><div class=""><div class="">A positive side-effect of removing the classical for;; loop</div><div class="">&nbsp;(yes, it’s me saying this :o) &nbsp;is that it forces me to find</div><div class="">a good and generic equivalent for it,&nbsp;</div><div class="">making the conversion of my for;;s to 3.0 easier.</div><div class="">which is *not* based on collections or sequences and</div><div class="">does not rely on deeper calls to Sequence etc.</div><div class=""><br class=""></div><div class="">so, I’ve made the functions [iterator, iterator2D, iterator3D] &nbsp;(hereunder)</div><div class="">wich btw clearly demonstrate the power and flexibility of Swift.&nbsp;</div><div class=""><br class=""></div><div class="">Very straightforward, and efficient (i assume) just like the classical for;; loop. &nbsp;</div><div class="">It works quite well in my sources.</div><div class=""><br class=""></div></div><div class="">As a spin-off, &nbsp;I’ve extended these to iterators for matrices 2D and cubes? 3D...</div><div class=""><br class=""></div><div class="">Question:&nbsp;</div><div class="">Perhaps implementing “multi dimensional iterator functions</div><div class="">in Swift might &nbsp;be a good idea. so that is no longer necessary to nest/nest/nest iterators.&nbsp;</div><div class=""><br class=""></div><div class="">Met vriendelijke groeten, sorry for my “intensity” in discussing the classical for;;&nbsp;</div><div class="">I'll have to rethink this for;; again.. &nbsp;</div><div class="">Thanks, Ted.</div><div class=""><br class=""></div><div class="">Any remarks ( all ), suggestions about the code hereunder: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;?&nbsp;</div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span style="color:rgb(187,44,162)" class="">protocol</span><span class="">&nbsp;NumericType</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">{</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">func</span><span class="">&nbsp;+(lhs:&nbsp;</span><span style="color:rgb(79,129,135)" class="">Self</span><span class="">, rhs:&nbsp;</span><span style="color:rgb(79,129,135)" class="">Self</span><span class="">) -&gt;&nbsp;</span><span style="color:rgb(112,61,170)" class="">Self</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">func</span><span class="">&nbsp;-(lhs:&nbsp;</span><span style="color:rgb(79,129,135)" class="">Self</span><span class="">, rhs:&nbsp;</span><span style="color:rgb(79,129,135)" class="">Self</span><span class="">) -&gt;&nbsp;</span><span style="color:rgb(112,61,170)" class="">Self</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">func</span><span class="">&nbsp;*(lhs:&nbsp;</span><span style="color:rgb(79,129,135)" class="">Self</span><span class="">, rhs:&nbsp;</span><span style="color:rgb(79,129,135)" class="">Self</span><span class="">) -&gt;&nbsp;</span><span style="color:rgb(112,61,170)" class="">Self</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">func</span><span class="">&nbsp;/(lhs:&nbsp;</span><span style="color:rgb(79,129,135)" class="">Self</span><span class="">, rhs:&nbsp;</span><span style="color:rgb(79,129,135)" class="">Self</span><span class="">) -&gt;&nbsp;</span><span style="color:rgb(112,61,170)" class="">Self</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">func</span><span class="">&nbsp;%(lhs:&nbsp;</span><span style="color:rgb(79,129,135)" class="">Self</span><span class="">, rhs:&nbsp;</span><span style="color:rgb(79,129,135)" class="">Self</span><span class="">) -&gt;&nbsp;</span><span style="color:rgb(112,61,170)" class="">Self</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">}</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;min-height:19px" class=""><span class=""></span><br class=""></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class=""><span style="color:rgb(187,44,162)" class="">extension</span><span class="">&nbsp;</span><span style="color:rgb(112,61,170)" class="">Double</span><span class="">&nbsp;:&nbsp;</span><span class="">NumericType</span><span class="">&nbsp;{ }</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class=""><span style="color:rgb(187,44,162)" class="">extension</span><span class="">&nbsp;</span><span style="color:rgb(112,61,170)" class="">Float</span><span class="">&nbsp; :&nbsp;</span><span class="">NumericType</span><span class="">&nbsp;{ }</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class=""><span style="color:rgb(187,44,162)" class="">extension</span><span class="">&nbsp;</span><span style="color:rgb(112,61,170)" class="">CGFloat</span><span class="">:&nbsp;</span><span class="">NumericType</span><span class="">&nbsp;{ }</span></div><div style="margin:0px;font-size:16px;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="">Int</span><span class="">&nbsp; &nbsp; :&nbsp;</span><span style="color:rgb(79,129,135)" class="">NumericType</span><span class="">&nbsp;{ }</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class=""><span style="color:rgb(187,44,162)" class="">extension</span><span class="">&nbsp;</span><span style="color:rgb(112,61,170)" class="">Int8</span><span class="">&nbsp;&nbsp; :&nbsp;</span><span class="">NumericType</span><span class="">&nbsp;{ }</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class=""><span style="color:rgb(187,44,162)" class="">extension</span><span class="">&nbsp;</span><span style="color:rgb(112,61,170)" class="">Int16</span><span class="">&nbsp; :&nbsp;</span><span class="">NumericType</span><span class="">&nbsp;{ }</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class=""><span style="color:rgb(187,44,162)" class="">extension</span><span class="">&nbsp;</span><span style="color:rgb(112,61,170)" class="">Int32</span><span class="">&nbsp; :&nbsp;</span><span class="">NumericType</span><span class="">&nbsp;{ }</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class=""><span style="color:rgb(187,44,162)" class="">extension</span><span class="">&nbsp;</span><span style="color:rgb(112,61,170)" class="">Int64</span><span class="">&nbsp; :&nbsp;</span><span class="">NumericType</span><span class="">&nbsp;{ }</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class=""><span style="color:rgb(187,44,162)" class="">extension</span><span class="">&nbsp;</span><span style="color:rgb(112,61,170)" class="">UInt</span><span class="">&nbsp;&nbsp; :&nbsp;</span><span class="">NumericType</span><span class="">&nbsp;{ }</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class=""><span style="color:rgb(187,44,162)" class="">extension</span><span class="">&nbsp;</span><span style="color:rgb(112,61,170)" class="">UInt8</span><span class="">&nbsp; :&nbsp;</span><span class="">NumericType</span><span class="">&nbsp;{ }</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class=""><span style="color:rgb(187,44,162)" class="">extension</span><span class="">&nbsp;</span><span style="color:rgb(112,61,170)" class="">UInt16</span><span class="">&nbsp;:&nbsp;</span><span class="">NumericType</span><span class="">&nbsp;{ }</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class=""><span style="color:rgb(187,44,162)" class="">extension</span><span class="">&nbsp;</span><span style="color:rgb(112,61,170)" class="">UInt32</span><span class="">&nbsp;:&nbsp;</span><span class="">NumericType</span><span class="">&nbsp;{ }</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(79,129,135)" class=""><span style="color:rgb(187,44,162)" class="">extension</span><span class="">&nbsp;</span><span style="color:rgb(112,61,170)" class="">UInt64</span><span class="">&nbsp;:&nbsp;</span><span class="">NumericType</span><span class="">&nbsp;{ }</span></div><div class=""><span class=""><br class=""></span></div></div><div class=""><br class=""></div><div class=""><div class=""><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">/// Simple iterator with generic parameters, with just a few lines of code.</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class="">/// for most numeric types (see above)</div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">/// Usage Example:</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">///</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">/// &nbsp; iterate(xmax, { $0 &gt; xmin}, -xstep,</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">///&nbsp; &nbsp; {x in</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">///&nbsp; &nbsp; &nbsp; &nbsp; print("x = \(x)")</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">///&nbsp; &nbsp; &nbsp; &nbsp; return true&nbsp; // returning false acts like a break</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">/// &nbsp; &nbsp; } )</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">///</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">///&nbsp; -Parameter vstart: Initial value</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">///&nbsp; -Parameter step:&nbsp; &nbsp; The iteration stepping value.</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">///&nbsp; -Parameter test:&nbsp; &nbsp; A block with iteration test. e.g. {$0 &gt; 10}</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">///</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">///&nbsp; -Parameter block: &nbsp; A block to be executed with each step.</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">/// &nbsp; &nbsp; &nbsp; The block must include a return true (acts like "continue")</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">/// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; or false (acts like "break")</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><div style="margin:0px;line-height:normal" class=""><span class="">/// &nbsp;-Please Note:&nbsp;</span></div><div style="margin:0px;line-height:normal" class=""><span class="">/// &nbsp;There is minor precision loss ca: 1/1000 ... 1/500&nbsp;</span></div><div style="margin:0px;line-height:normal" class=""><span class="">///&nbsp;&nbsp;when iterating with floating point numbers.</span></div><div style="margin:0px;line-height:normal" class=""><span class="">///&nbsp;&nbsp;However, in most cases this can be safely ignored.</span></div><div style="margin:0px;line-height:normal" class=""><span class="">/// &nbsp;made by ted van gaalen.</span></div><div style="margin:0px;line-height:normal" class=""><br class=""></div><div style="margin:0px;line-height:normal" class=""><br class=""></div></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span style="color:rgb(187,44,162)" class="">func</span><span class="">&nbsp;iterate&lt;T:</span><span style="color:rgb(79,129,135)" class="">NumericType</span><span class="">&gt; (</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vstart:&nbsp;&nbsp;</span><span style="color:rgb(79,129,135)" class="">T</span><span class="">,</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">_</span><span class="">&nbsp;vstep:&nbsp;&nbsp;</span><span style="color:rgb(79,129,135)" class="">T</span><span class="">,</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">_</span><span class="">&nbsp; test: (</span><span style="color:rgb(79,129,135)" class="">T</span><span class="">) -&gt;&nbsp;</span><span style="color:rgb(112,61,170)" class="">Bool</span><span class="">,</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">_</span><span class="">&nbsp;block: (</span><span style="color:rgb(79,129,135)" class="">T</span><span class="">) -&gt;&nbsp;</span><span style="color:rgb(112,61,170)" class="">Bool</span><span class="">&nbsp;)</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">{</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">var</span><span class="">&nbsp;current = vstart</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;min-height:19px" class=""><span class="">&nbsp;&nbsp; &nbsp;</span><br class=""></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">while</span><span class="">&nbsp;test(current) &amp;&amp; block(current)</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; {</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; current = current&nbsp;</span><span style="color:rgb(49,89,93)" class="">+</span><span class="">&nbsp;vstep</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; }</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">}</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><br class=""></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;min-height:19px" class=""><span class=""></span><br class=""></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">/// X,Y 2D matrix (table) iterator with generic parameters</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span style="color:rgb(187,44,162)" class="">func</span><span class="">&nbsp;iterate2D&lt;T:</span><span style="color:rgb(79,129,135)" class="">NumericType</span><span class="">&gt; (</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp;&nbsp; &nbsp; xstart:&nbsp;&nbsp;</span><span style="color:rgb(79,129,135)" class="">T</span><span class="">,&nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">_</span><span class="">&nbsp;xstep:&nbsp;</span><span style="color:rgb(79,129,135)" class="">T</span><span class="">,&nbsp;</span><span style="color:rgb(187,44,162)" class="">_</span><span class="">&nbsp;xtest: (</span><span style="color:rgb(79,129,135)" class="">T</span><span class="">) -&gt;&nbsp;</span><span style="color:rgb(112,61,170)" class="">Bool</span><span class="">,</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp;&nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">_</span><span class="">&nbsp;ystart:&nbsp;&nbsp;</span><span style="color:rgb(79,129,135)" class="">T</span><span class="">,&nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">_</span><span class="">&nbsp;ystep:&nbsp;</span><span style="color:rgb(79,129,135)" class="">T</span><span class="">,&nbsp;</span><span style="color:rgb(187,44,162)" class="">_</span><span class="">&nbsp;ytest: (</span><span style="color:rgb(79,129,135)" class="">T</span><span class="">) -&gt;&nbsp;</span><span style="color:rgb(112,61,170)" class="">Bool</span><span class="">,</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp;&nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">_</span><span class="">&nbsp;block: (</span><span style="color:rgb(79,129,135)" class="">T</span><span class="">,</span><span style="color:rgb(79,129,135)" class="">T</span><span class="">) -&gt;&nbsp;</span><span style="color:rgb(112,61,170)" class="">Bool</span><span class="">&nbsp;)</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">{</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">var</span><span class="">&nbsp;xcurrent = xstart</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">var</span><span class="">&nbsp;ycurrent = ystart</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;min-height:19px" class=""><span class="">&nbsp;&nbsp; &nbsp;</span><br class=""></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">var</span><span class="">&nbsp;dontStop =&nbsp;</span><span style="color:rgb(187,44,162)" class="">true</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;min-height:19px" class=""><span class="">&nbsp;&nbsp; &nbsp;</span><br class=""></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">while</span><span class="">&nbsp;xtest(xcurrent) &amp;&amp; dontStop</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; {</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; ycurrent = ystart</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">while</span><span class="">&nbsp;ytest(ycurrent) &amp;&amp; dontStop</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; {</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dontStop = block(xcurrent, ycurrent)</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ycurrent = ycurrent&nbsp;</span><span style="color:rgb(49,89,93)" class="">+</span><span class="">&nbsp;ystep</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; }</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; xcurrent = xcurrent&nbsp;</span><span style="color:rgb(49,89,93)" class="">+</span><span class="">&nbsp;xstep</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; }</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">}</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;min-height:19px" class=""><span class=""></span><br class=""></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;min-height:19px" class=""><span class=""></span><br class=""></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">/// X,Y,Z 3D (cubic) iterator with generic parameters:</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;min-height:19px" class=""><span class=""></span><br class=""></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span style="color:rgb(187,44,162)" class="">func</span><span class="">&nbsp;iterate3D&lt;T:</span><span style="color:rgb(79,129,135)" class="">NumericType</span><span class="">&gt; (</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; xstart:&nbsp;&nbsp;</span><span style="color:rgb(79,129,135)" class="">T</span><span class="">,&nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">_</span><span class="">&nbsp;xstep:&nbsp;</span><span style="color:rgb(79,129,135)" class="">T</span><span class="">,&nbsp;</span><span style="color:rgb(187,44,162)" class="">_</span><span class="">&nbsp;xtest: (</span><span style="color:rgb(79,129,135)" class="">T</span><span class="">) -&gt;&nbsp;</span><span style="color:rgb(112,61,170)" class="">Bool</span><span class="">,</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">_</span><span class="">&nbsp;ystart:&nbsp;&nbsp;</span><span style="color:rgb(79,129,135)" class="">T</span><span class="">,&nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">_</span><span class="">&nbsp;ystep:&nbsp;</span><span style="color:rgb(79,129,135)" class="">T</span><span class="">,&nbsp;</span><span style="color:rgb(187,44,162)" class="">_</span><span class="">&nbsp;ytest: (</span><span style="color:rgb(79,129,135)" class="">T</span><span class="">) -&gt;&nbsp;</span><span style="color:rgb(112,61,170)" class="">Bool</span><span class="">,</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">_</span><span class="">&nbsp;zstart:&nbsp;&nbsp;</span><span style="color:rgb(79,129,135)" class="">T</span><span class="">,&nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">_</span><span class="">&nbsp;zstep:&nbsp;</span><span style="color:rgb(79,129,135)" class="">T</span><span class="">,&nbsp;</span><span style="color:rgb(187,44,162)" class="">_</span><span class="">&nbsp;ztest: (</span><span style="color:rgb(79,129,135)" class="">T</span><span class="">) -&gt;&nbsp;</span><span style="color:rgb(112,61,170)" class="">Bool</span><span class="">,</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">_</span><span class="">&nbsp;block: (</span><span style="color:rgb(79,129,135)" class="">T</span><span class="">,</span><span style="color:rgb(79,129,135)" class="">T</span><span class="">,</span><span style="color:rgb(79,129,135)" class="">T</span><span class="">) -&gt;&nbsp;</span><span style="color:rgb(112,61,170)" class="">Bool</span><span class="">&nbsp;)</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">{</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">var</span><span class="">&nbsp;xcurrent = xstart</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">var</span><span class="">&nbsp;ycurrent = ystart</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">var</span><span class="">&nbsp;zcurrent = zstart</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;min-height:19px" class=""><span class="">&nbsp;&nbsp; &nbsp;</span><br class=""></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">var</span><span class="">&nbsp;dontStop =&nbsp;</span><span style="color:rgb(187,44,162)" class="">true</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;min-height:19px" class=""><span class="">&nbsp;&nbsp; &nbsp;</span><br class=""></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">while</span><span class="">&nbsp;xtest(xcurrent) &amp;&amp; dontStop</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; {</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; ycurrent = ystart</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">while</span><span class="">&nbsp;ytest(ycurrent) &amp;&amp; dontStop</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; {</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; zcurrent = zstart</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">while</span><span class="">&nbsp;ztest(zcurrent) &amp;&amp; dontStop</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dontStop = block(xcurrent, ycurrent, zcurrent)</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; zcurrent = zcurrent&nbsp;</span><span style="color:rgb(49,89,93)" class="">+</span><span class="">&nbsp;zstep</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ycurrent = ycurrent&nbsp;</span><span style="color:rgb(49,89,93)" class="">+</span><span class="">&nbsp;ystep</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; }</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; xcurrent = xcurrent&nbsp;</span><span style="color:rgb(49,89,93)" class="">+</span><span class="">&nbsp;xstep</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; }</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">}</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;min-height:19px" class=""><br class=""></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;min-height:19px" class=""><br class=""></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;min-height:19px" class=""><span style="color:rgb(187,44,162)" class="">func</span><span class="">&nbsp;testIterator()</span><span class=""></span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">{</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(209,47,27)" class=""><span class="">&nbsp;</span><span class="">&nbsp; &nbsp;</span><span style="color:rgb(49,89,93)" class="">iterate</span><span class="">(</span><span style="color:rgb(39,42,216)" class="">0.0</span><span class="">,&nbsp;</span><span style="color:rgb(39,42,216)" class="">0.5</span><span class="">, {$0 &lt;&nbsp;</span><span style="color:rgb(39,42,216)" class="">1000.00000</span><span class="">} ,</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { value&nbsp;</span><span style="color:rgb(187,44,162)" class="">in</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="color:rgb(61,29,129)" class="">print</span><span class="">(</span><span style="color:rgb(209,47,27)" class="">"Value =&nbsp;</span><span class="">\</span><span style="color:rgb(209,47,27)" class="">(</span><span class="">value</span><span style="color:rgb(209,47,27)" class="">)&nbsp;</span><span style="color:rgb(209,47,27)" class="">"</span><span class="">)</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">return</span><span class="">&nbsp;</span><span style="color:rgb(187,44,162)" class="">true</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; } )</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(209,47,27)" class=""><br class=""></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(209,47,27)" class=""><span class="">&nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">let</span><span class="">&nbsp;startv:&nbsp;</span><span style="color:rgb(112,61,170)" class="">CGFloat</span><span class="">&nbsp;= -</span><span style="color:rgb(39,42,216)" class="">20.0</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">let</span><span class="">&nbsp;stepv:&nbsp;</span><span style="color:rgb(112,61,170)" class="">CGFloat</span><span class="">&nbsp;= &nbsp;&nbsp;</span><span style="color:rgb(39,42,216)" class="">0.5</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;min-height:19px" class=""><span class="">&nbsp;&nbsp; &nbsp;</span><br class=""></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp;&nbsp;</span><span style="color:rgb(49,89,93)" class="">iterate</span><span class="">(startv, stepv, {$0 &lt;&nbsp;</span><span style="color:rgb(39,42,216)" class="">1000.00000</span><span class="">} ,</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { val&nbsp;</span><span style="color:rgb(187,44,162)" class="">in</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="color:rgb(61,29,129)" class="">print</span><span class="">(</span><span style="color:rgb(209,47,27)" class="">"R =&nbsp;</span><span class="">\</span><span style="color:rgb(209,47,27)" class="">(</span><span class="">val</span><span style="color:rgb(209,47,27)" class="">)"</span><span class="">)</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">return</span><span class="">&nbsp;</span><span style="color:rgb(187,44,162)" class="">true</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; } )</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(209,47,27)" class=""><br class=""></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(209,47,27)" class=""><span class="">&nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">let</span><span class="">&nbsp;tolerance =&nbsp;</span><span style="color:rgb(39,42,216)" class="">0.01</span><span class="">&nbsp;</span><span style="color:rgb(0,132,0)" class="">// boundary tolerance for floating point type</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;min-height:19px" class=""><span class="">&nbsp;&nbsp; &nbsp;</span><br class=""></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp;&nbsp;</span><span style="color:rgb(49,89,93)" class="">iterate2D</span><span class="">(&nbsp;</span><span style="color:rgb(39,42,216)" class="">0.0</span><span class="">,&nbsp;</span><span style="color:rgb(39,42,216)" class="">10.0</span><span class="">, { $0 &lt;&nbsp;</span><span style="color:rgb(39,42,216)" class="">100.0</span><span class="">&nbsp;+ tolerance } ,</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="color:rgb(39,42,216)" class="">0.0</span><span class="">,&nbsp;&nbsp;</span><span style="color:rgb(39,42,216)" class="">5.0</span><span class="">, { $0 &lt;&nbsp;&nbsp;</span><span style="color:rgb(39,42,216)" class="">50.0</span><span class="">&nbsp;+ tolerance } ,</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {x,y&nbsp;</span><span style="color:rgb(187,44,162)" class="">in</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="color:rgb(61,29,129)" class="">print</span><span class="">(</span><span style="color:rgb(209,47,27)" class="">"x =&nbsp;</span><span class="">\</span><span style="color:rgb(209,47,27)" class="">(</span><span class="">x</span><span style="color:rgb(209,47,27)" class="">) y =&nbsp;</span><span class="">\</span><span style="color:rgb(209,47,27)" class="">(</span><span class="">y</span><span style="color:rgb(209,47,27)" class="">)"</span><span class="">)</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">return</span><span class="">&nbsp;</span><span style="color:rgb(187,44,162)" class="">true</span><span class="">&nbsp;&nbsp;</span><span class="">// false from block stops iterating ( like break)</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } )</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(209,47,27)" class=""><br class=""></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(209,47,27)" class=""><span class="">&nbsp; &nbsp;&nbsp;</span><span style="color:rgb(49,89,93)" class="">iterate3D</span><span class="">(&nbsp;</span><span style="color:rgb(39,42,216)" class="">0.0</span><span class="">,&nbsp;&nbsp;</span><span style="color:rgb(39,42,216)" class="">10.0</span><span class="">, { $0 &lt; &nbsp;&nbsp;</span><span style="color:rgb(39,42,216)" class="">30.0</span><span class="">&nbsp;} ,&nbsp;&nbsp;</span><span style="color:rgb(0,132,0)" class="">// x</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="color:rgb(39,42,216)" class="">0.0</span><span class="">, &nbsp;&nbsp;</span><span style="color:rgb(39,42,216)" class="">5.0</span><span class="">, { $0 &lt; &nbsp;&nbsp;</span><span style="color:rgb(39,42,216)" class="">20.0</span><span class="">&nbsp;} ,&nbsp;&nbsp;</span><span style="color:rgb(0,132,0)" class="">// y</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="color:rgb(39,42,216)" class="">10.0</span><span class="">, -</span><span style="color:rgb(39,42,216)" class="">5.0</span><span class="">, { $0 &gt;&nbsp; -</span><span style="color:rgb(39,42,216)" class="">10.0</span><span class="">&nbsp;} ,&nbsp;&nbsp;</span><span style="color:rgb(0,132,0)" class="">// z</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {x,y,z&nbsp;</span><span style="color:rgb(187,44,162)" class="">in</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="color:rgb(61,29,129)" class="">print</span><span class="">(</span><span style="color:rgb(209,47,27)" class="">"x =&nbsp;</span><span class="">\</span><span style="color:rgb(209,47,27)" class="">(</span><span class="">x</span><span style="color:rgb(209,47,27)" class="">) y =&nbsp;</span><span class="">\</span><span style="color:rgb(209,47,27)" class="">(</span><span class="">y</span><span style="color:rgb(209,47,27)" class="">) z =&nbsp;</span><span class="">\</span><span style="color:rgb(209,47,27)" class="">(</span><span class="">z</span><span style="color:rgb(209,47,27)" class="">)"</span><span class="">)</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">if</span><span class="">&nbsp;z &lt;&nbsp;</span><span style="color:rgb(39,42,216)" class="">0.0</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(209,47,27)" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="color:rgb(61,29,129)" class="">print</span><span class="">&nbsp;(&nbsp;</span><span class="">"** z value&nbsp;</span><span class="">\</span><span class="">(</span><span class="">z</span><span class="">) is below zero! **"</span><span class="">&nbsp;)</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;min-height:19px" class=""><span class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><br class=""></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">return</span><span class="">&nbsp;</span><span style="color:rgb(187,44,162)" class="">false</span><span class="">&nbsp;&nbsp;</span><span class="">// (acts as break in for;;)</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class=""><span class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</span><span style="color:rgb(187,44,162)" class="">return</span><span class="">&nbsp;</span><span style="color:rgb(187,44,162)" class="">true</span><span class="">&nbsp;&nbsp;</span><span class="">// return stmt is obligatory (continue)</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;min-height:19px" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} )</div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;min-height:19px" class="">}</div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;min-height:19px" class=""><span class=""></span><br class=""></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Menlo;min-height:19px" class=""><span class=""></span><br class=""></div></div><div class=""><br class=""></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></div></blockquote><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote></div></div></blockquote></div><br class=""></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></div>_______________________________________________<br class="">
swift-users mailing list<br class="">
<a href="mailto:swift-users@swift.org" target="_blank" class="">swift-users@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br class="">
</blockquote></div>
</div></blockquote></div><br class=""></body></html>