<< Previous exercise (3.27) | Index | Next exercise (3.29) >>
meteorgan
(define (or-gate a1 a2 output) (define (or-action-procedure) (let ((new-value (logic-or (get-singal a1) (get-signal a2)))) (after-delay or-gate-delay (lambda () (set-signal! output new-value))))) (add-action! a1 or-action-procedure) (add-action! a2 or-action-procedure)) (define (logic-or s1 s2) (if (or (= s1 1) (= s2 1)) 1 0))
sirel
(define (logical-or s1 s2) (if (= (+ s1 s2) 0) 0 1))
Version of logical-or which doesn't use the built-in or.
(define (logical-or s1 s2) (cond ((= s1 1) 1) ((= s2 1) 1) (else 0)))
And one which uses no arithmetic operations.
sirel
(define (logical-or s1 s2) (if (= (+ s1 s2) 0) 0 1))
Version of logical-or which doesn't use the built-in or.
(define (logical-or s1 s2) (cond ((= s1 1) 1) ((= s2 1) 1) (else 0)))
And one which uses no arithmetic operations.