Exercises
Exercise 1.1. [*] Locate the Web page for the workshop (see cover). Bookmark it. Copy and paste
| Use the language
level Beginning Student |
Exercise 1.2. [*]
Strings are another important class of data that most programming languages
offer. With number→string, you can even convert any number into
a string, and with string→number 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 string→number 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:
;;Requestis either ;; ---empty;; ---(cons Line Request);;Lineis(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.