Hi Alex,
That works perfect!
I've another (possibly stupid) question.
If I want this to work with your macro:
(def abc ["a" "b" "c"])
(def-name abc a)
How could I get that to work?
Thanks,
--anders
Den tisdagen den 23:e juli 2013 kl. 09:48:18 UTC+2 skrev Alex Baranosky:
>
> Hi Anders,
>
> (defm
Thanks a lot guys, I'll try it out tomorrow.
Anders
--
--
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 p
t is almost certainly not a good idea :) But educational,
> definitely.
>
>
> On Tue, Jul 23, 2013 at 12:48 AM, Baishampayan Ghose wrote:
>
>> Since the bindings are a function of the data that's passed in, IMO
>> you don't need a anaphoric macro for thi
Good point BG,
I think it is almost certainly not a good idea :) But educational,
definitely.
On Tue, Jul 23, 2013 at 12:48 AM, Baishampayan Ghose wrote:
> Since the bindings are a function of the data that's passed in, IMO
> you don't need a anaphoric macro for this.
Hi Anders,
(defmacro def-name [name-vec & body]
`(let ~(vec (interleave (map symbol name-vec)
name-vec))
~@body))
user=> (macroexpand '(def-name ["a" "b" "c"] 1 2 3))
(let* [a "a" b "b" c "c"] 1 2 3)
user=> (def-name ["a" "b" "c"] a)
"a"
user=> (def-name ["a" "
Since the bindings are a function of the data that's passed in, IMO
you don't need a anaphoric macro for this.
For example -
(defmacro def-names [names & body]
(let [bindings* (vec (mapcat (juxt symbol identity) names))]
`(let ~bindings*
~@body)))
As to whether it
Hi,
I want to write a macro that introduces new variables from data.
The data is a vector and looks like this for example: ["a" "b" "c"]
I want to use the macro like this:
(def-names ["a" "b" "c"] (str a b))
What code I want the macro to produce from the above is the following:
(let [a "a"