Код Ревью

Сравни свои решения

    #| BEGIN (Write your solution here) |#
(define (divider m1 m2 quotient)
  (define (process-new-value)
    (cond ((and (has-value? m1) (= (get-value m1) 0))
           (set-value! quotient 0 me))
          ((and (has-value? m2) (= (get-value m2) 0))
           (error " Can't be divide by 0"))
          ((and (has-value? m1) (has-value? m2))
           (set-value! quotient
                       (/ (get-value m1) (get-value m2))
                       me))
          ((and (has-value? quotient) (has-value? m1))
           (set-value! m2
                       (/ (get-value m1) (get-value quotient))
                       me))
          ((and (has-value? quotient) (has-value? m2))
           (set-value! m1
                       (* (get-value quotient) (get-value m2))
                       me))))
  (define (process-forget-value)
    (forget-value! quotient me)
    (forget-value! m1 me)
    (forget-value! m2 me)
    (process-new-value))
  (define (me request)
    (cond ((eq? request 'I-have-a-value)
           (process-new-value))
          ((eq? request 'I-lost-my-value)
           (process-forget-value))
          (else
           (error "Unknown requset -- DIVIDER" request))))
  (connect m1 me)
  (connect m2 me)
  (connect quotient me)
  me)


(define (c- x y)
  (let ((z (make-connector))
        (-y (make-connector))
        (minus (make-connector)))
    (constant -1 minus)
    (multiplier minus y -y)
    (adder x -y z)
    z))

(define (c* x y)
  (let ((z (make-connector)))
    (multiplier x y z)
    z))

(define (c/ x y)
  (let ((z (make-connector)))
    (divider x y z)
    z))

(define (cv x)
  (let ((z (make-connector)))
    (constant x z)
    z))
#| END |#