<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="">Sorry, I was too quick to send that email… Here is something from a playground that works:<div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(17, 109, 181);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ab4ca9" class="">extension</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">Dictionary</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> {</span></div><p style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span><br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(255, 169, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures" class="">/// An immutable version of update. Returns a new dictionary containing self's values and the key/value passed in.</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures; color: #ab4ca9" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> withUpdate(key: </span><span style="font-variant-ligatures: no-common-ligatures; color: #116db5" class="">Key</span><span style="font-variant-ligatures: no-common-ligatures" class="">, value: </span><span style="font-variant-ligatures: no-common-ligatures; color: #116db5" class="">Value</span><span style="font-variant-ligatures: no-common-ligatures" class="">) -&gt; </span><span style="font-variant-ligatures: no-common-ligatures; color: #116db5" class="">Dictionary</span><span style="font-variant-ligatures: no-common-ligatures" class="">&lt;</span><span style="font-variant-ligatures: no-common-ligatures; color: #116db5" class="">Key</span><span style="font-variant-ligatures: no-common-ligatures" class="">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #116db5" class="">Value</span><span style="font-variant-ligatures: no-common-ligatures" class="">&gt; {</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">                </span></span><span style="font-variant-ligatures: no-common-ligatures; color: #ab4ca9" class="">var</span><span style="font-variant-ligatures: no-common-ligatures" class=""> result = </span><span style="font-variant-ligatures: no-common-ligatures; color: #ab4ca9" class="">self</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">                </span>result[key] = value</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">                </span></span><span style="font-variant-ligatures: no-common-ligatures; color: #ab4ca9" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> result</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ab4ca9" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> dict1 = [</span><span style="font-variant-ligatures: no-common-ligatures; color: #ab4ca9" class="">"joe"</span><span style="font-variant-ligatures: no-common-ligatures" class="">: </span><span style="font-variant-ligatures: no-common-ligatures; color: #ab4ca9" class="">3</span><span style="font-variant-ligatures: no-common-ligatures" class="">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #ab4ca9" class="">"mary"</span><span style="font-variant-ligatures: no-common-ligatures" class="">: </span><span style="font-variant-ligatures: no-common-ligatures; color: #ab4ca9" class="">4</span><span style="font-variant-ligatures: no-common-ligatures" class="">]</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ab4ca9" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> dict2 = dict1.</span><span style="font-variant-ligatures: no-common-ligatures; color: #00a779" class="">reduce</span><span style="font-variant-ligatures: no-common-ligatures" class="">([:]) { dict2, element </span><span style="font-variant-ligatures: no-common-ligatures; color: #ab4ca9" class="">in</span><span style="font-variant-ligatures: no-common-ligatures" class=""> dict2.</span><span style="font-variant-ligatures: no-common-ligatures; color: #00a779" class="">withUpdate</span><span style="font-variant-ligatures: no-common-ligatures" class="">(element.</span><span style="font-variant-ligatures: no-common-ligatures; color: #ab4ca9" class="">0</span><span style="font-variant-ligatures: no-common-ligatures" class="">, value: element.</span><span style="font-variant-ligatures: no-common-ligatures; color: #ab4ca9" class="">1</span><span style="font-variant-ligatures: no-common-ligatures" class=""> * </span><span style="font-variant-ligatures: no-common-ligatures; color: #ab4ca9" class="">5</span><span style="font-variant-ligatures: no-common-ligatures" class="">) }</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #00a779" class="">print</span><span style="font-variant-ligatures: no-common-ligatures" class="">(dict2)</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Remember, map can be implemented in terms of reduce…</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div><blockquote type="cite" class=""><div class="">On Aug 31, 2016, at 2:17 PM, Jens Alfke &lt;<a href="mailto:jens@mooseyard.com" class="">jens@mooseyard.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=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Aug 31, 2016, at 10:51 AM, Daniel Tartaglia &lt;<a href="mailto:danielt1263@gmail.com" class="">danielt1263@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Alegreya-Regular; font-size: 15px; font-style: normal; font-variant-caps: 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="">I use the below to do this:</span><div class="" style="font-family: Alegreya-Regular; font-size: 15px; font-style: normal; font-variant-caps: 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;"><br class=""></div><div class="" style="font-family: Alegreya-Regular; font-size: 15px; font-style: normal; font-variant-caps: 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;">dict2 = dict1.map { $0.withUpdate($0.0, value: $0.1) }</div></div></blockquote></div><br class=""><div class="">I don’t see how this can work. Dictionary.map returns an Array, not a Dictionary.</div><div class="">Also, in the callback function $0 is the key, so your Dictionary.withUpdate method only makes sense if the key type of the Dictionary is another Dictionary, which seems … very unusual.</div><div class=""><br class=""></div><div class="">(To clarify, I wasn’t asking how to accomplish this; it’s pretty simple to write it either as an extension method or as a simple one-off ‘for’ loop. I was just making sure it wasn’t already in the standard library, since it seems an obvious thing to have.)</div><div class=""><br class=""></div><div class="">—Jens</div></div></div></blockquote></div><br class=""></div></body></html>