Task

Write a game (computer program) that follows the following rules:

 The computer chooses a number between given set limits.
 The player is asked for repeated guesses until the the target number is guessed correctly
 At each guess, the computer responds with whether the guess is:
 higher than the target,
 equal to the target, 
 less than the target,   or
 the input was inappropriate. 


Related task

   Guess the number/With Feedback (Player)


 
(import (otus random!))
 
(define from 0)
(define to 100)
 
(define number (+ from (rand! (+ from to 1))))
 
(let loop ()
   (for-each display `("Pick a number from " ,from " through " ,to ": "))
   (let ((guess (read)))
      (cond
         ((not (number? guess))
            (print "Not a number!")
            (loop))
         ((or (< guess from)
              (< to guess))
            (print "Out of range!")
            (loop))
         ((< guess number)
            (print "Too low!")
            (loop))
         ((> guess number)
            (print "Too high!")
            (loop))
         ((= guess number)
            (print "Well guessed!")))))
 