[swift-evolution] [swift-evolution-announce] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)
Wallacy
wallacyf at gmail.com
Tue Nov 21 17:00:41 CST 2017
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 languages, doesn’t apear the be “functional” drop nils and make
a map in the same operation instead in two steps: dropNils().map{**}
I think we only need to make a function (or a property) to easily drop
(remove or whatever name) and then feal free to call a map or other
function on it. (Or call a map and drop the nils after, how knows)
The role problem is the operation by itself, is confusing because is too
specific and the main use for this is the identity operation for just
remove the optional level.
Array.ToNonOptional()
Array.DropNil()
Array.WithNonOptional()
Etc...
If we only focus in this functionality, the ‘map’ part is already solved.
Em ter, 21 de nov de 2017 às 08:47, Benjamin G via swift-evolution <
swift-evolution at swift.org> escreveu:
> 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, because the
> operation of filtering has a wide range of application.
>
> "Compact", like Tino suggested, would have the general meaning of
> "reducing the size by removing similar elements". Removing nils doesn't
> seem to be a special case of this general definition.
>
> If we give "compact" the strict definition of "removing nil", then i don't
> understand the need for a general term, instead of something like
> "dropNils" (not much longer to write).
>
>
> On Tue, Nov 21, 2017 at 10:47 AM, Tino Heth via swift-evolution <
> swift-evolution at swift.org> wrote:
>
>> 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 shell tool uniq).
>> But there’s a long list of verbs with similar meaning, so if there’s a
>> consensus for compact (or compacted…), I join that camp.
>> _______________________________________________
>> swift-evolution mailing list
>> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171121/6fb980b6/attachment.html>
More information about the swift-evolution
mailing list