I am stuck trying to do something probably basic with clojure macro. I simplified my example to the minimal below. Let's say I have:
(def a {:i 0})
And I want to define b to something like:
(def b (my-func a a a a a a ... a a a a))
At compile time, I know how many a I want (for example 3). But to remove code redundancy, and for better code, I would like to parameterize the number of a. I would like something like:
(def b (my-func (some-magic-macro 3 a)))
that would expand to
(def b (my-func a a a))
Tried a bunch of things with macrodef, repeat, quoting etc... without much succes due to my limited understanding of clojure at this stage
Thank you people!
repeatin the position ofsome-magic-macro? Perhaps you want this:(def b (apply my-func (repeat 3 a))).applyfunction in the documentation. Study the difference that(+ 1 2 3 4 5)and(apply + [1 2 3 4 5])will help you understand that.