code-reviews

dharrigan 2020-02-13T08:52:45.022400Z

If I have a map of fully qualified keys, i.e, {:foo/bar "baz" :foo/wibble "wobble"}, is there a better way to return a new map with the namespace removed, i.e., :foo/, leaving just :bar? So, the result would be {:bar "baz" :wibble "wobble"}. My initial attempt is this (map #(s/rename-keys % {:foo/bar :bar :foo/wibble :wobble})) and use that in a transducer.

dharrigan 2020-02-13T08:53:41.023100Z

The downside of my approach is that I need to know every key name, whereas I just want to throw a map to something, with a prefix and say, remove all :foo/ thank you very much sir!

dharrigan 2020-02-13T08:54:30.023500Z

(p.s., s/rename-keys comes from clojure.set)

2020-02-13T18:35:57.024200Z

(into {} (map (fn [[k v]] [(keyword (name k)) v])) m) is a more general way to do it

dharrigan 2020-02-13T19:42:28.024600Z

oooh

dharrigan 2020-02-13T19:42:37.024800Z

very handy, thank you!