Last active
August 29, 2015 14:18
-
-
Save vsmart/8deecda2be8fb3e6afa0 to your computer and use it in GitHub Desktop.
Macro for Clojure debugging
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
;; 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