# CS 3520 Homework 6   - Due October 17

### Exercise 6.1, Set! finger exercises

• Complete the following Scheme definition (replace the "..."):
```          (define (ex1 v1 v2)
(let ([f ...])
(begin
(f v1)
(f v2))))```
so that the value of (ex1 n m) is (list m n) for any integers n and m. The catch is that neither v1 nor v2 may appear in anywhere within the expression replacing "...".
• Complete the following Scheme definition (replace the "..."):
```          (define (ex2 v1 v2)
(let ([mk ...])
(let ([f (mk)]
[g (mk)])
(begin
(f (list v1))
(g (list v2))
(g '())))))```
so that the value of (ex2 n m) is (list n m) for any integers n and m. As before, neither v1 nor v2 may appear in anywhere within the expression replacing "...".
• Complete the following Scheme definition (replace the "..."):
```          (define (ex3 v1 v2)
(let ([mk ...])
(let ([f (mk)]
[g (mk)])
(begin
(g (list v1))
(f (list v2))
(g '())))))```
so that the value of (ex3 n m) is (list n) for any integers n and m. As always, neither v1 nor v2 may appear in anywhere within the expression replacing "...".
• Complete the following Scheme definition (replace the "..."):
```          (define (ex4 v1 v2 v3 v4)
(let ([mk ...])
(let ([f (mk)]
[g (mk)])
(begin
(f (list v1) (list v2))
(g (list v3) (list v4))
(list (f '() '()) (g '() '()))))))```
so that the value of (ex4 n m p q) is (list (list n m q) (list m q p)) for any integers n, m, p, and q. Of course, v1, v2, v3, or v4 may not appear in anywhere within the expression replacing "...".

Hand in a single file, hw6.scm, with the completed ex1, ex2, ex3, and ex4. No contracts, purpose statements, or examples are necessary.

Important: You solution must not contain any expressions or definitions except for ex1-ex4, and you cannot modify the given definitions except to replace the "...".

 Last update: Tuesday, October 8th, 2002mflatt@cs.utah.edu