(defn current-balance [accounts]
(loop [balance 0
accounts accounts]
(if (first accounts)
(let [[account transactions] (first accounts)]
(recur (+ (inspect balance
"Starting balance processing" account)
(inspect (sum-transactions transactions)
"Total transactions amount"))
(rest accounts)))
balance)))
;;;; Having fixed the infinite loop, the code still doesn\'t work -- it throws an
;;;; error. Adding some more printlns via `inspect` we now see this:
;; 0 -- Starting balance processing :savings
;; 1200.23M -- Total transactions amount
;; 1200.23M -- Starting balance processing :checking
;; NumberFormatException java.math.BigDecimal.<init> (BigDecimal.java:494)