Very clever, Meikel.
--~--~-~--~~~---~--~~
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 wit
Hi,
On Aug 3, 11:43 pm, samppi wrote:
> (def my-map {:a 2})
> (defn process-a-map [arg] ...)
> ; Turns maps into corresponding vectors.
> ; (process-a-map my-map) returns ['*foo* :blah].
>
> (my-macro a-map ; Last statement
> (do-something))
The answer which should leave the
On Mon, Aug 3, 2009 at 8:01 PM, CuppoJava wrote:
>
> You can use eval to retrieve the value of a-map when the macro is
> expanded.
>
> (let [value (eval a-map)]
> `(binding ~(vec (process-a-map value)) ~...@forms))
>
> I've programmed some substantial programs now in Clojure though, and
> I've ne
On Mon, Aug 3, 2009 at 5:43 PM, samppi wrote:
> I'm getting stuck because a-map always gets passed into my-macro
> as a symbol.
>
> (defmacro my-macro [a-map & forms] ; Naive implementation
>`(binding ~(vec (process-a-map a-map)) ~...@forms))
Try
(defmacro my-macro [a-map & forms] ; Naive
You can use eval to retrieve the value of a-map when the macro is
expanded.
(let [value (eval a-map)]
`(binding ~(vec (process-a-map value)) ~...@forms))
I've programmed some substantial programs now in Clojure though, and
I've never had to use this. Perhaps there is another way to achieve
wha
I'm trying to make a macro my-macro so that the last statement in:
(def my-map {:a 2})
(defn process-a-map [arg] ...)
; Turns maps into corresponding vectors.
; (process-a-map my-map) returns ['*foo* :blah].
(my-macro a-map ; Last statement
(do-something))
expands to:
(bind