Assignment 2: Simple functions
Due: Friday, September 8, 11:59:59 PM EST.
The following should be completed in cooperation with your assigned partner from lab 1. (Partner assignments are listed on Piazza.)
1 HtDP exercises
Complete HtDP exercises 13, 14, and 18–20.
2 Render string
Design the function render-string, which consumes a number t and produces a text image of the first t letters from the string "qwerty".
Place the text on a white 200 x 100 rectangle. Use black text of font size 22.
3 Add message
Write the function add-message. Its task is to create an image that represents a sequence of chat messages.
The function consumes three items:
a string, which represents the name(s) of the sender of the latest message;
another string, which represents the latest message; and
an image, which represents what has been said so far and by whom.
The function produces an image that represents the complete history, that is, the history combined with the latest message.
There are no constraints on how you wish to represent messages in an image as long as it clearly expresses who said what.
Here is one possible usage scenario:
(define history-1 empty-image) (define history-2 (add-message "Matthias and Becca" "hello world" history-1)) (define history-3 (add-message "Ben and Alan" "hello, you guys" history-2)) (define history-4 (add-message "Leena and Nada" "good bye" history-3))
That is, the image argument to add-message is likely to be something that the function produced before, but it doesn’t have to be so.