Skip to content

Instantly share code, notes, and snippets.

@tzach
Created December 1, 2019 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tzach/e30c92eebc625ae91e3f9c6dba01373c to your computer and use it in GitHub Desktop.
Save tzach/e30c92eebc625ae91e3f9c6dba01373c to your computer and use it in GitHub Desktop.
calcInterest
(defn round100 [n] (-> n (* 100) (Math/floor) (/ 100)))
(defn calcInterest [& {:keys [initialAmount interestRate years roundInterestYearly]}]
(nth (iterate
(fn calcInterestOneYear [amount]
(cond-> (* interestRate amount)
roundInterestYearly round100))
initialAmount) years))
@tzach
Copy link
Author

tzach commented Dec 1, 2019

Reimplementing the Kotlin code from http://www.softwarearchiblog.com/2019/11/code-learner.html in Clojure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment