| 이전 주제 보기 :: 다음 주제 보기 |
| 글쓴이 |
메시지 |
이승중
가입: 2010년 6월 22일 올린 글: 561
|
올려짐: 2010년10월18일 16:35 주제: 숙제 4-2 제공되는 함수입니다. |
|
|
이전 숙제들과 마찬가지로 겉으로 드러나는 함수들만 사용해주세요
| 코드: | (define (mustItems giftList)
(cons 'items giftList))
(define (mustBeTheSame id)
(cons 'same id))
(define (mustHaveExceptFor cond giftList)
(cons 'except (cons cond giftList)))
(define (mustHaveCommon cond1 cond2)
(cons 'common (cons cond1 cond2)))
(define (mustAnd cond1 cond2)
(cons 'and (cons cond1 cond2)))
(define (isItems cond)
(define tag (car cond))
(eq? tag 'items))
(define (isSame cond)
(define tag (car cond))
(eq? tag 'same))
(define (isExcept cond)
(define tag (car cond))
(eq? tag 'except))
(define (isCommon cond)
(define tag (car cond))
(eq? tag 'common))
(define (isAnd cond)
(define tag (car cond))
(eq? tag 'and))
(define (whichItems cond)
(if (isItems cond) (cdr cond) (error "Not 'Items' Condition")))
(define (whoTheSame cond)
(if (isSame cond) (cdr cond) (error "Not 'Same' Condition")))
(define (condExcept cond)
(if (isExcept cond) (car (cdr cond)) (error "Not 'Except' Condition")))
(define (itemsExcept cond)
(if (isExcept cond) (cdr (cdr cond)) (error "Not 'Except' Condition")))
(define (condCommon cond)
(if (isCommon cond) (cdr cond) (error "Not 'Common' Condition")))
(define (condAnd cond)
(if (isAnd cond) (cdr cond) (error "Not 'And' Condition")))
|
이승중 가 2010년10월25일 13:21에 수정함, 총 1 번 수정됨 |
|
| 위로 |
|
 |
김태훈
가입: 2010년 9월 6일 올린 글: 91
|
올려짐: 2010년10월18일 22:47 주제: |
|
|
주어진 함수에서 is~ 함수들이 비교방법으로 전부 eq? 를 쓰고 있는데
equal? 이 더 좋지 않을까요?.. |
|
| 위로 |
|
 |
이승중
가입: 2010년 6월 22일 올린 글: 561
|
올려짐: 2010년10월19일 10:29 주제: |
|
|
심볼 비교에서 eq? 와 equal?은 결과가 같습니다.
equal?은 주로 pair, vector, string을 비교할때 쓰입니다.
자세한 설명이 필요하시면 DrScheme에서 F1 누르면 나오는 HelpDesk에서 eq?를 검색하시면 나옵니다// |
|
| 위로 |
|
 |
김태훈
가입: 2010년 9월 6일 올린 글: 91
|
올려짐: 2010년10월19일 10:35 주제: |
|
|
| 처음에 eq?로 되어있을 때 오류가 나길래 질문 드렸던 건데 하다 보니 다른 부분에서 실수한거더라구요 ㅎㅎ 지금은 eq?로 되어있는 상태에서도 잘 되는 것 같습니다. ㅎ 답변 감사합니다! ㅎ |
|
| 위로 |
|
 |
|