On this page:
1 Midterm advice
2 Pre-landing check
3 Follow the template and make a wish
8.5

Lecture 19: Follow the template

This assignment is due on Sunday, March 20 at 11:59pm. Submit it using Handin as assignment lecture19.

1 Midterm advice

Our second midterm is Tuesday night! The advice from the first midterm is still valid:
  • Read every word of instructions.

  • Define everything you use.

  • Solve old problems.

Feel free to ask questions, like on Discord!

2 Pre-landing check

Are you ready? Click the button

Check your answer using “Show answer” above. Did you get it right? If not, click the button again to get another set, and keeping doing it until you get it right without peeking at the answer.

You don’t need to submit anything for this check.

3 Follow the template and make a wish

Exercise 1. To review what we’ve learned, let’s design a function our-sort to sort a list of numbers into ascending order. Do steps 1–4 of the design recipe: write the template meticulously (named our-sort), but don’t fill it in.

Exercise 2. We wish we could just fill in the template by replacing the dots with the name of a helper function. Design the function insert which takes a Number and a ListOfNumbers and puts the number in the correct place in the list, assuming the list is already sorted. The new number should go before all the numbers bigger than it, and after all the numbers smaller than it. Don’t use the built-in sort function.