Skip to content

Instantly share code, notes, and snippets.

@athos
Created April 16, 2012 13:27
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 athos/2398796 to your computer and use it in GitHub Desktop.
Save athos/2398796 to your computer and use it in GitHub Desktop.
an example of Clojure 1.4 reader literals
(defn defn-reader [body]
(let [name (symbol (name (first (keys (dissoc (meta body) :tag)))))
args (read-string (:tag (meta body)))]
`(defn ~name ~args ~(seq body))))
(.bindRoot #'default-data-readers {'defn #'defn-reader})
#defn ^:fact ^"[x]"
[
if (= x 0)
1
(* x (fact (dec x)))
]
(fact 10) ;=> 3628800
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment