document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. (defn current-balance [accounts]
  2.   (loop [balance 0
  3.          accounts accounts]
  4.     (if (first accounts)
  5.       (let [[account transactions] (first accounts)]
  6.         (recur (+ (inspect balance
  7.                            "Starting balance processing" account)
  8.                   (inspect (sum-transactions transactions)
  9.                            "Total transactions amount"))
  10.                (rest accounts)))
  11.       balance)))
  12.  
  13. ;;;; Having fixed the infinite loop, the code still doesn\'t work -- it throws an
  14. ;;;; error.  Adding some more printlns via `inspect` we now see this:
  15.  
  16. ;; 0 -- Starting balance processing :savings
  17. ;; 1200.23M -- Total transactions amount
  18. ;; 1200.23M -- Starting balance processing :checking
  19. ;; NumberFormatException   java.math.BigDecimal.<init> (BigDecimal.java:494)
');