document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. ;; Original, un-instrumented function
  2. (defn as-currency
  3.   "Money amounts are transmitted as \\"$2.44\\".
  4.  Parse this and return a numeric type."
  5.   [currency-amount]
  6.   (-> (subs currency-amount 1)
  7.       (bigdec)))
  8.  
  9.  
  10. ;; Instrumented versions:
  11. (defn as-currency
  12.   "Money amounts are transmitted as \\"$2.44\\".
  13.  Parse this and return a numeric type."
  14.   [currency-amount]
  15.   (let [currency (-> (subs currency-amount 1)
  16.                      (bigdec))]
  17.     (log/debug currency)
  18.     currency))
  19.  
  20. (defn as-currency
  21.   "Money amounts are transmitted as \\"$2.44\\".
  22.  Parse this and return a numeric type."
  23.   [currency-amount]
  24.   (-> (subs currency-amount 1)
  25.       (bigdec)
  26.       ((fn [x] (log/debug x) x))))
  27.  
  28. (defn as-currency
  29.   "Money amounts are transmitted as \\"$2.44\\".
  30.  Parse this and return a numeric type."
  31.   [currency-amount]
  32.   (doto (-> (subs currency-amount 1)
  33.             (bigdec))
  34.     (log/debug)))
  35.  
  36. ;;;; The instrumented versions all output the same logging data:
  37.  
  38. ;; 18-02-07 03:11:12 DEBUG [ex.money:52] - 1200.20
  39. ;; 18-02-07 03:11:12 DEBUG [ex.money:52] - 0.03
  40. ;; 18-02-07 03:11:12 DEBUG [ex.money:52] - 120.00
  41. ;; 18-02-07 03:11:12 DEBUG [ex.money:52] - 5.99
  42. ;; 18-02-07 03:11:12 DEBUG [ex.money:52] - 20
  43. ;; 18-02-07 03:11:12 DEBUG [ex.money:52] - 12.33
  44. ;; NumberFormatException   java.math.BigDecimal.<init> (BigDecimal.java:494)
');