Com S 342 --- Principles of Programming Languages EXERCISE 05: WRITING RECURSIVE PROGRAMS (File $Date: 2005/03/01 06:11:36 $) The purpose of this exercise is to have you learn more about the "cases" special form. As with all exercises, this is to be done individually. And it is due the day this topic is planned to be discussed in class, unless specified otherwise (see the syllabus at: http://www.cs.iastate.edu/~cs342/syllabus.shtml). We expect this to help you think about the readings (see below). If you don't have an answer or an answer that you think is good, write down what you read, and a question or two that would have helped you make progress. Then you can ask that question in class; there will be other people with the same problem, and everyone can learn by discussing these issues. And you'll most likely see similar things on the homework, so it's best to understand them now. READINGS: Read 2.2 of "Essentials of Programming Languages" (2nd ed., 2001), by Friedman, Wand, and Haynes. 1. [bintree-to-list] Do exercise 2.4 on page 47 in the text. You can get the define-datatype for bintree using (load-quietly-from-lib "bintree.scm") Be sure to use "cases" in your solution, as that is the main point of the exercise. The code (define bintree-to-list (lambda (bt) bt)) will pass all the tests, but won't help you learn about "cases". Test your solution using (test-ex "bintree-to-list") For this exercise, turn in a printout of your code and testing, or write down a description of the problems you had in completing the code. WHAT TO HAND IN You should have at the beginning of class, written answers for the above questions (or written out questions and problems you encountered for each part). Make sure your name is on these. Attach the printouts, if any, requested above. ADDITIONAL READINGS If you have time, read section 2.3 of "Essentials of Programming Languages" (2nd ed., 2001), by Friedman, Wand, and Haynes.