13. Intro Exercises 1

  1. Use the code below to answer:
;; hit-snooze?: boolean number -> boolean
(define (hit-snooze? sleepy? time)
  (and (boolean=? sleepy? "true")
       (< time 700)))
  • What is wrong with this code? Fix it.
  • Write a check-expect where this function returns true.
  • Write a check-expect where this function returns false.
  1. Simplify or explain and correct the error.

    • (boolean=? (> 17 24) #false)
    • (boolean=? (= 1 1) "true")
    • (boolean=? practiced-piano? true)
    • (boolean=? hungry? false)
  2. Sometimes you get to sleep a lot (return true). That happens if you did not have homework, did not do the homework you have, or the homework was easy.

    Write a function to figure out if you slept a lot.

    (define (slept-lots? had-hw? did-hw? was-easy?)
       ...)
    
  3. (Shape Sorter I.) Write fit-rect?: image -> boolean that returns true if the image fits inside a 150x100 rectangle.

  4. (Shape Sorter II.) Write ibr?: image -> boolean that returns true if the image is a (pure) blue rectangle.