Chinaunix首页 | 论坛 | 博客
  • 博客访问: 220896
  • 博文数量: 136
  • 博客积分: 2919
  • 博客等级: 少校
  • 技术积分: 1299
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-11 09:08
文章分类

全部博文(136)

文章存档

2013年(1)

2011年(135)

我的朋友

分类: LINUX

2011-12-07 09:18:44

  1. ;; mht created on Nov 8, 2011

  2. ;; profit : number number -> number
  3. ;; to compute the profit as the difference between revenue and costs at some given ticket-price
  4. ;; example : (profit 5) should be (- 600 184.8)
  5. (define (profit ticket-price)
  6.   (- (revenue ticket-price)
  7.      (costs ticket-price)))

  8. ;; revenue : number -> number
  9. ;; to compute the revenue given ticket-price
  10. ;; example : (revenue 5) should be (* 5 120)
  11. (define (revenue ticket-price)
  12.   (* ticket-price
  13.      (attendees ticket-price)))

  14. ;; costs : number -> number
  15. ;; to compute the costs given ticket-price
  16. ;; example : (costs 5) should be (+ 180 (* 120 0.04))
  17. (define (costs ticket-price)
  18.   (+ 180 (
  19.           * .04 (attendees ticket-price))))

  20. ;; attendees : number -> number
  21. ;; to compute the number of attendees, given ticket-price
  22. ;; example : (attendees 5) should be 120
  23. ;; (attendees 3) should be 420
  24. ;; (attendees 4) should be 270
  25. (define (attendees ticket-price)
  26.   (+ 120
  27.      (* (/ 15 .10) (- 5.00 ticket-price))))

  28. ;; test:
  29. (attendees 4)
  30. (costs 5)
  31. (profit 3)
  32. (profit 4)
  33. (profit 5)

  34. ;; new-costs: number -> number
  35. ;; to compute the costs given ticket-price
  36. ;;
  37. (define (new-costs ticket-price)
  38.   (* 1.54 (attendees ticket-price)))
  39. ;; test
  40. ;(new-costs 5)


  41. ;; new-profit
  42. (define (new-profit ticket-price)
  43.   (- (revenue ticket-price)
  44.      (new-costs ticket-price)))
  45.      
  46. (new-profit 3)
  47. (new-profit 4)
  48. (new-profit 5)
阅读(455) | 评论(0) | 转发(0) |
0

上一篇:exam2.4.4

下一篇:exam3.3.1

给主人留下些什么吧!~~