이 문제는 and-gate와 비슷하게 or-gate를 만드는 문제입니다.
문제에서도 and-gate와 비슷하게 만들면 된다고 하여 그렇게 만들었습니다.^^

and를 or로 바꾸기만 하였습니다.
그리고 logical-or 프로시저를 x가 0이고 y가 0일 때 0을 리턴하고
그 외의 경우에는 1을 리턴하도록 하였습니다.
OR 연산자는 실제 그렇게 동작합니다.^^
참조
해럴드 애빌슨, 김재우 역, <컴퓨터 프로그램의 구조와 해석>, 인사이트, 2007, pp. 359
(define (or-gate a1 a2 output)
(define (or-action-procedure)
(let ((new-value
(logical-or (get-signal 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)
'ok)
(define (logical-or x y)
(if (and (= x 0) (= y 0))
0
1))
"in OCW" 카테고리의 다른 글
- SICP Exercise 연습문제 3.31 (0)2008/07/08
- SICP Exercise 연습문제 3.30 (0)2008/07/08
- SICP Exercise 연습문제 3.29 (0)2008/07/08
- SICP Exercise 연습문제 3.28 (0)2008/07/08
- SICP Exercise 연습문제 3.27 (2)2008/07/06
- SICP Exercise 연습문제 3.26 (0)2008/07/06
- SICP Exercise 연습문제 3.25 (0)2008/07/06
글에 잘못된 점, 다른 점, 부족한 점이 있다면 지적해주세요.
댓글, 트랙백, 메일 모두 고맙습니다.







댓글을 달아 주세요