When one is programming in an imperative programming languages such as Java one can conveniently add trace statements. For example:
for (int i=0; i<10; i++) {
// do something
// do something
System.out.println("Some trace statement");
// do something
}
How does one accomplish this in a LISP dialect such as Clojure - for example say I wanted to add a trace just before recur:
(def fact
(fn [n]
(loop [cnt n acc 1]
(if (zero? cnt)
acc
;; say I want to add a trace here
(recur (dec cnt) (* acc cnt))))))
Notes:
- The method should be relatively as simple as adding a line
- For example if I were to use a do block -- I have to reformat, make sure I close the brackets appropriately