Exercises

Exercise 1.1.   [*] Locate the Web page for the workshop (see cover). Bookmark it. Copy and paste

Use the language level
Beginning Student
the program for removing green (section 1.5) from a picture and run the tests. Then get the expression at the bottom of the program to run. Hint: Use DrScheme’s help desk to find out how the primitives on images work. Yes, you may use any picture that you like and you have access to the Web. 

Exercise 1.2.   [*] Strings are another important class of data that most programming languages offer. With numberstring, you can even convert any number into a string, and with stringnumber you can convert a string into a number, if the string represents one. Experiment with the two functions in DrScheme’s Interactions window.

Develop the function numbers-to-strings, which consumes a list of numbers and produces a list of strings that represent these numbers. For example, (cons 1 (cons 2 (cons 3 empty))) produces '("1" "2" "3").

Also develop the function strings-to-numbers, which consumes a list of strings and converts them to numbers, if possible. In other words, it uses stringnumber on each item on the list.

Finally, develop the program strings-to-numbers*. It consumes a list of strings and converts them to numbers. If a string doesn’t represent a number, it drops the item from the list. 

Exercise 1.3.   Networks send requests. Servers process these requests and send responses back.

One way to represent a class of requests is to form a list where each item is a list of two items: a string and a boolean:

;; Request is either 
;; --- empty
;; --- (cons Line Request)
;; Line is (cons String (cons Boolean empty))

Develop the function which-toppings. The function consumes a Request and produces the list of strings that come with true in the given request.