Re: [swift-evolution] [swift-evolution-announce] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-21 Thread Jonathan Hull via swift-evolution
What about mapOrNil? > On Nov 21, 2017, at 3:00 PM, Wallacy via swift-evolution > wrote: > > Let’s think I little. If the ideia is choose the best name to explain the > function: > > If the function drop the nil values and after that does a map operation. > Names

Re: [swift-evolution] [swift-evolution-announce] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-21 Thread Wallacy via swift-evolution
Let’s think I little. If the ideia is choose the best name to explain the function: If the function drop the nil values and after that does a map operation. Names like dropNilAndMap make sense, right? But we are talking about functions that mimics the berraviour of Functional programming

Re: [swift-evolution] [swift-evolution-announce] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-21 Thread Vladimir.S via swift-evolution
FWIW +1 For me 'compact' means drop "empty space" and return data items in the same order. I'd like to keep names exactly 'compact/compactMap' instead of 'compacted/compactedMap', but OK to have the latter if 'compact' will not be accepted as 'terms of art'. Vladimir. On 21.11.2017 8:47,

Re: [swift-evolution] [swift-evolution-announce] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-21 Thread Benjamin G via swift-evolution
I have a question regarding the general term "compact" vs something more specific like "remove nil" : Could we imagine other usages on different types for "compact" ? map / flatmap has the whole category theory behind it, making it meaningful for many different types. "Filter" is also generic,

Re: [swift-evolution] [swift-evolution-announce] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-21 Thread Tino Heth via swift-evolution
My favorite would be a variation of Scalas choice (collect / collectResults). The word compact (or similar choices like condense, squeeze, pack, compress…) always remind me on compression — my first association of „compact“ would be a transform that turns [1, 2, 2, 3] into [1, 2, 3] (like the

Re: [swift-evolution] [swift-evolution-announce] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-20 Thread Thorsten Seitz via swift-evolution
+1 > Am 20.11.2017 um 21:32 schrieb Jon Shier via swift-evolution > : > > This is why I really like compact/compactMap. > >>> On Nov 20, 2017, at 3:31 PM, John McCall via swift-evolution >>> wrote: >>> On Nov 20, 2017, at 12:22 PM,

Re: [swift-evolution] [swift-evolution-announce] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-20 Thread Jonathan Hull via swift-evolution
I agree that filterMap is just as confusing and awkward as flatMap, if not more. Filter works on Bools, not nils. It is just asking for trouble/confusion, and I would hate to rename this again next year. If the word ‘filter’ must be used, then I recommend using ‘filteringMap()’ to lessen

Re: [swift-evolution] [swift-evolution-announce] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-20 Thread Erica Sadun via swift-evolution
On Nov 20, 2017, at 1:31 PM, John McCall via swift-evolution wrote: > >> On Nov 20, 2017, at 12:22 PM, BJ Homer > > wrote: >>> On Nov 20, 2017, at 10:09 AM, Drew Crawford via swift-evolution >>>

Re: [swift-evolution] [swift-evolution-announce] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-20 Thread Jon Shier via swift-evolution
This is why I really like compact/compactMap. > On Nov 20, 2017, at 3:31 PM, John McCall via swift-evolution > wrote: > >> On Nov 20, 2017, at 12:22 PM, BJ Homer > > wrote: >>> On Nov 20, 2017, at 10:09 AM, Drew Crawford

Re: [swift-evolution] [swift-evolution-announce] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-20 Thread John McCall via swift-evolution
> On Nov 20, 2017, at 12:22 PM, BJ Homer wrote: >> On Nov 20, 2017, at 10:09 AM, Drew Crawford via swift-evolution >> > wrote: >> >> The typical case for this function in my code is the identity closure, that >> is

Re: [swift-evolution] [swift-evolution-announce] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-20 Thread BJ Homer via swift-evolution
> On Nov 20, 2017, at 10:09 AM, Drew Crawford via swift-evolution > wrote: > > The typical case for this function in my code is the identity closure, that is > > let a: [Int?] = ... > print(a.filterMap {$0}) > > filterMap is quite poor for this situation

Re: [swift-evolution] [swift-evolution-announce] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-20 Thread Drew Crawford via swift-evolution
The typical case for this function in my code is the identity closure, that is     let a: [Int?] = ...     print(a.filterMap {$0}) filterMap is quite poor for this situation because *each* component in the term is inaccurate: 1.  While we are filtering in the "english sense", in Swift the word