Last active
May 30, 2018 14:31
-
-
Save alex-dixon/4dee1b6a81fa7c86d010aabfddefe17a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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