The goal of this problem set is to practice the use of existing abstractions,
and how to extend programs you have already written.
HtDP Problems:
21.2.1, 21.2.2, 21.2.3
Problem A1:
Edit your Tetris project once again. Be sure to fix any and all problems that
your graders have discovered.
Next, you are to use "loops" wherever your functions may benefit from
them, especially for the lists of objects in your project.
Extend your program to "full" tetris, that is, whenever a tetra
lands, any full rows should be eliminated and all blocks above that
row should be moved down one unit.
Problem A2:
Develop data definitions for binary trees of symbols and binary trees of
numbers. Numbers and symbols should occur at the leaf positions only.
Create two instances of each. Abstract over the data definitions.
Design the function height
, which consumes any binary tree
and computes its height, that is, how far it is from the root (the given
tree) to farthest leaf.
A leafy binary tree is a binary tree with 'leaf
at its
leafs.
Design a function that consumes a natural number n
and
creates all leafy binary trees of height n
.
Hint:
Design a function that consumes a natural number n
and
creates all leafy binary trees of height equal or
less than n
? -- Warning: this is not about
abstraction; it's just a reminder that regular (and complex) programs are
around the corner.