## CSci 1301: Problem Set 8

#### Due Tuesday, November 24th at 11:59pm by e-mail

As always, please include a contract, a purpose, examples, and tests for each function.

### Problem 1 (4 points)

Exercise 20.2.4 parts 1, 2. Write the contracts in your e-mail message or in comments. You don't need to write the functions.

### Problem 2 (6 points)

Exercise 21.1.1. Instead of `(sub1 n)` just write `(- n 1)`. Make sure to write a contract for your general function.

### Problem 3 (6 points)

Exercise 21.2.1 parts 1, 2, 3 only. Make sure to test your functions, submit your tests.

Below is an example of using `build-list` to produce the squares of the first 10 integer numbers. `build-list` takes a number of elements it needs to produce and a function from an integer n to the n-th element on the list, e.g. n -> square(n).

``````
(define (square n) (* n n))

(build-list 10 square)
``````

### Problem 4 (4 points)

Exercise 21.2.3 part 3 only. UPDATE as of 2:45pm Wedn., Nov. 19th: solving this problem using the predefined `filter` is tricky at this point. A couple of work-arounds:

• Use `filter1` that we studied last week (the one with the threshold value). This solution would give you full credit.
• Use "local" to define a helper function and use the predefined `filter`. For this solution you can get full credit plus some extra credit. The credit is not additive (i.e. if you do both approaches, you will get credit only for using "local").

### Problem 5 (5 points)

Write a function `standard-dev` that consumes a list of `ummstudent` records defined in the in-class example and computes their standard deviation according to the formula at http://en.wikipedia.org/wiki/Standard_deviation#Discrete_random_variable_or_data_set . Use any of the predefined list functions (map, foldr, etc).

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.