Back Edit Delete

A key handler should reset the world to 0 when the space key is pressed and otherwise leave the world unchanged. Write the handler and two check-expect tests: one for the space key and one representative unrelated key.

Short answer

Accepted answer

(define (handle-key ws ke)
(cond [(key=? ke " ") 0]
[else ws]))

(check-expect (handle-key 25 " ") 0)
(check-expect (handle-key 25 "a") 25)