This Web
Other Webs
Schematics
Scheme Links
(define (monster-string n) (let ((text (if (= n 1) (list "is" 1 "") (list "are" n "s")))) (printf "There ~a ~a monster~a approaching" (car text) (cadr text) (caddr text)))) > (monster-string 1) There is 1 monster approaching > (monster-string 15) There are 15 monsters approaching >
(define (is-are n) (if (= n 1) "is" "are")) (define (plural n) (if (= n 1) "" "s")) (define (monster-string2 n) (printf "There ~a ~a monster~a approaching" (is-are n) n (plural n))) > (monster-string2 1) There is 1 monster approaching > (monster-string2 15) There are 15 monsters approaching >