Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (: calc-tax-bracketed-rate (-> Nonnegative-Real BracketSpec Nonnegative-Real))
- (define (calc-tax-bracketed-rate income brackets)
- (let calc-impl ([income income]
- [brackets brackets]
- [tax 0.0])
- (match-let ([(cons lo rate) (car brackets)]
- [(cons hi _) (cadr brackets)])
- (if (or (< income lo) (null? brackets))
- ;; stopping conditions:
- ;; - income < lo => we're one bracket too high
- ;; - null? bracket => we ran out of brackets
- tax
- (calc-impl income
- (cdr brackets)
- (+ tax (* rate (- (min (+ hi 1) income) lo))))))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement