代码
(defparameter *small* 1)
(defparameter *big* 100)
(defun guess-my-number()
(ash (+ *small* *big*) -1)
)
(defun smaller()
(setf *big* (1- (guess-my-number)))
(guess-my-number)
)
(defun biger()
(setf *small* (1- (guess-my-number)))
(guess-my-number)
)
(defun startover()
(defparameter *small* 1)
(defparameter *big* 100)
(guess-my-number)
)
运行
CL-USER> (guess-my-number)
50
CL-USER> (biger)
74
CL-USER> (biger)
86
CL-USER> (biger)
92
CL-USER> (smaller)
88
CL-USER> (startover)
50
CL-USER> (smaller)
25
CL-USER> (smaller)
12
CL-USER> (smaller)
6
CL-USER> (biger)
8