Teaching
211 F '07
 
Assignments
The Hand In
The Recipes
The World
Set 1
Set 2
Set 3
Set 4
Set 5
Set 6
Set 7
Set 8
Set 9
Set 10
Set X1

Problem Set 9

Due date: 11/21 @ 6pm

Programming Language: Intermediate Student Language with lambda


This problem set has two main goals: first, to practice the use of existing abstractions; second, to learn how to edit programs that you have already written, an essential skill for any programmer.


HtDP Problems:

19.1.5, 20.2.4 (also see 20.2.2)

Problem A1:

Edit your Tetris project according to your grader's mark ups. Be sure to fix any and all problems that your graders have discovered in your test suite.

You may use local within existing functions, and should use "loops" (abstractions such as map, foldr, etc.) wherever your functions may benefit from them, especially when processing lists of objects in your project.

Since you have a new partner, you actually have two different code bases from which you can start. You are free to pull code from both programs. You must turn in your marked up copy along with the your fixed-up code to get credit for this problem.

Explanation: A good "manager" will help you improve your code in this manner. So imagine we (the course staff and you) are in a start-up and we don't want to waste money with program code that is difficult or impossible to maintain. Your "manager" played "copy editor" (look it up if you don't know what this means) and you're now removing typos.

Problem A2:

Here is a data definition for the most important set of numbers:


 ;; A N (Natural number) is one of: 
 ;; -- 0 
 ;; -- (add1 N)

Use zero? as the predicate for recognizing 0 and positive? for the second branch; sub1 is the selector.

Design the function count, which consumes a Natural number n and creates (list n-1 ... 0).

Design the function tens, which consumes a natural number N and creates (list (* 10 n-1) ... 0).

Abstract over the two functions according to the recipe.

Use the abstraction to define the function squares, which consumes a natural number and produces the list of squares down to 0.

Suggestion: if you still believe that the design recipe doesn't empower you to solve problems whose data definitions you have never seen before, natural numbers are covered in the book, but the relevant sections have not been assigned.


last updated on Mon Nov 19 01:21:50 EST 2007generated with PLT Scheme