procedures as arguments, ctd
problem
- allow new gross to be arbitrary function of old gross and year
solution
- use procedure parameter that takes two arguments
(define (compound-flex principal app term)
(define (citer year gross)
(if (= term year) gross (citer (inc year) (app gross year))))))
(citer 0 principal))
- sample argument
(define (phased g y)(define rate (cond ((> g 1000) 0.10)) ((> g 500) 0.05) (else 0.02))))(* g (+ 1 rate)))
- sample applications
(compound-flex 1000 phased 20) ; evals to 6421
(compound-flex 100 phased 20) ; evals to 148