November 2010
Intermediate to advanced
504 pages
12h 45m
English
Our guess-my-number game has the computer respond to the player’s request to start the game, and then to requests for either smaller or bigger guesses. For these, we need to define three global functions: guess-my-number, smaller, and bigger. We’ll also define a function to start over with a different number, called start-over. In Common Lisp, functions are defined with defun, like this:
(defunfunction_name(arguments) ...)
First, we specify the name and arguments for the function. Then we follow it up with the code that composes the function’s logic.
The first function we’ll define is guess-my-number. This function uses the values of the *big* and *small* variables to generate ...