exam10.1.2

348阅读 0评论2011-11-18 maunix
分类:LINUX

  1. ;; mht created on Nov 15, 2011

  2. ;; hours->wages : list-of-numbers -> list-of-numbers
  3. ;; to create a list of weekly wages from a list of weekly hours (alon)
  4. (define (hours->wages alon)
  5.   (cond
  6.     [(empty? alon) empty]
  7.     [else (cons (wage (first alon)) (hours->wages (rest alon)))]))

  8. ;; wage : number -> number
  9. ;; to compute the total wage (at $12 per hour)
  10. ;; of someone who worked for h hours
  11. (define (wage h)
  12.   (cond
  13.     [(> h 100)
  14.      (error "too many hours")]
  15.     [else (* 14 h)]))

  16. ;; hours->wages
  17. (hours->wages (cons 40 (cons 80 empty)))
上一篇:exam10.1.1
下一篇:exam10.1.4