Re: Trouble with advanced macros

2019-03-30 Thread Nathan Rogers
(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

Re: Trouble with advanced macros

2019-03-30 Thread Nathan Rogers
(def dict {:key `(str "obj isn't defined in this scope" (:blah ~'obj))}) (defmacro encode [ncode get-key]

Re: Trouble with advanced macros

2019-03-30 Thread Nathan Rogers
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))})

Re: Trouble with advanced macros

2019-03-29 Thread Nathan Rogers
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] > `(

Re: Trouble with advanced macros

2019-03-28 Thread Nathan Rogers
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

Trouble with advanced macros

2019-03-28 Thread Nathan Rogers
(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

Re: Missing fns: rotate & rotate-while

2019-03-23 Thread Nathan Rogers
(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

Re: Missing fns: rotate & rotate-while

2019-03-23 Thread Nathan Rogers
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

Re: Missing fns: rotate & rotate-while

2019-03-22 Thread Nathan Rogers
(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