Before you tackle the homework, remind yourself of our General Advice, Advice on Homeworks, and Grading Guidelines. Above all, keep your work neat and honest.
current-inventory
stands for a list of these
inventory records, representing all items for sale. Choose a data
representation and make up an example!
Write the function new-item!, which consumes the name of an
item, its price, and the number of copies that arrived from the warehouse.
It extends the current-inventory
appropriately. That is, if
the item is already in the database, it modifies the corresponding record;
otherwise it adds an appropriate record.
Write the function inflate!, which consumes a percentage and
increases the price of each item in current-inventory
accordingly.
Write the function discontinued!, which consumes the name of an item and removes the item from the list.
The implementation requires two functions:
(begin (next!) (next!) (next!))should cycle the traffic light through all three states back to whatever was its intial state.
Here are the three states:
![]() | ![]() | ![]() |
They were produced with the following constants:
;; --------------------------------------------------------- ;; Basic constants: (define WIDTH 50) (define HIGHT 160) (define RADIUS 20) (define DELTA 10) (define X (quotient WIDTH 2)) ;; off-set : num -> num (define (off-set y) (+ y DELTA (* 2 RADIUS))) (define Y:RED (off-set (- RADIUS))) (define Y:YEL (off-set Y:RED)) (define Y:GRN (off-set Y:YEL)) (define-struct bulb (center color)) ;; A bulb is (make-bulb posn color) (define RED:BULB (make-bulb (make-posn X Y:RED) RED)) (define YEL:BULB (make-bulb (make-posn X Y:YEL) YELLOW)) (define GRN:BULB (make-bulb (make-posn X Y:GRN) GREEN))
Matthias Felleisen | This page was generated on Fri Mar 5 09:05:54 CST 1999. |