Name: Anonymous 2013-02-02 22:23
(define-struct trans (action amount))
;; A trans is a structure (make-trans a amt),
;; that represents a transaction for a bank account, where
;; a is a symbol, either ‘deposit or ‘withdraw. A deposit is a ;; payment made into the account. A withdrawal is a payment
;; made out of the account.
;; amt is a positive number representing the amount added
;; or removed from the account.Use accumulative recursion to write a function named update-balance that consumes a list of transactions that took place during the month (lot), and a starting balance at the beginning of the month (start-bal). The function produces the balance of a bank account after processing all of the transactions in lot. The balance may drop below zero at any point. You may assume that deposits and withdrawals will have no more than two decimal places and thus the balance produced by update-balance will have no more than two decimal places.
For example:
(update-balance
(list (make-trans ‘withdraw 604.34)
(make-trans ‘deposit 300)) 0) => -304.34
(update-balance
(list (make-trans ‘withdraw 20.99)(make-trans ‘deposit 60) (make-trans ‘deposit 900)(make-trans ‘withdraw 55.5)
(make-trans ‘deposit 100)(make-trans ‘deposit 40))50) => 1073.51