이승중
가입: 2010년 6월 22일 올린 글: 561
|
올려짐: 2011년10월16일 10:11 주제: 숙제 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")))
|
|
|