Skip to content

Instantly share code, notes, and snippets.

@vsmart
Last active August 29, 2015 14:18
Show Gist options
  • Save vsmart/8deecda2be8fb3e6afa0 to your computer and use it in GitHub Desktop.
Save vsmart/8deecda2be8fb3e6afa0 to your computer and use it in GitHub Desktop.
Macro for Clojure debugging
;; This is a useful macro for clojure debugging
(defmacro dbg[x] `(let [x# ~x] (println "dbg:" '~x "=" x#) x#))
;; Use it anywhere in your expression like so:
(defn factorial[n] (if (= n 0) 1 (* n (dbg (factorial (dec n))))))
;; Taken from [stackoverflow](http://stackoverflow.com/a/2352280/789070)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment