<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="">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><blockquote type="cite" class=""><div class="">On 2016-01-08, at 15:53:09, Craig Cruden <<a href="mailto:ccruden@novafore.com" class="">ccruden@novafore.com</a>> 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). </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. </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 …. 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 <<a href="mailto:me@jo2.co" class="">me@jo2.co</a>> 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 <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> 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 = </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> .Buy(<span class="" style="color: rgb(187, 44, 162);">let</span> quantity, <span class="" style="color: rgb(187, 44, 162);">let</span> price) <span class="" style="color: rgb(187, 44, 162);">where</span> <span class="" style="color: rgb(112, 61, 170);">Double</span>(quantity) * price > <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;"> <span class="Apple-tab-span" style="white-space: pre;">                </span><span class="" style="color: rgb(112, 61, 170);">Double</span>(quantity) * price * <span class="" style="color: rgb(79, 129, 135);">vipCommissionRate</span> / <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> .Buy(<span class="" style="color: rgb(187, 44, 162);">let</span> quantity, <span class="" style="color: rgb(187, 44, 162);">let</span> price) in</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="Apple-tab-span" style="white-space: pre;">                </span><span class="" style="color: rgb(112, 61, 170);">Double</span>(quantity) * price * <span class="" style="color: rgb(79, 129, 135);">commissionRate</span> / <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> .Sell(<span class="" style="color: rgb(187, 44, 162);">let</span> quantity, <span class="" style="color: rgb(187, 44, 162);">let</span> price) <span class="" style="color: rgb(187, 44, 162);">where</span> <span class="" style="color: rgb(112, 61, 170);">Double</span>(quantity) * price > <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;"> <span class="Apple-tab-span" style="white-space: pre;">                </span><span class="" style="color: rgb(112, 61, 170);">Double</span>(quantity) * price * <span class="" style="color: rgb(79, 129, 135);">vipCommissionRate</span> / <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> .Sell(<span class="" style="color: rgb(187, 44, 162);">let</span> quantity, <span class="" style="color: rgb(187, 44, 162);">let</span> price) in</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="Apple-tab-span" style="white-space: pre;">                </span><span class="" style="color: rgb(112, 61, 170);">Double</span>(quantity) * price * <span class="" style="color: rgb(79, 129, 135);">commissionRate</span> / <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 = </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);"> case</span><span style="font-family: Menlo; font-size: 11px;" class=""> .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=""> quantity, </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=""> price) </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=""> </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 > </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=""> </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 * </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=""> / </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);"> case</span><span style="font-family: Menlo; font-size: 11px;" class=""> .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=""> quantity, </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=""> price) in</span><br class=""><blockquote type="cite" class=""></blockquote><span style="font-family: Menlo; font-size: 11px;" class=""> </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 * </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=""> / </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);"> case</span><span style="font-family: Menlo; font-size: 11px;" class=""> .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=""> quantity, </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=""> price) </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=""> </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 > </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=""> </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 * </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=""> / </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);"> case</span><span style="font-family: Menlo; font-size: 11px;" class=""> .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=""> quantity, </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=""> price) in</span><br class=""><blockquote type="cite" class=""></blockquote><span style="font-family: Menlo; font-size: 11px;" class=""> </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 * </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=""> / </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"> </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></body></html>