8.7

### Lecture 30: How long does it take?

This assignment is due on Tuesday, April 25 at 11:59pm. Submit it using Handin as assignment lecture30. You only need to submit the first 3 exercises.

Exercise 1. Using the function add-to-end from Lecture 25: Accumulators:
• Calculate step-by-step
 (add-to-end "man" (list "dog" "bites")) = ... = ... = (list "dog" "bites" "man")

• Calculate step-by-step
 (add-to-end "mail" (list "dog" "bites" "man")) = ... = ... = ... = (list "dog" "bites" "man" "mail")

• Calculate step-by-step
 (add-to-end "area" (list "dog" "bites" "man" "mail")) = ... = ... = ... = ... = (list "dog" "bites" "man" "mail" "area")

Because our purpose here is to count steps, make sure to follow the steps in the video above. Careful use of find-and-replace can speed up your work. Do not put these calculations in comments.

Exercise 2. Using the function add-to-end from Lecture 25: Accumulators:
• How many servings of steps does it take to add to the end of a 2-element list? Define this number as a constant named add-to-end-2

• How many servings of steps does it take to add to the end of a 3-element list? Define this number as a constant named add-to-end-3

• How many servings of steps does it take to add to the end of a 4-element list? Define this number as a constant named add-to-end-4

Exercise 3. Using the function rev from Lecture 25: Accumulators:
• How many servings of steps does it take to reverse a 3-element list? Define this number as a constant named rev-3

• How many servings of steps does it take to reverse a 4-element list? Define this number as a constant named rev-4

• How many servings of steps does it take to reverse a 5-element list? Define this number as a constant named rev-5

For the rest of this page, you don’t need to submit anything, but do watch the videos and try the exercises anyway. We’ll work through the material together in class. 