[swift-evolution] [swift-evolution-announce] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)
Vladimir.S
svabox at gmail.com
Tue Nov 21 15:39:23 CST 2017
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, Thorsten Seitz via swift-evolution wrote:
> +1
>
> Am 20.11.2017 um 21:32 schrieb Jon Shier via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>>:
>
>> This is why I really like compact/compactMap.
>>
>>> On Nov 20, 2017, at 3:31 PM, John McCall via swift-evolution <swift-evolution at swift.org
>>> <mailto:swift-evolution at swift.org>> wrote:
>>>
>>>> On Nov 20, 2017, at 12:22 PM, BJ Homer <bjhomer at gmail.com <mailto:bjhomer at gmail.com>> wrote:
>>>>> On Nov 20, 2017, at 10:09 AM, Drew Crawford via swift-evolution <swift-evolution at swift.org
>>>>> <mailto:swift-evolution at swift.org>> 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 because *each* component in the term is inaccurate:
>>>>
>>>> filterMap is indeed an awkward name for this use case, just like flatMap is. In my experience, about half of my use
>>>> cases use the identity closure, and half actually make use of the closure in a meaningful way. I would support a
>>>> proposal to add something like Sequence.dropNils (actual name to be determined), and then we could let this proposal
>>>> target the non-identity-closure use case.
>>>
>>> If the identity closure (i.e. "please remove the nils from this sequence") is a common use case, then I absolutely
>>> agree that we should consider adding a specific operation for that, and that name might illuminate the right name for
>>> the mapping version.
>>>
>>> John.
>>>
>>> _______________________________________________
>>> swift-evolution mailing list
>>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
More information about the swift-evolution
mailing list