]> git.rkrishnan.org Git - sicp.git/blob - src/sicp/ex3_29.rkt
solutions to 4.38, 4.39 and 4.40
[sicp.git] / src / sicp / ex3_29.rkt
1 #lang racket
2
3 #|
4 (or a b) = (and (and (not a) b)
5                 (and a (not b))
6 |#
7
8 (define (or-gate o1 o2 output)
9   (let ((a1 (make-wire)) 
10         (a2 (make-wire))
11         (a3 (make-wire))
12         (a4 (make-wire)))
13     (inverter o1 a1)
14     (inverter o2 a2)
15     (and-gate a1 o2 a3)
16     (and-gate o1 a2 a4)
17     (and-gate a3 a4 output)
18     'ok))
19
20 #|
21
22 or-gate delay is one inverter delay + 2 x and-gate-delay, considering that
23 the whole things works in a parallel way. i.e. a3 and a4 are produced parallely.
24
25 |#