(defmacro encode [get-key]
(let [body (eval get-key)]
`(~@body)))
It turns out this is actually the macro I'm looking for, but I still don't
want to use eval :(
Honestly, it looks to me that you are concocting something overl
(def dict
{:key `(str "obj isn't defined in this scope" (:blah ~'obj))})
(defmacro encode [ncode get-key]
Ok, so it turns out I have other issues. Args is (:keys dict) and that
doesn't evaluate
(def dict
{:key `(str "obj isn't defined in this scope" (:blah ~'obj))})
Thanks everyone. That's what I needed.
On Fri, Mar 29, 2019 at 3:25 AM Alexander Yakushev
wrote:
> Looks like you are missing a few unquotes. Is this what you expected?
>
> (def dict
> {:key `(str "obj isn't defined in this scope" (:blah ~'obj))})
>
> (defmacro my-macro [my-obj & args]
> `(
my-macro [obj & args]
`(let [o# ~obj
a# ~args]
(apply (fn [obj args] (print ~(:key dict) args)) o# a#)))
This approach looks even better and still doesn't work :(
On Thursday, March 28, 2019 at 9:58:25 PM UTC-6, Natha
(def dict
{:key `(str "obj isn't defined in this scope" (:blah ~'obj))})
(defmacro my-macro [obj & args]
`(print ~(:key dict) ~@args))
(macroexpand '(my-macro {:blah "thingy"} "test string"))
I have a n
(defn rotate [a n]
(let [l (count a)
off (mod (+ (mod n l) l) l)]
(concat (drop off a) (take off a
(rotate '((1 2) (3 4) (5 6) (7 8) (9 10)) 3)
=> ((7 8) (9 10) (1 2) (3 4) (5 6))
On Saturday, March 23, 2
Concat
(defn rotate [a n]
(let [l (count a)
off (-> (mod n l) (+ (mod n l) l) l)]
(concat (drop off a) (take off a
(rotate '((1 2) (3 4) (5 6) (7 8) (9 10)) 3)
=> ((7 8) (9 10) (1 2) (3 4) (5 6))
On Saturd
(defn rotate [a n]
(let [l (count a)
off (mod (+ (mod n l) l) l)]
(flatten (list (drop off a) (take off a)
(rotate '(1 2 3 4 5) -1) => (5 1 2 3 4)
(rotate '(1 2 3 4 5) -6) => (5 1 2