<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="">What about mapOrNil?<div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 21, 2017, at 3:00 PM, Wallacy 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=""><div dir="auto" class=""><div style="color:rgb(49,49,49);word-spacing:1px" dir="auto" class=""><div dir="auto" style="font-size:1rem" class="">Let’s think I little. If the ideia is choose the best name to explain the function:</div><div dir="auto" class=""><br class=""></div><div dir="auto" style="font-size:1rem" class="">If the function drop the nil values and after that does a map operation. Names like dropNilAndMap make sense, right?</div><div dir="auto" class=""><br class=""></div><div dir="auto" style="font-size:1rem" class="">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{**}</div></div><div dir="auto" style="color:rgb(49,49,49);word-spacing:1px" class=""><br class=""></div><div dir="auto" style="color:rgb(49,49,49);font-size:1rem;word-spacing:1px" class="">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)</div><div dir="auto" style="color:rgb(49,49,49);word-spacing:1px" class=""><br class=""></div><div dir="auto" style="color:rgb(49,49,49);font-size:1rem;word-spacing:1px" class="">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.</div><div dir="auto" style="color:rgb(49,49,49);word-spacing:1px" class=""><br class=""></div><div dir="auto" style="color:rgb(49,49,49);font-size:1rem;word-spacing:1px" class="">Array.ToNonOptional()</div><div dir="auto" style="color:rgb(49,49,49);font-size:1rem;word-spacing:1px" class="">Array.DropNil()</div><div dir="auto" style="color:rgb(49,49,49);font-size:1rem;word-spacing:1px" class="">Array.WithNonOptional()</div><div dir="auto" style="color:rgb(49,49,49);font-size:1rem;word-spacing:1px" class="">Etc...</div><div dir="auto" style="color:rgb(49,49,49);word-spacing:1px" class=""><br class=""></div><div dir="auto" style="color:rgb(49,49,49);font-size:1rem;word-spacing:1px" class="">If we only focus in this functionality, the ‘map’ part is already solved.</div><div dir="auto" style="color:rgb(49,49,49);font-size:1rem;word-spacing:1px" class=""><br class=""></div></div><div class=""><br class=""><div class="gmail_quote"><div class="">Em ter, 21 de nov de 2017 às 08:47, Benjamin G via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> escreveu:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">I have a question regarding the general term "compact" vs something more specific like "remove nil" : <div class="">Could we imagine other usages on different types for "compact" ?</div><div class=""><br class=""></div><div class="">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. </div><div class=""><br class=""></div><div class="">"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. </div><div class=""><br class=""></div><div class="">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).</div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Nov 21, 2017 at 10:47 AM, Tino Heth via swift-evolution <span class=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">My favorite would be a variation of Scalas choice (collect / collectResults).<br class="">
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).<br class="">
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.<br class="">
<div class="m_-6827864556965686767HOEnZb"><div class="m_-6827864556965686767h5">_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
</div></div></blockquote></div><br class=""></div>
_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
</blockquote></div></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=""></div></body></html>