7. HW B

This part uses the CodeWorld definition of a Point.

type Point = (Double, Double)

Answer the following questions. They are written with some ambiguity to avoid the question explaining exactly how to write them.

  1. (mq) Give a number x, return the point (x, x^2) unless this is outside of the square with $-100 \le x \le 100$ and $-100 \le y \le 100$. In that case return Nothing. Include two more tests showing that the function works.

     mq :: Double -> Maybe Point
     mq x = Nothing
    
     check_mq = [ Nothing == mq (-200) ]
    
  2. (avoid) In this question you are given a point (x0,y0) and a list of doubles (x,y,r). The avoid function returns the first ordered triple that describes a circle centered at (x,y) of radius r that does not contain your original point (x0,y0) (inside or on the boundary of the circle). If there is no such triple, return Nothing.

     type Circ = (Double, Double, Double)
     avoid :: Point -> [Circ] -> Maybe Circ
    
Last modified October 15, 2023: Changed title. (e6ba9e5)