public
Created

  • Download Gist
be.scm
Scheme
1 2 3 4 5 6 7 8 9
(define (game min max)
(let* ((guess (floor (/ (+ min max) 2)))
(hl (begin (format #t "is your number ~a?\n(h)igher/(l)ower/(c)orrect: " guess) (read))))
(cond
((eq? hl 'h) (game guess max))
((eq? hl 'l) (game min guess))
((eq? hl 'c) (format #t "I win!\n"))
(else (game min max)))))
(game 0 100)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.