《How to Design Programs》HTDP_ChapterI——3

将大问题拆分成小问题

3.1 电影院利润问题

;; profit : number  ->  number
;; to compute the profit as the difference between revenue and costs
;; at some given ticket-price
(define (profit ticket-price) ...)
;; revenue : number  ->  number
;; to compute the revenue, given ticket-price
(define (revenue ticket-price) ...)

;; cost : number  ->  number
;; to compute the costs, given ticket-price
(define (cost ticket-price) ...)

;; attendees : number  ->  number
;; to compute the number of attendees, given ticket-price
(define (attendees ticket-price) ...)
 

猜你喜欢

转载自blog.csdn.net/seeleday/article/details/80666934