ianp a écrit : > I'm trying to create a macro that will splice in some additional > elements to a structure. If I have an input struture like so: > > (p (s (c foo bar)) (s (c baz qux))) > > I'd like to be able to do (splice grp layout (rest my-data)) and have > it return: > > ((s grp layout (c foo bar)) (s grp layout (c baz qux))) > > Here's the closest I came: > > (defmacro splice [a b & body] > (let [sbody (map (fn [f] (list* (first f) a b (rest f))) body)] > `~sbody)) >
`~sbody is equivalent to body > but it's just returning an empty list, anyone see what I;m doing > wrong? > splice works well: => (macroexpand-1 '(splice grp layout (s (c foo bar)) (s (c baz qux)))) ((s grp layout (c foo bar)) (s grp layout (c baz qux))) How did you test splice? hth Christophe -- Professional: http://cgrand.net/ (fr) On Clojure: http://clj-me.blogspot.com/ (en) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---