; question 2 ;; count-the-loot : list -> number ;; returns the total taxes paid by a given ;; payroll list (define (count-the-loot pyrl) (cond [(empty? pyrl) 0] [else (+ (tr-amount (sr-to-tr (first pyrl))) (count-the-loot (rest pyrl)))])) ;; election-year-giveaway : list number -> list ;; returns a payroll with all salaries increased ;; by a given percentage from a given payroll list (define (election-year-giveaway pyrl boost) (cond [(empty? pyrl) (cons empty)] [else (cons (sr-name (first pyrl)) (* (sr-salary (first pyrl)) (+ 1 (/ boost 100))) (election-year-giveaway (rest pyrl) boost))])) ;; eat-the-rich : list -> list ;; returns a payroll list with all those people ;; earning $120,000 or more removed from a ;; given payroll list (define (eat-the-rich pyrl) (cond [(empty? pyrl) (cons empty)] [else (cond [(< (sr-salary (first pyrl)) 120000) (cons (sr-name (first pyrl)) (sr-salary (first pyrl)) (eat-the-rich (rest pyrl)))] [else (eat-the-rich (rest pyrl))])])) ;; question 3 ;; on-line : number number list -> list ;; returns a list of posns whose x and y ;; values satisfy the equation y=ax+b ;; from given numbers a and b and a ;; given list of posns (define (on-line a b plist) (cond [(empty? plist) (cons empty)] [else (cond [(= (posn-y (first plist)) (+ (* a (posn-x (first plist))) b)) (cons (first plist) (on-line a b (rest plist)))] [else (on-line a b (rest plist))])]))