이전 주제 보기 :: 다음 주제 보기 |
글쓴이 |
메시지 |
유.강민
가입: 2011년 3월 22일 올린 글: 38
|
올려짐: 2011년9월26일 21:32 주제: 숙제2 테스트셋 복사붙여넣기 버전입니다 |
|
|
1번)
(define mytree (node (list (leaf (list 'node 'leaf ())) (node (list (leaf 'node) (leaf (list 1 2 3)) (leaf ()))) (node (list (leaf ()) (leaf (list 'leaf ())) (leaf (list ())))))))
(equal? (is-empty-tree? mytree) #f)
(equal? (is-leaf? mytree) #f)
(equal? (is-leaf? (nth-child mytree 0)) #t)
(equal? (leaf-val (nth-child mytree 0)) '(node leaf ()))
(equal? (is-leaf? (nth-child mytree 1)) #f)
(equal? (is-leaf? (nth-child (nth-child mytree 1) 1)) #t)
(equal? (leaf-val (nth-child (nth-child mytree 1) 1)) '(1 2 3))
(equal? (leaf-val (nth-child (nth-child mytree 1) 0)) 'node)
(equal? (leaf-val (nth-child (nth-child mytree 1) 2)) '())
(equal? (is-empty-tree? (nth-child (nth-child mytree 1) 2)) #f)
(equal? (leaf-val (nth-child (nth-child mytree 2) 0)) '())
(equal? (leaf-val (nth-child (nth-child mytree 2) 1)) '(leaf ()))
(equal? (leaf-val (nth-child (nth-child mytree 2) 2)) '(()))
(equal? (is-empty-tree? (leaf ())) #f)
(equal? (is-empty-tree? (node ())) #t)
(equal? (is-empty-tree? (node (list (leaf ()) (node ())))) #f)
(equal? (is-empty-tree? (nth-child (node (list (leaf ()) (node ()))) 1)) #t)
2번)
(equal? (weight (make-mobil (make-branch 12 (make-mobil (make-branch 3 (make-mobil (make-branch 2 (model 2)) (make-branch 2 (make-mobil (make-branch 3 (model 1)) (make-branch 3 (model 1)))))) (make-branch 6 (model 2)))) (make-branch 18 (make-mobil (make-branch 3 (model 1)) (make-branch 1 (model 3)))))) 10)
(equal? (is-balanced? (make-mobil (make-branch 12 (make-mobil (make-branch 3 (make-mobil (make-branch 2 (model 2)) (make-branch 2 (make-mobil (make-branch 3 (model 1)) (make-branch 3 (model 1)))))) (make-branch 6 (model 2)))) (make-branch 18 (make-mobil (make-branch 3 (model 1)) (make-branch 1 (model 3)))))) #t)
(equal? (is-balanced? (make-mobil (make-branch 12 (make-mobil (make-branch 3 (make-mobil (make-branch 3 (model 2)) (make-branch 2 (make-mobil (make-branch 3 (model 1)) (make-branch 3 (model 1)))))) (make-branch 6 (model 2)))) (make-branch 18 (make-mobil (make-branch 3 (model 1)) (make-branch 1 (model 3)))))) #f)
(equal? (is-balanced? (make-mobil (make-branch 12 (make-mobil (make-branch 3 (make-mobil (make-branch 2 (model 2)) (make-branch 2 (make-mobil (make-branch 3 (model 1)) (make-branch 3 (model 1)))))) (make-branch 4 (model 3)))) (make-branch 18 (make-mobil (make-branch 3 (model 1)) (make-branch 1 (model 3)))))) #f)
3,4번)
(equal? (let ((logic (lambda (a b c d) (output (or-circuit (or-circuit (and-circuit (and-circuit (not-circuit a) b) (not-circuit c)) (and-circuit (and-circuit (not-circuit a) (not-circuit c)) d)) (and-circuit (and-circuit (not-circuit a) (not-circuit b)) (and-circuit c (not-circuit d))))))))
(list
(logic zero zero zero zero)
(logic zero zero zero one)
(logic zero zero one zero)
(logic zero zero one one)
(logic zero one zero zero)
(logic zero one zero one)
(logic zero one one zero)
(logic zero one one one)
(logic one zero zero zero)
(logic one zero zero one)
(logic one zero one zero)
(logic one zero one one)
(logic one one zero zero)
(logic one one zero one)
(logic one one one zero)
(logic one one one one))) '(0 1 1 0 1 1 0 0 0 0 0 0 0 0 0 0))
(equal? (let ((logic (lambda (a b c d) (output (or-circuit (or-circuit (and-circuit b (not-circuit c)) (and-circuit (not-circuit a) b)) (and-circuit (and-circuit a (not-circuit b)) (and-circuit c d)))))))
(list
(logic zero zero zero zero)
(logic zero zero zero one)
(logic zero zero one zero)
(logic zero zero one one)
(logic zero one zero zero)
(logic zero one zero one)
(logic zero one one zero)
(logic zero one one one)
(logic one zero zero zero)
(logic one zero zero one)
(logic one zero one zero)
(logic one zero one one)
(logic one one zero zero)
(logic one one zero one)
(logic one one one zero)
(logic one one one one))) '(0 0 0 0 1 1 1 1 0 0 0 1 1 1 0 0))
유.강민 가 2011년9월28일 10:08에 수정함, 총 1 번 수정됨 |
|
위로 |
|
 |
안준형
가입: 2011년 9월 7일 올린 글: 18
|
올려짐: 2011년9월28일 0:31 주제: 2-2 테스트셋에 함수 이름이 make-mobile 이 아니라 make-mobil 아닌가요! |
|
|
아닌가요! |
|
위로 |
|
 |
강현수
가입: 2011년 9월 27일 올린 글: 16
|
올려짐: 2011년9월28일 0:37 주제: Thank you much man |
|
|
make-mobile빼고 ㅋㅋ |
|
위로 |
|
 |
안준형
가입: 2011년 9월 7일 올린 글: 18
|
올려짐: 2011년9월28일 0:54 주제: 그리고 테스트셋 2-3 번 #f가 아니라 #t 같은데! |
|
|
둘다 계싼해보면 72나오는데... |
|
위로 |
|
 |
유.강민
가입: 2011년 3월 22일 올린 글: 38
|
올려짐: 2011년9월28일 10:09 주제: RE |
|
|
make-mobile고쳤어요
그리고 2-3번은 하위 모빌도 체크했나요? |
|
위로 |
|
 |
엄태건
가입: 2011년 9월 27일 올린 글: 50
|
올려짐: 2011년9월29일 19:21 주제: Re: 숙제2 테스트셋 복사붙여넣기 버전입니다 |
|
|
감사합니당. |
|
위로 |
|
 |
|