최민아
가입: 2009년 9월 28일 올린 글: 236
|
올려짐: 2012년10월13일 22:15 주제: 숙제 5-5 주어지는 함수 코드 |
|
|
| 코드: | (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"))) |
|
|