이전 주제 보기 :: 다음 주제 보기 |
글쓴이 |
메시지 |
최원태
가입: 2006년 9월 16일 올린 글: 369
|
올려짐: 2008년10월15일 19:06 주제: 숙제 4 공지 (Due : 10/24) |
|
|
네번째 과제가 나왔습니다.
10/24일 금요일 자정까지, 코딩과제 1문제 입니다.
http://ropas.snu.ac.kr/~kwang/4190.210/08/hw4.pdf
추신,
이번 과제는 "파인만식 문제해결법" 을 사용해서 푸시길 바랍니다
인용: | 1. Write down the problem.
2. Think very hard.
3. Write down the solution. |
최원태 가 2008년10월28일 14:55에 수정함, 총 1 번 수정됨 |
|
위로 |
|
|
최원태
가입: 2006년 9월 16일 올린 글: 369
|
올려짐: 2008년10월19일 13:56 주제: |
|
|
이번 과제의 해석을 놓고 여러가지 의견이 분분한 것 같습니다.
과제의 내용을 한번 더 정리해보고
자세한 가이드라인을 오늘 저녁까지 올리겠습니다. |
|
위로 |
|
|
최원태
가입: 2006년 9월 16일 올린 글: 369
|
올려짐: 2008년10월20일 0:01 주제: |
|
|
1. 함수 type에 대해서
mustAnd : cond * cond -> cond
mustHaveCommon : cond * cond -> cond
이 두 함수는 두개의 cond를 받아 하나의 cond를 돌려주는 함수입니다.
아래와 같이 사용합니다
코드: | (mustHaveCommond cond1 cond2)
(mustAnd cond1 cond2) |
condCommon : cond -> cond * cond
condAnd : cond -> cond * cond
이 두 함수는 하나의 cond를 받아 cond의 pair를 돌려주는 함수입니다.
아래와 같이 사용합니다.
코드: | (car (condCommon cond))
(cdr (condCommon cond))
(car (condAnd cond))
(cdr (condAnd cond)) |
2. shoppingList의 입력으로 들어오는 (id * cond) list 에서 중복되는 id는 들어오지 않는 것으로 가정하셔도 됩니다.
3. 조카A에게 줄 선물을 정의하는데 조카A가 가진 선물을 참조할 수 도 있습니다. |
|
위로 |
|
|
최원태
가입: 2006년 9월 16일 올린 글: 369
|
올려짐: 2008년10월20일 0:06 주제: |
|
|
4. and와 common, except의 의미에 대해서는 게시판에서 충분한 토론이 이루어지고 있는 듯 하므로, 따로 답을 하지 않겠습니다.
5. 과제에 필요한 함수들을 정의입니다.
코드: | (define (mustItems giftList)
(cons 'mustItems giftList))
(define (mustBeTheSame id)
(cons 'mustBeTheSame id))
(define (mustHaveExceptFor condition giftList)
(cons 'mustHaveExceptFor (cons condition giftList)))
(define (mustHaveCommon condition giftList)
(cons 'mustHaveCommon (cons condition giftList)))
(define (mustAnd condition1 condition2)
(cons 'mustHaveAnd (cons condition1 condition2)))
(define (isItems c)
(and (pair? c) (equal? (car c) 'mustItems)))
(define (isSame c)
(and (pair? c) (equal? (car c) 'mustBeTheSame)))
(define (isExcept c)
(and (pair? c) (equal? (car c) 'mustHaveExceptFor)))
(define (isCommon c)
(and (pair? c) (equal? (car c) 'mustHaveCommon)))
(define (isAnd c)
(and (pair? c) (equal? (car c) 'mustHaveAnd)))
(define (whichItems c)
(cond ((isItems c) (cdr c))
(else (error "c is not constructed by mustItem procedure"))))
(define (whoTheSame c)
(cond ((isSame c) (cdr c))
(else (error "c is not constructed by mustBeTheSame procedure"))))
(define (condExcept c)
(cond ((isExcept c) (cadr c))
(else (error "c is not constructed by mustHaveExceptFor procedure"))))
(define (itemsExcept c)
(cond ((isExcept c) (cddr c))
(else (error "c is not constructed by mustHaveExceptFor procedure"))))
(define (condCommon c)
(cond ((isCommon c) (cdr c))
(else (error "c is not constructed by mustHaveCommon procedure"))))
(define (condAnd c)
(cond ((isAnd c) (cdr c))
(else (error "c is not constructed by mustHaveAnd procedure")))) |
조교가 주는 코드는 타입체크를 그다지 타이트 하게 하지 않지만
여러분은 타입체크를 충실히 해주세요 |
|
위로 |
|
|
|