<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="">I would also be happy with ‘fold’/‘unfold’. The term of art argument applies to fold in the same way it does for ‘reduce’.</div><div class=""><br class=""></div><div class="">Otherwise (if we stick with ‘reduce’) I find both ‘induce’ and ‘expand’ to be good names. I can also suggest ‘accumulate’.</div><div class="">In each of these cases I prefer the local consistency of a pair of functions, both being verbs, over the global consistency of a pair of functions, one being a verb and one a noun (for consistency with other functions in the standard library). As such, I like the name ‘iterate’.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Regarding the name ’sequence’: I find that it works well as a name for the two versions that was specified in Revision 3:</div><div class=""><br class=""></div><div class=""><font face="Menlo" style="font-size: 11px;" class="">func unfold<T>(_ initialElement: T, applying: T -> T) -> UnfoldSequence<T></font></div><div class=""><font class=""><font face="Menlo" style="font-size: 11px;" class="">func unfold<T, State>(_ initialState: State, applying: State -> (T, State)?) -> UnfoldSequence<T></font><br class=""><br class=""></font></div><div class="">corresponding to `<span style="font-size: 11px;" class=""><font face="Menlo" class="">iterate</font></span>` and the list `<font face="Menlo" style="font-size: 11px;" class="">unfoldr</font>` (also a specialization of `<font face="Menlo" style="font-size: 11px;" class="">ana</font>` (for anamorphism)):</div><div class=""><font class=""> </font></div><div class=""><font face="Menlo" style="font-size: 11px;" class="">iterate :: (a -> a) -> a -> [a]</font></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class="">unfoldr :: </span></font><span style="font-size: 11px; font-family: Menlo;" class="">(</span><span style="font-size: 11px; font-family: Menlo;" class="">b</span><span style="font-size: 11px; font-family: Menlo;" class=""> </span><span style="font-size: 11px; font-family: Menlo;" class="">-></span><span style="font-size: 11px; font-family: Menlo;" class=""> </span><span style="font-size: 11px; font-family: Menlo;" class="">Maybe</span><span style="font-size: 11px; font-family: Menlo;" class=""> </span><span style="font-size: 11px; font-family: Menlo;" class="">(</span><span style="font-size: 11px; font-family: Menlo;" class="">a</span><span style="font-size: 11px; font-family: Menlo;" class="">,</span><span style="font-size: 11px; font-family: Menlo;" class="">b</span><span style="font-size: 11px; font-family: Menlo;" class="">))</span><span style="font-size: 11px; font-family: Menlo;" class=""> </span><span style="font-size: 11px; font-family: Menlo;" class="">-></span><span style="font-size: 11px; font-family: Menlo;" class=""> </span><span style="font-size: 11px; font-family: Menlo;" class="">b</span><span style="font-size: 11px; font-family: Menlo;" class=""> </span><span style="font-size: 11px; font-family: Menlo;" class="">-></span><span style="font-size: 11px; font-family: Menlo;" class=""> </span><span style="font-size: 11px; font-family: Menlo;" class="">[</span><span style="font-size: 11px; font-family: Menlo;" class="">a</span><span style="font-size: 11px; font-family: Menlo;" class="">] </span></div><div class=""><font face="Menlo" style="font-size: 11px;" class=""><br class=""></font></div><div class="">But would like to point out that by putting the return type in the name, it makes it less suitable as a potential general name for unfolding to other data structures (e.g trees).</div><div class=""><br class=""></div><div class=""> - David</div><br class=""><div><blockquote type="cite" class=""><div class="">On 06 May 2016, at 09:12, Cole Campbell 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=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class=""></div><div class="">I don't know if it's considered too late at this point to rename 'reduce', but I'll add an enthusiastic +1 to renaming it to 'fold' and adding 'unfold'. 'Fold' is just as obvious a name as 'reduce', IMO (actually I even prefer it). I think changing it now with other source-breaking changes is better than moving forward with 'reduce' and a corresponding function with a confusing name. Fold/unfold would fit in beautifully with the prefix/suffix pairings already in the standard library.</div><div class=""><br class=""></div><div class="">Cole</div><div class=""><br class="">On May 6, 2016, at 1:29 AM, David Hart via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div class="">If we are discussing naming changes to reduce, here's my personal opinion:</div><div class=""><br class=""></div><div class="">* When I first encountered it, I understood exactly what it did because I knew that term of art. If it was named <b class="">sequence</b>, I would have been confused.</div><div class="">* If we are discussing name changes, I'd personally vote to change it to <b class="">fold</b>. It is the other term of art used for it, and it makes <b class="">unfold</b> work.</div><div class=""><br class=""></div><div class="">David</div><div class=""><br class=""></div><div class="">On 05 May 2016, at 22:39, Chris Lattner via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On May 5, 2016, at 1:03 PM, Erica Sadun <<a href="mailto:erica@ericasadun.com" class="">erica@ericasadun.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="">On May 4, 2016, at 5:50 PM, Chris Lattner via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><div class=""><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:) & Sequence.drop(while:) - These are *accepted* as specified in revision 3 of the proposal.<br class=""></div></div></blockquote><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">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. 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. “unfold” is problematic, despite its precedence in other language, because Swift calls the corresponding operation “reduce” and not “fold”. No one could get excited about “unreduce”. “iterate” was also considered, but a noun is more appropriate than an verb in this case. 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. </div></div></div></blockquote><div class=""><br class=""></div><div class="">I’m not a naming guru, but my understanding is that ‘reduce’ was picked because it was term of art (like map), which is what allowed the misuse of a verb.</div><br class=""></div><div class="">One idea that came out of the core team discussion was something like:</div><div class=""><br class=""></div><div class=""> sequence(from: 0) { $0 += 42 }<br class=""></div><div class=""><br class=""></div><div class="">Since it returns a sequence.</div><div class=""><br class=""></div><div class="">-Chris</div><br class=""></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" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote></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" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>