~willvaughn/kata

4cdbcaada7d26231692dbebcca3531e166e191bf — William Vaughn 1 year, 11 months ago bec2e70
exercism interest is interesting solution
1 files changed, 16 insertions(+), 6 deletions(-)

M exercism/clojure/interest-is-interesting/src/interest_is_interesting.clj
M exercism/clojure/interest-is-interesting/src/interest_is_interesting.clj => exercism/clojure/interest-is-interesting/src/interest_is_interesting.clj +16 -6
@@ 1,16 1,26 @@
(ns interest-is-interesting)

(defn abs [x]
  (max x (- x)))

(defn interest-rate
  "TODO: add docstring"
  "Select interest rate depending on balance amount."
  [balance]
  )
  (cond (neg? balance) -3.213
        (< balance 1000) 0.5
        (< balance 5000) 1.621
        :else 2.475))

(defn annual-balance-update
  "TODO: add docstring"
  "Calculate new balance after interest rate yield."
  [balance]
  )
  (let [rate (/ (bigdec (interest-rate balance)) 100)
        delta (* (abs balance) rate)]
    (+ balance delta)))

(defn amount-to-donate
  "TODO: add docstring"
  "Donate twice the allowed governmental tax-free donation amount."
  [balance tax-free-percentage]
  )
\ No newline at end of file
  (let [tax-free-pct (/ tax-free-percentage 100)
        tax-free-donation-amount (max 0 (* balance tax-free-pct))]
    (int (* 2 tax-free-donation-amount))))