Com S 342 --- Principles of Programming Languages HOMEWORK 2: STATIC PROPERTIES OF VARIABLES (File $Date: 1995/10/04 01:35:51 $) Due: problem 1,2,4,6 at beginning of your discussion section, September 15, problems 9-11 at the beginning of class, September 20. In this homework, you will learn static properties of variables and the lambda calculus. For coding problems, code is to be written in Scheme, using the exact procedure names specified in the problem descriptions. For code hand in *both* your printout of the code and a transcript of testing. See the directory $PUB/data/hw2/hw2.tst for test data for each coding problem. (You can use the procedure test-hw2 to run our tests, as described in homework 1. Recall that $PUB means /home/cs342/public.) The section headings below give the readings related to the problems. (Please read them!) ESSENTIALS OF PROGRAMMING LANGUAGES: Section 2.3.1 1. (10 points) Do exercise 2.3.1 in the text. [free-vars, bound-vars] Remember, for all coding problems, you must hand in a transcript showing testing using our test data (see above). For this problem, you can use (test-hw2 "free-vars") (test-hw2 "bound-vars") on the Com S department machines when running scm342 to test these. 2. (10 points) Do exercise 2.3.2 in the text. [free?, bound?] 3. (suggested practice) Do exercise 2.3.3 in the text. 4. (10 points, extra credit) Do exercise 2.3.4 in the text. 5. (10 points, extra credit) Do exercise 2.3.5 in the text. [free-vars+multiple, bound-vars+multiple] For this problem, you should write two procedures: free-vars+multiple and bound-vars+multiple. 6. (10 points) Do exercise 2.3.6 in the text. [free-vars+if, bound-vars+if] For this problem, you should write two procedures: free-vars+if and bound-vars+if that are similar to those in problem 1, but also handle the syntax of if-expressions. 7. (suggested practice) Do exercise 2.3.7 in the text. The question can be rephrased: if you add the syntax (quote e) to the lambda-calculus, how would your definition of free-vars and bound-vars have to change? 8. (suggested practice) Do exercises 2.3.8 and 2.3.9 in the text. [scoping] 9. (50 points, extra credit) Do exercise 2.3.10 in the text. [lexical-address] 10. (5 points) Do exercise 2.3.11 in the text. (This can be handwritten.) 11. (5 points) Do exercise 2.3.12 in the text. (This can be handwritten.) 12. (25 points, extra credit) Do exercise 2.3.13 in the text. [un-lexical-address] 13. (10 points, extra credit) Do exercise 2.3.14 in the text. 14. (10 points, extra credit) Do exercise 2.3.15 in the text.