Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defvar *maximum* 100)
- (defvar *minimum* 1)
- (defun reset ()
- "Resets the minimum and maximum values"
- (format t "Okay, let's reset!~%")
- (setf *maximum* 100)
- (setf *minimum* 1)
- (guess))
- (defun average (initial &rest remaining)
- "Gets the average of the values, requiring at least the intial value"
- (let* ((all (cons initial remaining))
- (len (length all))
- (sum (apply #'+ all)))
- (floor sum len)))
- (defun higher ()
- "Sets the maximum to the average and guesses again"
- (setf *minimum* (average *maximum* *minimum*))
- (guess))
- (defun lower ()
- "Sets the average to the minimum and guesses again"
- (setf *maximum* (average *maximum* *minimum*))
- (guess))
- (defun guess ()
- "Prints a guess based on the average"
- (format t "I'm guessing ~a~%" (average *maximum* *minimum*)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement