clojuredesign-podcast

Discussions around the Functional Design in Clojure podcast - https://clojuredesign.club/
jumar 2019-10-16T08:09:10.055900Z

@neumann thanks a lot for the clarification and examples - very much appreciated. Could you also share the utility functions you use for namespaced maps (like selecting all keys with given ns)?

neumann 2019-10-16T15:31:17.057Z

I don't have code from a project I can share, but I just whipped this up:

(defn select-keys-by-namespace
  [m ns]
  (reduce-kv
    (fn [m k v]
      (if (= ns (namespace k))
        (assoc m k v)
        m))
    {} m))

neumann 2019-10-16T15:32:01.057200Z

=> (select-keys-by-namespace {:player/id 42 :player/name "Boom" :team/id 1001} "player")
#:player{:id 42, :name "Boom"}

neumann 2019-10-16T15:32:45.057500Z

Although in the future, I may be inclined to use: https://weavejester.github.io/medley/medley.core.html#var-filter-keys

neumann 2019-10-16T15:34:16.058600Z

@jumar You're welcome. I'm happy to chat about it!