1. Read section 5.1 of [Harper](http://www.cs.cmu.edu/~rwh/isml/book.pdf) about tuple types and tuple patterns. Also look at the list examples in sections 9.1 and 9.2 of Harper. Now consider the pattern `(x::y::zs, w)`. For each of the following expressions, tell whether the pattern matches the value denoted. If the pattern matches, say what values are bound to the four variables `x`, `y`, `zs`, and `w`. If it does not match, explain why not. (a) `([1, 2, 3], ("COMP", 105))` (b) `(("COMP", 105), [1, 2, 3])` (c) `([("COMP", 105)], (1, 2, 3))` (d) `(["COMP", "105"], true)` (e) `([true, false], 2.718281828)` Answers here: (a) (b) (c) (d) (e) You are now starting to be ready to use pattern matching. 2. Look at the clausal function definition of `outranks` on page 83 of [Harper](http://www.cs.cmu.edu/~rwh/isml/book.pdf). Using the clausal definition enables us to avoid nested `case` expressions such as we might find in Standard ML or μML, and it enables us to avoid nested `if` expressions such as we might find in μScheme. This particular example also collapses multiple cases by using the "wildcard pattern" `_`. A wildcard by itself can match anything, but a wildcard in a clausal definition can match only things that are not matched by preceding clauses. Answer these questions about the wildcards in `outranks`: (a) In the second clause, what three suits can the `_` match? → (b) In the fifth clause, what suits can the `_` match? → (c) In the eighth and final clause, what suits can the `_` match? → You are now ready to match patterns that combine tuples with algebraic data types. 3. In Ramsey's chapter 5, the `eval` code for applying a function appears in code chunk 365c. In evaluating `APPLY (f, args)`, if expression `f` does not evaluate to either a primitive function or a closure, the code raises the `RuntimeError` exception. (a) Show a piece of μScheme code that would, when evaluated, cause chunk 365c to raise the `RuntimeError` exception. → (b) When exception `RuntimeError` is raised, what happens from the user's point of view? You are now ready for problems G, L, and M. 4. "Free" variables are those that are not bound to a value in the current scope. You can find a longer discussion and precise definition in section 5.11 of Ramsey's book, which starts on page 375. Read the section and identify the free variables of the following expressions: (a) Free variables of `(lambda (x) (lambda (y) (equal? x y)))` → (b) Free variables of `(lambda (y) (equal? x y))` → You are now ready to improve the μScheme interpreter in problem 2.