Skip to content

Instantly share code, notes, and snippets.

@craftybones
Last active December 29, 2016 14:10
Show Gist options
  • Save craftybones/cd06557b01e94aa605d8a06958d26c6e to your computer and use it in GitHub Desktop.
Save craftybones/cd06557b01e94aa605d8a06958d26c6e to your computer and use it in GitHub Desktop.
(defn foo [x y]
`(intern *ns* ~x ~y))
(defmacro def-symbols-across-range
[[from step] & symbols]
(list* 'do
(map foo symbols (range))))
;; updated
(defn foo [x y]
`(intern *ns* (quote ~x) ~y))
(defmacro def-symbols-across-range
[[from step] & symbols]
(list* 'do
(map foo symbols (range))))
;; I want to say
;; (def-symbols-across-range [1 3]
;; foo
;; bar
;; etc)
;; I don't want to say
;; (def-symbols-across-range [1 3]
;; 'foo
;; 'bar
;; 'etc)
@jjl
Copy link

jjl commented Dec 29, 2016

(defmacro def-symbols-across-range
  [[from step] & syms]
  `(do (map foo ~(map #(list 'quote %)) (range)))

@craftybones
Copy link
Author

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment