1. 48
    1. 8

      Example of the new keyword argument / map function call syntax:

      (defn destr [& {:keys [a b] :as opts}]
        [a b opts])
      
      (destr :a 1)
      ->[1 nil {:a 1}]
      
      (destr {:a 1 :b 2})
      ->[1 2 {:a 1 :b 2}]
      
      1. 6

        I’m so glad the Clojure team is adding all of these new functions, like update-keys and update-vals. It’s easy to say (as they have in the past), “The implementation is simple, so just write it yourself.” But this leads to a proliferation of implementations that have subtly different semantics and performance characteristics, which makes it hard to move between codebases.

        Here’s to adding the rest of weavejester’s medley library to clojure.core! 😉

        1. 3

          Indeed, there were a lot of different implementations of Mapping a function on the values of a map in Clojure on Stack Overflow. I just posted a newer answer pointing people towards update-vals and update-keys.

          I hadn’t heard of weavejester’s Medley library. Links: source code at GitHub – weavejester/medley; Medley’s API documentation for map-vals and map-keys. The library’s other functions look handy.

          1. 2

            Thanks for posting the links, I should have done that!