<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="">Makes sense. I like the idea of having a pattern matching case system for closures. Would be very useful across all sorts of functions, including custom closures developers create.&nbsp;<br class=""><div class="">
<br class="Apple-interchange-newline"><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""><font color="#8d8d8d" class=""><span class="Apple-converted-space">&nbsp;</span>Nerd . Designer . Developer</font></span><font color="#464646" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Jo Albright</span></font><br style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On Jan 8, 2016, at 4:22 AM, Craig Cruden &lt;<a href="mailto:ccruden@novafore.com" class="">ccruden@novafore.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Conceivably anywhere you accept a function - you could accept a set of functions based on pattern matching.<div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 2016-01-08, at 15:53:09, Craig Cruden &lt;<a href="mailto:ccruden@novafore.com" class="">ccruden@novafore.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">There is no reason why it could not be called that…. but…. it would be much more restrictive (then of course you would have switchFilter, switchReduce, switchFold etc.<div class=""><br class=""></div><div class="">The idea is that instead of having just a map which takes only a single function, in now takes a set of functions that are applicable based on pattern matching conditions (the entire set covers all cases). &nbsp;</div><div class=""><br class=""></div><div class="">In the case of reduce, I could take a list of types which apply different calculations depending on type which sum together to produce a single value. &nbsp;</div><div class=""><br class=""></div><div class="">Of you could just have a single case that covers all cases but allows you to decompose a type/value into something more friendly to work with.</div><div class=""><br class=""></div><div class="">i.e. key/value …. &nbsp;n.map { case (k, v) in …. }</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class=""><div class=""><blockquote type="cite" class=""><div class="">On 2016-01-08, at 15:35:30, Jo Albright &lt;<a href="mailto:me@jo2.co" class="">me@jo2.co</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class="">On Jan 8, 2016, at 2:36 AM, Craig Cruden via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class=""><div class=""><div class=""><blockquote type="cite" class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><font color="#bb2ca2" class="">let commission =&nbsp;</font><span class="" style="color: rgb(79, 129, 135);">trade</span><span class="">.map {</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(187, 44, 162);"><span class="Apple-tab-span" style="white-space: pre;">        </span>case</span>&nbsp;.Buy(<span class="" style="color: rgb(187, 44, 162);">let</span>&nbsp;quantity,&nbsp;<span class="" style="color: rgb(187, 44, 162);">let</span>&nbsp;price)&nbsp;<span class="" style="color: rgb(187, 44, 162);">where</span>&nbsp;<span class="" style="color: rgb(112, 61, 170);">Double</span>(quantity) * price &gt;&nbsp;<span class="" style="color: rgb(39, 42, 216);">10000 in</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;&nbsp;<span class="Apple-tab-span" style="white-space: pre;">                </span><span class="" style="color: rgb(112, 61, 170);">Double</span>(quantity) * price *&nbsp;<span class="" style="color: rgb(79, 129, 135);">vipCommissionRate</span>&nbsp;/&nbsp;<span class="" style="color: rgb(39, 42, 216);">100</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(187, 44, 162);"><span class="Apple-tab-span" style="white-space: pre;">        </span>case</span>&nbsp;.Buy(<span class="" style="color: rgb(187, 44, 162);">let</span>&nbsp;quantity,&nbsp;<span class="" style="color: rgb(187, 44, 162);">let</span>&nbsp;price) in</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;&nbsp;<span class="Apple-tab-span" style="white-space: pre;">                </span><span class="" style="color: rgb(112, 61, 170);">Double</span>(quantity) * price *&nbsp;<span class="" style="color: rgb(79, 129, 135);">commissionRate</span>&nbsp;/&nbsp;<span class="" style="color: rgb(39, 42, 216);">100</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(187, 44, 162);"><span class="Apple-tab-span" style="white-space: pre;">        </span>case</span>&nbsp;.Sell(<span class="" style="color: rgb(187, 44, 162);">let</span>&nbsp;quantity,&nbsp;<span class="" style="color: rgb(187, 44, 162);">let</span>&nbsp;price)&nbsp;<span class="" style="color: rgb(187, 44, 162);">where</span>&nbsp;<span class="" style="color: rgb(112, 61, 170);">Double</span>(quantity) * price &gt;&nbsp;<span class="" style="color: rgb(39, 42, 216);">10000 in</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;&nbsp;<span class="Apple-tab-span" style="white-space: pre;">                </span><span class="" style="color: rgb(112, 61, 170);">Double</span>(quantity) * price *&nbsp;<span class="" style="color: rgb(79, 129, 135);">vipCommissionRate</span>&nbsp;/&nbsp;<span class="" style="color: rgb(39, 42, 216);">100</span></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(187, 44, 162);"><span class="Apple-tab-span" style="white-space: pre;">        </span>case</span>&nbsp;.Sell(<span class="" style="color: rgb(187, 44, 162);">let</span>&nbsp;quantity,&nbsp;<span class="" style="color: rgb(187, 44, 162);">let</span>&nbsp;price) in</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">&nbsp; &nbsp;&nbsp;<span class="Apple-tab-span" style="white-space: pre;">                </span><span class="" style="color: rgb(112, 61, 170);">Double</span>(quantity) * price *&nbsp;<span class="" style="color: rgb(79, 129, 135);">commissionRate</span>&nbsp;/&nbsp;<span class="" style="color: rgb(39, 42, 216);">100</span></div></div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(39, 42, 216);">}</span></div></div></div></div></blockquote></div></div></div></div></div></div></blockquote></div></blockquote><br class=""></div><div class="">Is there any reason it couldn’t be “switchMap” instead of “map”? Would follow the design of “flatMap” naming. It would also help explain what is happening by mapping based on a switch statement.</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""></blockquote><font color="#bb2ca2" class="" style="font-family: Menlo; font-size: 11px;">let commission =&nbsp;</font><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(79, 129, 135);">trade</span><span class="" style="font-family: Menlo; font-size: 11px;">.switchMap {</span></div><div class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""><br class=""></span></font><blockquote type="cite" class=""></blockquote><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">&nbsp; &nbsp; case</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;.Buy(</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">let</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;quantity,&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">let</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;price)&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">where</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(112, 61, 170);">Double</span><span style="font-family: Menlo; font-size: 11px;" class="">(quantity) * price &gt;&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(39, 42, 216);">10000 in</span><br class=""><blockquote type="cite" class=""></blockquote><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp; &nbsp;&nbsp;</span><span class="Apple-tab-span" style="font-family: Menlo; font-size: 11px; white-space: pre;">                </span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(112, 61, 170);">Double</span><span style="font-family: Menlo; font-size: 11px;" class="">(quantity) * price *&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(79, 129, 135);">vipCommissionRate</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;/&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(39, 42, 216);">100</span><br class=""><blockquote type="cite" class=""></blockquote><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">&nbsp; &nbsp; case</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;.Buy(</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">let</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;quantity,&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">let</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;price) in</span><br class=""><blockquote type="cite" class=""></blockquote><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp; &nbsp;&nbsp;</span><span class="Apple-tab-span" style="font-family: Menlo; font-size: 11px; white-space: pre;">                </span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(112, 61, 170);">Double</span><span style="font-family: Menlo; font-size: 11px;" class="">(quantity) * price *&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(79, 129, 135);">commissionRate</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;/&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(39, 42, 216);">100</span><br class=""><blockquote type="cite" class=""></blockquote><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">&nbsp; &nbsp; case</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;.Sell(</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">let</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;quantity,&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">let</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;price)&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">where</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(112, 61, 170);">Double</span><span style="font-family: Menlo; font-size: 11px;" class="">(quantity) * price &gt;&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(39, 42, 216);">10000 in</span><br class=""><blockquote type="cite" class=""></blockquote><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp; &nbsp;&nbsp;</span><span class="Apple-tab-span" style="font-family: Menlo; font-size: 11px; white-space: pre;">                </span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(112, 61, 170);">Double</span><span style="font-family: Menlo; font-size: 11px;" class="">(quantity) * price *&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(79, 129, 135);">vipCommissionRate</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;/&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(39, 42, 216);">100</span><br class=""><blockquote type="cite" class=""></blockquote><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">&nbsp; &nbsp; case</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;.Sell(</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">let</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;quantity,&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);">let</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;price) in</span><br class=""><blockquote type="cite" class=""></blockquote><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp; &nbsp;&nbsp;</span><span class="Apple-tab-span" style="font-family: Menlo; font-size: 11px; white-space: pre;">                </span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(112, 61, 170);">Double</span><span style="font-family: Menlo; font-size: 11px;" class="">(quantity) * price *&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(79, 129, 135);">commissionRate</span><span style="font-family: Menlo; font-size: 11px;" class="">&nbsp;/&nbsp;</span><span class="" style="font-family: Menlo; font-size: 11px; color: rgb(39, 42, 216);">100</span></div><div class=""><font color="#272ad8" face="Menlo" class=""><span style="font-size: 11px;" class=""><br class=""></span></font><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class=""><div class=""><div class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="color: rgb(39, 42, 216);">}</span></div></div></div></div></div></div></div></div></div></div></div><div class=""><br class=""></div><div apple-content-edited="true" class="">
<br class="Apple-interchange-newline"><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""><font color="#8d8d8d" class=""><span class="Apple-converted-space">&nbsp;</span>Nerd . Designer . Developer</font></span><font color="#464646" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Jo Albright</span></font><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div><br class=""><br class=""></div></div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></body></html>