; Load the guessing game for its utiltities. (load "/home/rebelsky/Web/Courses/CS151/2006F/Examples/guessing-game.scm") (define guess-name (lambda () (letrec ((kernel (lambda (lb ub) (if (> lb ub) (print-line "You win! I've run out of names.") (let* ((mid (quotient (+ lb ub) 2)) (midname (vector-ref names mid))) (cond ((yes-or-no? (string-append "Is the name " midname "?")) (print-line "I win!")) ((yes-or-no? (string-append "Does the name alphabetically precede " midname "?")) (kernel lb (- mid 1))) (else (kernel (+ mid 1) ub)))))))) (print-line "Think of a name and I'll try to guess it.") (kernel 0 (- (vector-length names) 1)) (if (yes-or-no? "Play again?") (guess-name) (print-line "Thanks for playing.")))))