Skip to content

Instantly share code, notes, and snippets.

@scotthaleen
Created December 9, 2016 15:28
Show Gist options
  • Select an option

  • Save scotthaleen/be984e8819e20a85d63bfe71067d9b3d to your computer and use it in GitHub Desktop.

Select an option

Save scotthaleen/be984e8819e20a85d63bfe71067d9b3d to your computer and use it in GitHub Desktop.
fully qualify keys for a namespace
(defn ns-qualified-keys
"
takes a namespace and map of kv and converts it to namespace qualified keys
(ns-qualified-keys 'foo.bar {:port 80})
;;=> {:foo.bar/port 80}
"
[ns m]
(into {}
(for [[k v] m]
[(keyword (str ns) (name k)) v])))
;; usage
(ns my.ns)
(ns-qualified-keys *ns* {:foo 1 :bar 2})
;;=> {:my.ns/foo 1, :my.ns/bar 2}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment