I actually did this just the other day, to create a simple C-style enum macro (I assume someone has a better version; this was a learning exercise). You can see my project at www.github.com/amalloy/enum. It sounds like your problem might be constructing the symbol to define; the solution will look something like:
(let [fn-sym (->> name (str "prefix-") symbol)] `(defn ~fn-sym [args] body)) On Sep 10, 12:39 pm, icemaze <icem...@gmail.com> wrote: > Hi, I'm developing a small DSL with Clojure and I need to define many > similar functions. I'd like to do that programmatically, of course. > > My solution (involving a simple macro) doesn't work, so I won't bother > you with it. I'll post it if anyone asks. > > Basically what I need is: given a list of keywords, for each keyword x > i need to define a function whose name is (str "prefix-" (name x)). > The function has a very short body which uses x in one place > (something like (fn [n] (= n x))). > > Can you help me please? I've been banging my head against this for > over four hours and I'm getting a little frustrated. > > Thanks. -- 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