Last active
August 29, 2015 14:21
-
-
Save vsnguyen/3c61368e636f039c595d to your computer and use it in GitHub Desktop.
Clojure: Macro
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 | |
;; only run at compile time | |
;; Simple | |
(defmacro unless [condition expression] | |
(list 'if condition nil expression)) | |
(unless (> 2 3) true) | |
;; (if (> 2 3) true nil) | |
;; Multiple Expressions | |
(defmacro unless | |
([condition expression] | |
(list 'if condition nil expression)) | |
([condition expression-1 expression-2] | |
(list 'if condition expression-1 expression-2))) | |
(unless (> 2 3) true false) | |
;; (if (> 2 3) true false) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment