Created
January 5, 2014 04:25
-
-
Save ikemonn/8264306 to your computer and use it in GitHub Desktop.
Lisp binary search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun smaller() | |
(setf *big* (1- (guess-my-number))) | |
(guess-my-number)) | |
(defun bigger() | |
(setf *small* (1+ (guess-my-number))) | |
(guess-my-number)) | |
(defun guess-my-number() | |
(ash (+ *small* *big*) -1)) | |
(defun start-over () | |
(defparameter *small* 1) | |
(defparameter *big* 100) | |
(guess-my-number)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment