CS 5010: Guided Practice 4.3: Computing on Lists of Structures

Starting with 04-2-books.rkt (from this week's examples), design the following functions:

    ;; inventory-total-value : LOB -> Number
    ;; GIVEN: a LOB
    ;; RETURNS: the value of all the copies on hand of all the books in the
    ;; given LOB
    ;; (inventory-total-value lob1) = 390
    
    (begin-for-test
      (check-equal? 
        (inventory-total-value empty)
        0
        "value of the empty inventory should have been 0")
      (check-equal?
        (inventory-total-value lob1)
        390
        "simple test"))
    
    ;; books-out-of-stock : LOB -> LOB
    ;; GIVEN: a list of books
    ;; RETURNS: a list of the books that are out of stock in the given LOB
    ;; Example:
    ;; (books-out-of-stock lob1) =
    ;;  (list
    ;;    (make-book "Shakespeare" "Hamlet" 0 2)
    ;;    (make-book "Shakespeare" "Macbeth" 0 10))
  

[ANSWER]

For debugging: Click here to validate.