Skip to content

Instantly share code, notes, and snippets.

@yuanmai
Created December 3, 2012 14:28
Show Gist options
  • Save yuanmai/4195358 to your computer and use it in GitHub Desktop.
Save yuanmai/4195358 to your computer and use it in GitHub Desktop.
Trace
user> (defn fib[n] (if (< n 2) n (+ (fib (- n 1)) (fib (- n 2)))))
#'user/fib
user> (use 'clojure.tools.trace)
nil
user> (trace-vars fib)
#'user/fib
user> (fib 3)
TRACE t3166: (user/fib 3)
TRACE t3167: | (user/fib 2)
TRACE t3168: | | (user/fib 1)
TRACE t3168: | | => 1
TRACE t3169: | | (user/fib 0)
TRACE t3169: | | => 0
TRACE t3167: | => 1
TRACE t3170: | (user/fib 1)
TRACE t3170: | => 1
TRACE t3166: => 2
2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment