Created
February 24, 2012 09:06
-
-
Save mowat27/1899666 to your computer and use it in GitHub Desktop.
Example of using a macro to rewrite defn in Clojure
This file contains 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
(ns homoiconic.my-defn) | |
; ----------- --- --- -- -- - - | |
(defn hello [what] | |
(str "hello " what)) | |
(hello "world") | |
; ----------- --- --- -- -- - - | |
(defmacro my-defn [form args name] | |
`(defn ~name ~args ~form)) | |
(my-defn | |
(str "HELLO " what) | |
[what] my-hello) | |
(my-hello "world") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment