Created
July 11, 2016 20:43
-
-
Save futureperfect/4978607713bd0beeb98464a6109811b7 to your computer and use it in GitHub Desktop.
Ch2 Realm of Racket
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
#lang racket | |
(define lower-bound 1) | |
(define upper-bound 100) | |
(define (start n m) | |
(set! lower-bound (min n m)) | |
(set! upper-bound (max n m)) | |
(guess)) | |
(define (guess) | |
(quotient (+ lower-bound upper-bound) 2)) | |
(define (smaller) | |
(set! upper-bound (max lower-bound (sub1 (guess)))) | |
(guess)) | |
(define (bigger) | |
(set! lower-bound (min upper-bound (add1 (guess)))) | |
(guess)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment