; Load the guessing game for its utiltities. (load "/home/rebelsky/Web/Courses/CS151/2006F/Examples/guessing-game.scm") (define sequential-guess-name (lambda () ; Remember the length of the vector (let ((len (vector-length names))) ; In the kernel, we step through the positions, guessing each one ; in turn. (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) (if (yes-or-no? "Play again?") (sequential-guess-name) (print-line "Thanks for playing."))))))