Hello i was having difficulty using the function which i created which is supposed to display the number of guesses the program takes to find the players number.i have defined this function not sure if its correct ,
(define( number-of-guesses w)
(add1 (number-of-guesses (guess w))))
i was trying to apply this to the render clause however
(define (render w)
(overlay (text (number->string (guess w)) SIZE COLOR) MT-SC)
(overlay (text (number->string (number-of-guesses w)) SIZE COLOR) MT-SC))
i get this error (start 1 100)
. . interval-small: contract violation
expected: interval?
given: 50
how and where should i place the function on my code
#lang racket
(require 2htdp/universe 2htdp/image)
(define WIDTH 600)
(define HEIGHT 600)
(define TEXT-SIZE 10)
(define TEXT-X 20)
(define TEXT-UPPER-Y 50)
(define TEXT-LOWER-Y 50)
(define SIZE 36)
(define X-CENTER (quotient WIDTH 2))
(define Y-CENTER (quotient HEIGHT 2))
(struct interval (small big))
(define HELP-TEXT (text " UP for larger numbers, DOWN for smaller ones"
TEXT-SIZE
"Blue"))
(define HELP-TEXT2
(text "press = when your number is guessed; q to quit it."
TEXT-SIZE
"blue"))
(define COLOR "red")
(define MT-SC
(place-image/align
HELP-TEXT TEXT-X TEXT-UPPER-Y "left" "top"
(place-image/align
HELP-TEXT2 TEXT-X TEXT-LOWER-Y "left" "bottom"
(empty-scene WIDTH HEIGHT))))
(define (start lower upper)
(big-bang (interval lower upper)
(on-key deal-with-guess)
(to-draw render )
(stop-when single? render-last-scene)))
(define (deal-with-guess w key)
(cond
[(key=? key "up") (bigger w)]
[(key=? key "down") (smaller w)]
[(key=? key "q") (stop-with w)]
[(key=? key "=") (stop-with w)]
[else w]))
(define (smaller w)
(interval (interval-small w)
(max (interval-small w) (sub1 (guess w)))))
(define (bigger w)
(interval (min (interval-big w) (add1 (guess w)))
(interval-big w)))
(define (guess w)
(quotient ( + (interval-small w) (interval-big w)) 2))
(define (render w)
(overlay (text (number->string (guess w)) SIZE COLOR) MT-SC)
(overlay (text (number->string (number-of-guesses w)) SIZE COLOR) MT-SC))
(define (render-last-scene w)
(overlay (text "END" SIZE COLOR) MT-SC))
(define (single? w)
(= (interval-small w) (interval-big w)))
(define( number-of-guesses w)
(add1 (number-of-guesses (guess w))))