-
-
Save dschneider/3b8ffea29937fdf5ba00 to your computer and use it in GitHub Desktop.
Debug clojure cool
This file contains hidden or 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