Edit your Tetris project once again. Be sure to fix any and all
problems that your graders have (or would have) discovered.
Next, you are to use local and "loops" (abstractions
such as map, foldr, filter,
etc.) wherever your functions may benefit from them,
especially for the lists of objects in your project.
You should notice that the length of your program decreases
considerably.
Part 1:
Develop data definitions for binary trees of Symbols, and
binary trees of Numbers. The numbers and symbols should
occur at the leaf positions only.
Create two instances of each, and abstract over the data
definitions.
Design the function height, which consumes any binary
tree and computes its height. That is, the maximum number of nodes
from the root of the given tree to a leaf. Here's some tests to
further explain:
(check-expect (height 5) 0)
(check-expect (height (make-node 'yes (make-node 'no 'maybe))) 2)
Part 2:
A leafy binary tree is a binary tree with the
symbol 'leaf at its leafs.
Design a function that consumes a natural number n and
creates (a list of) all leafy binary trees of height n.
Hint: Design a function that consumes a natural
number n and creates (a list of) all leafy binary
trees of height equal or less than n.
Warning: this is not about
abstraction; it's just a reminder that more interesting (and
complex) programs are around the corner.