Due date: 2/16 @ 9:50 am
Problem 0 [5%]:
Find one interesting article from the weeks news on the use of software/computers in society. Summarize the article in your own words with a single 200-word paragraph, as a pair, one playing writer, the other playing editor. Add both the article and the summary in with the rest of your problem set.
Purpose:
The goal of this problem set is to practice designing functions for data that represent lists of items. The graders will look for data definitions, contracts, purpose statements, examples/tests, and properly organized function definitions. For this assignment you must have a template for each function you design.
HtDP Problems:
9.5.4, 9.5.7, 10.2.4
Problem A2:
DrScheme provides the following class of data:
(define-struct posn (x y)) ;; Posn = (make-posn Number Number)Think of instances of
posn
as Cartesian points.
- Provide a data definition for lists of Posns.
- Provide a template for processing such lists.
- Design the function
lop-length
, which counts how manyPosn
s are on a given list ofPosn
s.- Design the function
lop-x
, which extracts all thex
coordinates from a list ofPosn
s.- Design the function
lop-draw
, which consumes a list ofPosn
s and adds them to an empty scene of 300 x 300 as red dots with a radius of 3.- Design the function
lop-filter
, which consumes a list ofPosn
s and produces one that contains only thosePosn
s from the given list that are within a 300 x 300 grid.- Design
lop-intersect
. The function consumes a list ofPosn
slop
and aPosn p
. It then determines whetherp
occurs onlop
.
Problem A2:
Here are the data definitions:
(define-struct txt (content x y)) ;; Str = (make-txt Number Number String) ;; LoStr is one of: ;; -- empty ;; -- (cons Str LoStr) (define-struct world (image hidden)) ;; World = (make-world Image LoStr) ;; intepretation: ;; the world's image represents the image that the audience ;; can see the world's list of Str represents the still ;; hidden elements
- Create a world with an empty blue 300 x 300 canvas to which the program will add the following three phrases: "Hello World", "Nice to Meet You", and "Good Bye, World", which the program will add one step at a time to the canvas. Make sure that a single change to your program changes the placements of all phrases on the slide.
- Design the function
display
, which consumes aworld
and returns its current image.- Design the function
next
, which consumes aworld
and adds the next hiddenStr
to the currently visible slide image. Use 22pt font and red for the color of the text.- Optional: Make the program run and display the animated slide from above.