CS 201: Struct example: point

In Struct.html we saw examples of structs for a person and Turing machine instructions and configurations.

Below we give you a practice problem for structs: a Cartesian coordinate point.

A point has both an x and y coordinate. Above, we define p1 to be the origin and p2 to be a point a (3,4).

good-point?

Your first job is to write a procedure good-point? which checks to see if a given object is legimate point, including numeric coordinates.

Note that complex numbers are still numbers.

line

Next, write a procedure line which takes two points as arguments and returns the length of the line connecting those two points. It complains if you give it bogus points.

See Euclidean distance formula.

For the solution, see point.rkt