<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="">On May 4, 2016, at 5:50 PM, Chris Lattner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><div><blockquote type="cite" class=""><br class="Apple-interchange-newline"><div class=""><div class="">Proposal link: <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0045-scan-takewhile-dropwhile.md" class="">https://github.com/apple/swift-evolution/blob/master/proposals/0045-scan-takewhile-dropwhile.md</a><br class=""><br class="">Sequence.prefix(while:) &amp; Sequence.drop(while:) - These are *accepted* as specified in revision 3 of the proposal.<br class=""></div></div></blockquote><div><br class=""></div><div>I'm still a little sad we didn't go for `prefix`/`suffix` or `take`/`drop` pairs that linguistically matched.Nonetheless I'm gratified these are hopping into the language. That said, I'm going to put on my painters cap to consider selecting some exterior latex for the feature I was most looking forward to in this proposal:</div><div><br class=""></div><div>Core team writes:</div><blockquote type="cite" class=""><div class=""><div class="">unfold(_:applying:) - This addition is *rejected* by the core team as written, but deserves more discussion in the community, and potentially could be the subject of a future proposal. &nbsp;The core team felt that the utility of this operation is high enough to be worth including in the standard library, but could not find an acceptable name for it. &nbsp;“unfold” is problematic, despite its precedence in other language, because Swift calls the corresponding operation “reduce” and not “fold”. &nbsp;No one could get excited about “unreduce”. &nbsp;&nbsp;“iterate” was also considered, but a noun is more appropriate than an verb in this case. &nbsp;Given the lack of a good name, the core team preferred to reject <b class=""><u class="">to let the community discuss it more</u></b>.</div></div></blockquote></div><br class=""><div class="">A few thoughts:</div><div class=""><br class=""></div><div class="">* I'm not sure why a noun is more appropriate than a verb. Reduce isn't a noun, prefix isn't a noun, drop isn't a noun.&nbsp;</div><div class="">* Not a fan of unfold or unreduce, either.</div><div class="">* Why not `induce` as a counter to `reduce`? (induction/reduction if you want to noun it, which I don't)</div><div class=""><br class=""></div><div class="">Stepping back, the definition of `reduce` is:</div><div class=""><br class=""></div><div class=""><div class="">&nbsp; &nbsp; Returns the result of repeatedly calling `combine` with an accumulated value&nbsp;</div><div class="">&nbsp; &nbsp; initialized to `initial` and each element of `self`, in turn</div></div><div class=""><br class=""></div><div class="">&nbsp; &nbsp;&nbsp;<font face="Menlo" class="">public func reduce&lt;T&gt;(initial: T, @noescape combine: (T, Self.Generator.Element) throws -&gt; T) rethrows -&gt; T</font></div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; e.g. print("Hello".characters.reduce(" ", combine: {$0 + String($1) + " "}))</div><div class=""><br class=""></div><div class="">The definition of whatever *this* is, is more or less:</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; Returns the lazy sequence of repeatedly calling `generate` with an accumulated value</div><div class="">&nbsp; &nbsp; initialized to `initial`. The sequence terminates when the generation closure returns `nil`.</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; <font face="Menlo" class="">public func ???&lt;T&gt;(initial: T, generate: (T) -&gt; T?) -&gt; Sequence&lt;T&gt;</font></div><div class=""><br class=""></div><div class="">So why not `induce`? It's got a cute name relationship with `reduce`?</div><div class=""><br class=""></div><div class=""><div class="">var seq = induce(10, generate: { $0 == 0 ? nil : $0 - 1 })</div><div class="">print(Array(seq)) //&nbsp;[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]</div><div class=""><br class=""></div><div class="">seq = induce(1, generate:{ $0 * 2 }).prefix(while: { $0 &lt; 1000 })</div><div class="">print(Array(seq)) // [2, 4, 8, 16, 32, 64, 128, 256, 512]</div></div><div class=""><br class=""></div><div class="">-- E</div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>