I would like to create function names programmatically. So far, I have code that works:
(defn create [endpoints] (doseq [{:keys [action method url]} endpoints] (let [endpoint-fn (if (re-matches #".*/:id(/.*)?" url) (fn [id session] (method (string/replace url #":id" id) session)) (fn [session] (method url session)))] (intern *ns* (symbol action) endpoint-fn)))) This creates functions from an array of hashes of the form {:action "index" :method api/get :url "url"}. But I want to move this to a namespace where I can call it from multiple other namespaces. As soon as I replace this function with the following, it stops working: (defn create [a-ns endpoints] (doseq [{:keys [action method url]} endpoints] (let [endpoint-fn (if (re-matches #".*/:id(/.*)?" url) (fn [id session] (method (string/replace url #":id" id) session)) (fn [session] (method url session)))] (intern a-ns (symbol action) endpoint-fn)))) ;; From other ns: (other-ns/create *ns* endpoints) Where am I going wrong? David -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en