<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged update-vals</title>
<link>https://ask.clojure.org/index.php/tag/update-vals</link>
<description></description>
<item>
<title>update-vals documentation string has a typo</title>
<link>https://ask.clojure.org/index.php/13297/update-vals-documentation-string-has-a-typo</link>
<description>&lt;pre&gt;&lt;code&gt;(doc update-vals)
-------------------------
clojure.core/update-vals
([m f])
  m f =&amp;gt; {k (f v) ...}

  Given a map m and a function f of 1-argument, returns a new map where the keys of m
  are mapped to result of applying f to the corresponding values of m.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Says &quot;...returns a new map where the &amp;gt;&amp;gt;&amp;gt;keys&amp;lt;&amp;lt;&amp;lt; of m are mapped to...&quot;. This should be &quot;values,&quot; not &quot;keys.&quot; Probably a cut/paste holdover from the update-keys doc string.&lt;/p&gt;
</description>
<category>Docs</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13297/update-vals-documentation-string-has-a-typo</guid>
<pubDate>Fri, 15 Sep 2023 22:12:07 +0000</pubDate>
</item>
<item>
<title>`update-keys` and `update-vals` missing the `&amp; args` from `update`</title>
<link>https://ask.clojure.org/index.php/12107/update-keys-and-update-vals-missing-the-args-from-update</link>
<description>&lt;p&gt;The &lt;code&gt;&amp;amp; args&lt;/code&gt; in &lt;code&gt;update&lt;/code&gt;, &lt;code&gt;swap!&lt;/code&gt; and etc are very ergonomic and compose really well, so I was surprised to learn that &lt;code&gt;update-keys&lt;/code&gt; and &lt;code&gt;update-vals&lt;/code&gt; don't have that, they're only &lt;code&gt;[m f]&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;What is the reason for this?&lt;/p&gt;
&lt;p&gt;I think adding &lt;code&gt;&amp;amp; args&lt;/code&gt; to these functions would be more consistent with the existing core functions and help avoid anon functions where not needed.&lt;/p&gt;
</description>
<category>Collections</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12107/update-keys-and-update-vals-missing-the-args-from-update</guid>
<pubDate>Tue, 09 Aug 2022 15:03:31 +0000</pubDate>
</item>
<item>
<title>`update-vals` not preserving sorted maps?</title>
<link>https://ask.clojure.org/index.php/12073/update-vals-not-preserving-sorted-maps</link>
<description>&lt;p&gt;Hello! We recently found that when applying &lt;code&gt;update-vals&lt;/code&gt; to a sorted map, it's converted back into an unsorted array/hash map due to the collection not being transientable. Example given below. As a note, this differs from &lt;code&gt;medley/map-vals&lt;/code&gt; which preserves sorting and which we were using for this functionality previously to 1.11. &lt;/p&gt;
&lt;p&gt;Is this intended behavior? If so, I'd be curious about the intent behind it :) Thanks!&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user&amp;gt; (def m (sorted-map :a 0 :b 0))
;; =&amp;gt; #'user/m
user&amp;gt; (type m)
;; =&amp;gt; clojure.lang.PersistentTreeMap
user&amp;gt; (type (update-vals m inc))
;; =&amp;gt; clojure.lang.PersistentArrayMap
user&amp;gt; (type (medley.core/map-vals inc m))
;; =&amp;gt; clojure.lang.PersistentTreeMap
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Collections</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12073/update-vals-not-preserving-sorted-maps</guid>
<pubDate>Wed, 27 Jul 2022 08:35:05 +0000</pubDate>
</item>
</channel>
</rss>