You mean there's no way to define bar? Here's some context. I had a metafunction, conc:
(defn conc [& subrules] (fn [tokens] (loop [subrule-queue (seq subrules), remaining-tokens (seq tokens), products []] (if (nil? subrule-queue) [products remaining-tokens] (let [[subrule-products subrule-remainder :as subrule-result] ((first subrule-queue) remaining-tokens)] (when-not (nil? subrule-result) (recur (rest subrule-queue) subrule-remainder (conj products subrule-products)))))))) I changed it to a macro to avoid evaluating its arguments until needed: (defn conc* [tokens & subrules] (loop [subrule-queue (seq subrules), remaining-tokens (seq tokens), products []] (if (nil? subrule-queue) [products remaining-tokens] (let [[subrule-products subrule-remainder :as subrule-result] ((first subrule-queue) remaining-tokens)] (when-not (nil? subrule-result) (recur (rest subrule-queue) subrule-remainder (conj products subrule-products))))))) (defmacro conc [& subrules] `(fn [tokens#] (conc* tokens# ~...@subrules))) I had another function called factor=: (defn factor= [factor subrule] (apply conc (replicate factor arg))) When I changed conc to a macro, factor= didn't work anymore. Is there no way of fixing factor=? On Feb 7, 3:09 pm, Laurent PETIT <laurent.pe...@gmail.com> wrote: > Hello, > > Is it theoretical, or do you have a concrete use case we could try to help > you with ? > > 2009/2/7 samppi <rbysam...@gmail.com> > > > > > > > Let's say I have a macro: > > > (defmacro foo [& args] ...) > > > I want to do something equivalent to this: > > (defn bar-fn [factor arg] > > (apply foo (replicate factor arg))) > > > ...but since I can't take values of macros, I have to do something > > like this, right? > > > (defmacro bar [factor arg] > > `(foo ~@(replicate factor arg))) > > > ...but then when I use it I get a ClassCastException if I try to do > > something like (bar (dec 5) something), because then Clojure tries to > > evaluate (replicate '(dec 5) 'something). > > > So how should I rewrite bar to behave like bar-fn, then? > > -- > Cordialement, > > Laurent PETIT --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---