| 이전 주제 보기 :: 다음 주제 보기 |
| 글쓴이 |
메시지 |
민현기
가입: 2012년 9월 15일 올린 글: 29
|
올려짐: 2012년9월15일 17:42 주제: 숙제 2 테스트셋 |
|
|
2, 4번은 작년 테스트셋을 조금 수정하였습니다.
1번
(let ((n1 (node (list (leaf 2) (leaf 'abc) (leaf "abc") (leaf true) (leaf (node (list (leaf 3) (leaf 7))))))) (n2 (node (list (node (list (leaf 11) (leaf '(())))) (node (list (node (list (node (list (leaf "fg") (leaf 17) (leaf (= 3 4)))) (leaf "cde") (leaf 'fg))) (leaf 'cde) (leaf 13))) (node (list (leaf 19) (node (list (node (list (leaf null) (leaf (list 23 29)))) (leaf (cons 31 37)))))) (leaf (node (list (leaf 41) (leaf 43)))))))) (and (not (is-leaf? n1)) (is-leaf? (nth-child n1 0)) (= (leaf-val (nth-child n1 0)) 2) (equal? 'abc (leaf-val (nth-child n1 1))) (not (equal? 'abc (leaf-val (nth-child n1 2)))) (equal? "abc" (leaf-val (nth-child n1 2))) (equal? true (leaf-val (nth-child n1 3))) (is-leaf? (nth-child n1 4)) (is-leaf? (nth-child (leaf-val (nth-child n1 4)) 0)) (= 7 (leaf-val (nth-child (leaf-val (nth-child n1 4)) 1))) (not (is-leaf? n2)) (not (is-leaf? (nth-child n2 0))) (is-leaf? (nth-child (nth-child n2 0) 0)) (is-leaf? (nth-child (nth-child n2 0) 1)) (= 11 (leaf-val (nth-child (nth-child n2 0) 0))) (equal? null (car (leaf-val (nth-child (nth-child n2 0) 1)))) (equal? null (cdr (leaf-val (nth-child (nth-child n2 0) 1)))) (not (is-leaf? (nth-child n2 1))) (is-leaf? (nth-child (nth-child n2 1) 1)) (is-leaf? (nth-child (nth-child n2 1) 2)) (not (is-leaf? (nth-child (nth-child n2 1) 0))) (eq? 'cde (leaf-val (nth-child (nth-child n2 1) 1))) (= 13 (leaf-val (nth-child (nth-child n2 1) 2))) (equal? "fg" (leaf-val (nth-child (nth-child (nth-child (nth-child n2 1) 0) 0) 0))) (= 17 (leaf-val (nth-child (nth-child (nth-child (nth-child n2 1) 0) 0) 1))) (equal? false (leaf-val (nth-child (nth-child (nth-child (nth-child n2 1) 0) 0) 2))) (equal? 'fg (leaf-val (nth-child (nth-child (nth-child n2 1) 0) 2))) (equal? '() (leaf-val (nth-child (nth-child (nth-child (nth-child n2 2) 1) 0) 0))) (equal? '(23 29) (leaf-val (nth-child (nth-child (nth-child (nth-child n2 2) 1) 0) 1))) (= 31 (car (leaf-val (nth-child (nth-child (nth-child n2 2) 1) 1)))) (is-leaf? (nth-child n2 3)) (= 43 (leaf-val (nth-child (leaf-val (nth-child n2 3)) 1)))))
2번. 1번문제의 모든 정의들을 2번문제에 붙여넣고 테스트해야 합니다.
(and (= (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) (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)))))) (not (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))))))) (not (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))))))))
4번. 1번문제, 3번문제를 4번문제에 붙여넣고 테스트해야 합니다.
(and (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)))
전부 true가 나오면 됩니다. |
|
| 위로 |
|
 |
지완규
가입: 2012년 9월 15일 올린 글: 23
|
올려짐: 2012년9월15일 19:12 주제: |
|
|
| 감사합니다. 이런 테스트 셋은 직접 만드시는 건가요 ㅠㅠ |
|
| 위로 |
|
 |
kimsl30
가입: 2011년 3월 4일 올린 글: 12
|
올려짐: 2012년9월16일 19:20 주제: |
|
|
3,4번 테스트셋이 이번꺼랑 맞는 건가요??
전 왜 안되죠 ㅜㅜ _________________ 김수린 |
|
| 위로 |
|
 |
민현기
가입: 2012년 9월 15일 올린 글: 29
|
올려짐: 2012년9월17일 21:20 주제: |
|
|
안된다는게 에러가 난다는 건가요??
아니면 false가 나온다는 건가요? |
|
| 위로 |
|
 |
kimsl30
가입: 2011년 3월 4일 올린 글: 12
|
올려짐: 2012년9월18일 13:14 주제: |
|
|
에러가 나요 ㅜ
zero, one 이 함수가 아닌건가요?
전 함수로 해놔서 괄호 차이였군요.. _________________ 김수린 |
|
| 위로 |
|
 |
임성철
가입: 2012년 9월 8일 올린 글: 35
|
올려짐: 2012년9월19일 14:22 주제: |
|
|
잘 되는 거 같아요
감사합니다  |
|
| 위로 |
|
 |
이계원
가입: 2012년 9월 14일 올린 글: 9
|
올려짐: 2012년9월21일 1:19 주제: |
|
|
| zero, one을 argument가 0인 함수로 구현했다면 (zero), (one)과 같은 방식으로 입력을 받아야하는군요. 어떤것이 맞는 입력인지는 조교님께 물어봐야할것 같고요. 그 이외에는 이상이 없어보입니다. |
|
| 위로 |
|
 |
김민석
가입: 2012년 9월 15일 올린 글: 40
|
올려짐: 2012년9월21일 16:27 주제: |
|
|
| 감사합니다. 다 잘 되네요. |
|
| 위로 |
|
 |
|