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 : Inventory -> Integer ;; GIVEN: a Inventory ;; RETURNS: the value of all the copies on hand of all the books in the ;; given Inventory ;; (inventory-total-value lob1) = 390 (begin-for-test (check-equal? (inventory-total-value empty) 0 "value of the empty inventory should be 0") (check-equal? (inventory-total-value inv1) 390 "value of inv1 should be 390")) ;; books-out-of-stock : Inventory -> Inventory ;; GIVEN: a list of books ;; RETURNS: a list of the books that are out of stock in the given Inventory ;; Example: ;; (books-out-of-stock inv1) = ;; (list ;; (make-book "Shakespeare" "Hamlet" 0 2) ;; (make-book "Shakespeare" "Macbeth" 0 10))
Are these the only reasonable contracts for these functions?