Comp210
Due: 97.Oct.28 (Wed.) in class
As usual, you should include contracts, test cases, etc.
Given the function f, one way to compute an approximate value for the integral of f from a to b is to:
The choice of sub-intervals has a significant effect on the accuracy of the approximation. The simplest choice would be to subdivide [a,b] into n equal sub-intervals. Unfortunately, this approach requires a large number of sub-intervals for parts of the function that have sharp peaks and valleys, which is wasteful for the parts of the function that are smooth. Plus, it's not clear how large ``large'' should be, for different functions.
For this homework, we will use a better method:
subdivide [a,b] into intervals in an adaptive
manner until the difference between trapezoid area for the interval
Your assignment is to to write a Scheme function integrate that
takes four parameters:
The result of (integrate f a b epsilon) is the approximate area
under
the integral according to the adaptive quadrature method described above.
(define second (compose first rest)) (second (list 2 3 4 5)) = 3 ((compose add1 sqrt) 4) = 3
#t
if and only if key agrees with
the password used to create the lock.
Example:
(define my-passwd (create-lock 'secret-handshake)) (check-lock my-passwd 'is-this-it?) = #f (check-lock my-passwd 'secret-handshake) = #t my-passwd ;; No interesting information should be printed in drscheme!Note that using a symbol for the lock would not be secure at all: evaluating the placeholder
my-passwd
above would reveal the symbol.
Your representation should be secure in the sense that
if you didn't see my call to create-lock
,
there is nothing you could type at my drscheme window
to get check-lock
to answer #t
,
short of systematically trying all passwords (or making a
lucky guess).
So what type of Scheme value might a lock be?
Well, this is the homework about functions which
accept/create/return other functions....
In writing create-lock
,
you may use local if you wish,
though it is not necessary nor advised.