skype でローンの話になり、ローン計算スクリプトを組むことに。(何やっているんだ)
利子を 0.02% として、利子をどれぐらい払いつづけなきゃいけないか計算。
先輩の組んだ common lisp でローン計算
#!/usr/local/bin/clisp
(defun view-month (n)
(format t "~A years ~A month " (floor (/ n 12.0)) (+ (mod n 12) 1)))
(defun calc-total (n total pay)
(cond ((< total pay) 0)
(t
(setq risi (/ (* total 0.02) 12))
(setq total (- total (- pay risi)))
(view-month n)
(format t "nokori = ~A risi = ~A~A" total risi #\Newline)
(calc-total (+ n 1) total pay))))
(先輩のソースをパクリ)俺が組んだ scheme でローン計算
再起関数なので set quote(元来schemeにそんなものはない) で代入を行うよりも let* を使うことにしました。
#!/usr/local/bin/gosh
(define mod modulo)
(define (view-month num)
(format #t "~A years ~A month " (floor (/ num 12)) (+ (mod num 12) 1)))
(define (calc-total total pay num)
(let* ((rishi (/ (* total 0.02) 12))
(total (- total (- pay rishi))))
(format #t "nokori = ~A rishi = ~A~A" total rishi #\Newline)
(cond ((< total pay) #t)
(else
(view-month num)
(calc-total total pay (+ num 1))))))
3433歩
Wow, cool man, big thanks! <a href=http://ncriaeorbdp.com >http://ncriaeorbdp.com</a>
<a href=http://nerkepp.info/index11.html > http://nerkepp.info/index11.html </a><br>