Skip to content

Instantly share code, notes, and snippets.

@dschneider
Forked from vsmart/gist:8deecda2be8fb3e6afa0
Last active August 29, 2015 14:18
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 dschneider/3b8ffea29937fdf5ba00 to your computer and use it in GitHub Desktop.
Save dschneider/3b8ffea29937fdf5ba00 to your computer and use it in GitHub Desktop.
Debug clojure cool
;; 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