Lecture 19: Space invaders using built-in abstractions (TODO)
This assignment is due on Sunday, October 27 at 11:59pm. Submit it using Handin as assignment lecture19. You only need to submit the first 0 exercises.
1 Midterm advice
Read every word of instructions.
Define everything you use.
Solve old problems, including those on the first midterm and before. Students who don’t review that basic material are often surprised by how poorly they do on the second midterm.
Feel free to ask questions, like on Discord!
2 More midterm review
For the rest of this page, you don’t need to submit anything.
Exercise 1. Recall the data definition of Mobile from Problem set 6: Unions and recursion. Design the function count-leaves which counts how many leaves are in a given Mobile.
Exercise 2. Design the function count-big-leaves which counts how many leaves of weight more than 10 are in a given Mobile.
Exercise 3. Design a function remove-multiples-of-10 that removes every number divisible by 10 from a list of numbers. Use filter.
Hint: Study the signature and purpose of filter in Figure 95 of the textbook. What is X?
Exercise 4. Design a function has-multiple? that takes a list of numbers and a number as inputs, and checks whether any number in the given list is a multiple of the given number. Use ormap.
Hint: Study the signature and purpose of ormap in Figure 95 of the textbook. What is X?
Exercise 5. Design a function move-invaders which takes a list of Posns and increases each Y coordinate by 1. Use map.
Hint: Study the signature and purpose of map in Figure 95 of the textbook. What is X and what is Y?