(load "../lang/dlambda.lisp") (defun interest-compounder (initial-principal initial-interest-rate) (let ((private) (public) (principal initial-principal) (interest-rate initial-interest-rate)) (setf private (eval (dlambda (:percent-of-number (n percentage) (if (> percentage 0) (/ (+ (* n percentage) 50) 100) (/ (- (* n percentage) 50) 100))) (:compound-interest (years) (if (> years 0) (progn (setf principal (+ principal (call private :percent-of-number principal interest-rate))) (call private :compound-interest (- years 1)))))))) (setf public (eval (dlambda (:get-principal () principal) (:get-interest-rate () interest-rate) (:move-forward-one-year () (call private :compound-interest 1)) (:move-forward-years (years) (call private :compound-interest years)))))))