As always, please include a contract, a purpose, examples, and tests for each function.
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.
Exercise 21.1.1.
Instead of (sub1 n)
just write (- n 1)
. Make
sure to write a contract for your general function.
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)
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:
filter1
that we studied last week (the one with the threshold value). This solution would give you full credit.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").
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).