<div dir="ltr">It would certainly be clearer that the state is changing on each "iteration", but I'm not sure it's worth such a long parameter label. Maybe <span style="font-size:12.8px">`sequence(state:update:)</span><span style="font-size:12.8px">`?</span></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 19, 2016 at 8:46 PM, Patrick Smith <span dir="ltr"><<a href="mailto:pgwsmith@gmail.com" target="_blank">pgwsmith@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>Would `sequence(mutatingState:next:)` perhaps be clearer?</div><div><br></div><br><div><blockquote type="cite"><div>On 20 May 2016, at 10:37 AM, Trent Nadeau via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Ah, yes. I apologize. The fact that state is inout, and the same instance is always passed in confused me. Thanks for the correction.</div><div class="gmail_extra" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br><div class="gmail_quote">On Thu, May 19, 2016 at 7:46 PM, Brent Royal-Gordon<span> </span><span dir="ltr"><<a href="mailto:brent@architechies.com" target="_blank">brent@architechies.com</a>></span><span> </span>wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span>> Also note that there's a typo in the second example:<br>><br>> for view in sequence(initial: someView, next: { $0.<br>> superview }) {<br>><br>> // someView, someView.superview, someView.superview.superview, ...<br>><br>> }<br>><br>><br>> should be:<br>><br>> for view in sequence(state: someView, next: { $0.<br>> superview }) {<br>><br>> // someView, someView.superview, someView.superview.superview, ...<br>><br>> }<br><br></span>I don't think these are mistakes—in each iteration of the loop, $0 is supposed to be the view from the previous iteration.<br><br>If you wanted an example using `state`, here's one which is roughly equivalent to `stride(from: 1.0, to: 2.0, by: 0.1)`, using a non-error-accumulating algorithm:<br><br> <span> </span>let start = 1.0<br> <span> </span>let end = 2.0<br> <span> </span>let distance = 0.1<br><br> <span> </span>for color in sequence(state: -1.0, next: { $0 += 1; let next = start + $0 * distance; return next < end ? next : nil }) {<br> <span> </span>…<br> <span> </span>}<span class="HOEnZb"><font color="#888888"><br><span><font color="#888888"><br>--<br>Brent Royal-Gordon<br>Architechies<br><br></font></span></font></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>--<span> </span><br><div>Trent Nadeau</div></font></span></div><span class="HOEnZb"><font color="#888888"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">_______________________________________________</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">swift-evolution mailing list</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="mailto:swift-evolution@swift.org" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">swift-evolution@swift.org</a><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></font></span></div></blockquote></div><br></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Trent Nadeau</div>
</div>