Define a function (BLORG-SPOKEN-NAME COLOR-OF-SPEAKER NAME-ON-TRUNK) which, given the color of the speaking Blorgian and the name inscribed on the trunk of the Blorgian being addressed, returns the name to be spoken.
For example:
Color of Speaking Blorgian | Name on Trunk of Blorgian Being Addressed | Name to be Spoken |
---|---|---|
PURPLE | ZACH | ZACH-OOK-OOK |
GREEN | ZACH | BLIP-ZACH |
GREEN | ZAQS | BLIP-ZAQS-ICHOR |
GREEN | QUUX | BLOP-QUUX |
GREEN | QUIS | BLOP-QUIS-ICHOR |
GREEN | JIMMY | JIMMY |
PURPLE | JIMMY | JIMMY-OOK-OOK |
(define (blorg-spoken-name color name) (cond ((equal color 'purple) (word name '-ook-ook)) ((equal color 'green) (word (cond ((equal? (first name) 'z) 'blip-) ((equal? (first name) 'q) 'blop-) (else "")) name (if (equal? (last name) 's) '-ichor "")))))
(define (add-up sen) (if (empty? sen) 0 (+ (first sen) (add-up (rest sen)))))
expression | result |
---|---|
(or #f #f 'aye 'bee) | AYE |
(and #t #t 'aye 'bee) | BEE |
(sentence 1 2) | (1 2) |
'(sentence 1 2) | (SENTENCE 1 2) |
(word 12 13) | 1213 |
(first 98765) | 9 |
(first '(98 76 5)) | 98 |
(butfirst '(98 76 5)) | (76 5) |
(quote (and 1 2)) | (AND 1 2) |
(not 'false) | #f |
(define (utensil cuisine) (cond ((equal? cuisine 'chinese) 'chopsticks) ((equal? cuisine 'ethiopian) 'fingers) (else 'fork)))
(define (utensil cuisine) (if (equal? cuisine 'chinese) 'chopsticks (if (equal? cuisine 'ethiopian) 'fingers 'fork)))