@laurent.orseau thanks for the reply. It works actually. Only it gives the error message at the end. So, yes it should be returning the postitive vlaues, but then at some point (after reaching the end poit) it encounters a negative number and finishes with an error message. At least I thought so, I am a total beginner, maybe I get it wrong.
Hey all, I have a new question with world design. Rocket was perfectly launching until I added a “stop-when” to the code. (It was constantly launching after reaching the HEIGHT). So this is what I have: (define (main2 s) (big-bang s [to-draw show] [on-tick fly] [on-key launch] [stop-when out-of-sight?])) (define (out-of-sight? x) (not (or (string? x) (<= –3 x –1) (<= 0 x 100) )))
Now after adding “stop-when” the rocket only sits on the bottom of the scene, and doesn’t fly, with the parameters string, –1, –3, 10, 20 etc. If the parameter gerater than 30 it launches. I can’t understand where I made a mistake. Tests passed: (check-expect (out-of-sight? “resting”) false) (check-expect (out-of-sight? –3) false) (check-expect (out-of-sight? –4) true) (check-expect (out-of-sight? 0) false) (check-expect (out-of-sight? 100) false) (check-expect (out-of-sight? 101) true) (check-expect (out-of-sight? 10) false) (check-expect (out-of-sight? 30) false)
Assuming that you are doing Exercise 56 in https://htdp.org/2022-6-7/Book/part_one.html, can you tell me what are possible values of an LRCD?
You should really follow the design recipe that they provide you, by the way. When you define out-of-sight?
, write down signature, purpose statements, etc, etc.
Yes, Exercise 56. Do you mean check-expect tests with “possible values of an LRCD”, or something else? Actually my desgin recipe is this:
; LRCD -> Boolean ; produces true if the rocket is out of sight, otherwise false (check-expect (out-of-sight? “resting”) false) (check-expect (out-of-sight? –3) false) (check-expect (out-of-sight? –4) true) (check-expect (out-of-sight? 0) false) (check-expect (out-of-sight? 100) false) (check-expect (out-of-sight? 101) true) (check-expect (out-of-sight? 10) false) (check-expect (out-of-sight? 30) false) ; Tests passed.
; (define (out-of-sight? x) false) ; stub
(define (out-of-sight? x) (not (or (string? x) (<= –3 x –1) (<= 0 x 100) )))
Well, I am simply asking you a question: what are possible values of an LRCD?
~another hint (IIRC) is that all your functions provided to big-bang
have to deal with the same set of LRCD values. By doing (out-of-sight? -3)
, you are saying show -3
is also valid, which doesn’t look right~
(show -3)
is valid IIUC
It’s one of the test cases in the book
Oh, I see. My bad. I got what the meaning of LRCD is