This seems like a bug to me. user> `[~@(mapcat #(list (keyword %) (str %)) '(a b c))] [:a "a" :b "b" :c "c"] user> `(~@(mapcat #(list (keyword %) (str %)) '(a b c))) (:a "a" :b "b" :c "c") user> `#{~@(mapcat #(list (keyword %) (str %)) '(a b c))} #{"a" "b" "c" :a :c :b} user> `{~@(mapcat #(list (keyword %) (str %)) '(a b c))} ; Evaluation aborted. ArrayIndexOutOfBounds user> `{~(keyword "x") ~(str "x")} {:x "x"} user> `{~@(list (keyword "x") (str "x"))} ; Evaluation aborted. ArrayIndexOutOfBounds
unquote seems to work with maps, but unquote-splicing fails even in the simplest form with maps. On Sun, Sep 5, 2010 at 2:19 PM, ingokr <ing...@gmail.com> wrote: > Hello -- > > I am trying to gain a better understanding of Clojure's macro > language. > > The output I am aiming for (and which is to be used as code in another > macro) is as follows: > > {:a a :b b :c c :d d} > > The attempt I made is as follows: > > (defmacro tm [& args] > `{~@(mapcat (fn [x] (list (keyword x) x)) args)}) > > Obviously, I am making a very basic mistake, because at the REPL I > get: > > --- > user=> (defmacro tm [& args] > `{~@(mapcat (fn [x] (list (keyword x) x)) args)}) > java.lang.ArrayIndexOutOfBoundsException: 1 > java.lang.Exception: Unmatched delimiter: ) > --- > > Any pointers are greatly appreciated. > > Ingolf > > -- > 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 -- http://www.apgwoz.com -- 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