check-expect
or check-within
format of the testing.ss teachpack to define your test cases.
When designing your data, note that there may be several different entries for a given city; for example, a city like Worcester has several different zip codes which represent localities at slightly different latitude and longitude coordinates.
Use a separate data definition to represent the location of each locality.
You may use data from a list of US state capitals when creating examples of data. (You do not have to use all the data in this file - we may be using all the data in a later assignment.) Note that the data lists the longitude before the latitude.
Assume that the latitude and longitude lines are parallel to the Canvas boundaries (parallel projection). Assume that
Define the function to-posn
that produces a posn that represents the given location on our Canvas.
*A posn is a struct that is built-in to DrScheme, and is used to represent x and y coordinates. It is defined as:
;; a posn is a struct ;; (make-posn number number) (define-struct posn(x y))
**The origin of the Canvas (x=0, y=0) is the upper-left corner.
distance
that computes the distance (in miles) between two cities. Estimates tell us that one degree of longitude (at our latitude) is approximately 55 miles and one degree of latitude is approximately 70 miles.
total-distance
that computes the length of a trip on which we visit all cities in a list of cities in the order in which they appear in the list.
You should first design this function using the Design Recipe. After you have tested the function and you're convinced it works, modify your function to solve the problem using accumulator style. (Hand in only the accumulator style function.)
all-states
that produces a list of all states we visit when our trip takes us to all cities in a given list of cities. Make sure each state appears in the list only once.
Using web-based turnin,
turn in a single file containing
all code and documentation for this assignment. Name your file
username-hw1.ss
, where username
is your CCC username. Your name and CCC username should
appear in a comment at the top of the file.