How can I play the game "guess.lisp"?

Discussion of Common Lisp
Post Reply
Ahdan
Posts: 1
Joined: Fri Jul 29, 2011 7:58 pm

How can I play the game "guess.lisp"?

Post by Ahdan » Sat Jul 30, 2011 2:38 am

I just started with lisp and installed CLISP and LispIDE.
When I type (load "guess.lisp") there is the message:

;; Datei guess.lisp wird geladen...

;; Datei guess.lisp ist geladen.
but the game does not start. How can I play the game?

Thanks, Ahdan

(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 bigger ()
(setf *small* (1+ (guess-my-number)))
(guess-my-number))

(defun start-over ()
(defparameter *small* 1)
(defparameter *big* 100)
(guess-my-number))

[1]> (load "guess.lisp")

;; Datei guess.lisp wird geladen...
;; Datei guess.lisp ist geladen.
T
[2]>

Kompottkin
Posts: 94
Joined: Mon Jul 21, 2008 7:26 am
Location: München, Germany
Contact:

Re: How can I play the game "guess.lisp"?

Post by Kompottkin » Sat Jul 30, 2011 6:31 am

Ahdan wrote:How can I play the game?
By repeatedly typing one of (guess-my-number), (smaller), and (higher), depending on whether the current guess is too large or too small.

Code: Select all

[7]> (guess-my-number)
50
[8]> (smaller) 
25
[9]> (bigger) 
37
[10]> (bigger) 
43
[11]> (smaller) 
40
[12]> (bigger) 
41
[13]> (bigger) 
42
[14]> 

Post Reply