I would also be happy with ‘fold’/‘unfold’. The term of art argument applies to fold in the same way it does for ‘reduce’.
Otherwise (if we stick with ‘reduce’) I find both ‘induce’ and ‘expand’ to be good names. I can also suggest ‘accumulate’. 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’. Regarding the name ’sequence’: I find that it works well as a name for the two versions that was specified in Revision 3: func unfold<T>(_ initialElement: T, applying: T -> T) -> UnfoldSequence<T> func unfold<T, State>(_ initialState: State, applying: State -> (T, State)?) -> UnfoldSequence<T> corresponding to `iterate` and the list `unfoldr` (also a specialization of `ana` (for anamorphism)): iterate :: (a -> a) -> a -> [a] unfoldr :: (b -> Maybe (a,b)) -> b -> [a] 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). - David > On 06 May 2016, at 09:12, Cole Campbell via swift-evolution > <[email protected]> wrote: > > 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. > > Cole > > On May 6, 2016, at 1:29 AM, David Hart via swift-evolution > <[email protected] <mailto:[email protected]>> wrote: > >> If we are discussing naming changes to reduce, here's my personal opinion: >> >> * When I first encountered it, I understood exactly what it did because I >> knew that term of art. If it was named sequence, I would have been confused. >> * If we are discussing name changes, I'd personally vote to change it to >> fold. It is the other term of art used for it, and it makes unfold work. >> >> David >> >> On 05 May 2016, at 22:39, Chris Lattner via swift-evolution >> <[email protected] <mailto:[email protected]>> wrote: >> >>> >>>> On May 5, 2016, at 1:03 PM, Erica Sadun <[email protected] >>>> <mailto:[email protected]>> wrote: >>>> >>>> On May 4, 2016, at 5:50 PM, Chris Lattner via swift-evolution >>>> <[email protected] <mailto:[email protected]>> wrote: >>>>> >>>>> Proposal link: >>>>> https://github.com/apple/swift-evolution/blob/master/proposals/0045-scan-takewhile-dropwhile.md >>>>> >>>>> <https://github.com/apple/swift-evolution/blob/master/proposals/0045-scan-takewhile-dropwhile.md> >>>>> >>>>> Sequence.prefix(while:) & Sequence.drop(while:) - These are *accepted* as >>>>> specified in revision 3 of the proposal. >>>> >>>> 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: >>>> >>>> Core team writes: >>>>> 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 to let the community discuss it >>>>> more. >>>> >>>> A few thoughts: >>>> >>>> * 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. >>> >>> 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. >>> >>> One idea that came out of the core team discussion was something like: >>> >>> sequence(from: 0) { $0 += 42 } >>> >>> Since it returns a sequence. >>> >>> -Chris >>> >>> _______________________________________________ >>> swift-evolution mailing list >>> [email protected] <mailto:[email protected]> >>> https://lists.swift.org/mailman/listinfo/swift-evolution >>> <https://lists.swift.org/mailman/listinfo/swift-evolution> >> _______________________________________________ >> swift-evolution mailing list >> [email protected] <mailto:[email protected]> >> https://lists.swift.org/mailman/listinfo/swift-evolution >> <https://lists.swift.org/mailman/listinfo/swift-evolution> > _______________________________________________ > swift-evolution mailing list > [email protected] > https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
