Skip to content

Instantly share code, notes, and snippets.

@alex-dixon
Last active May 30, 2018 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alex-dixon/4dee1b6a81fa7c86d010aabfddefe17a to your computer and use it in GitHub Desktop.
Save alex-dixon/4dee1b6a81fa7c86d010aabfddefe17a to your computer and use it in GitHub Desktop.
(defmacro deflet [bindings & body]
`(do ~@(for [[sym expr] (partition 2 (destructure bindings))]
(list 'def sym expr))
~@body))
(defmacro defbindings [bindings]
`(do ~@(for [[sym expr] (partition 2 (destructure bindings))]
(list 'def sym expr))))
(defmacro deflast [sym]
`(def ~sym *1))
;(deflet [foo 1
; [_ bar] [1 2]
; {:keys [baz]} {:baz 3}]
; (+ foo bar baz))
;=> 6
;(+ 1 1)
;(deflast foo)
;foo => 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment