CSci 1301: Problem Set 5

Due: Monday, November 3rd at 11:59pm by e-mail

You are required to write signatures and descriptions for all functions, and also descriptions of all your structures. Additionally, functions, except the world problems, must be tested using check-expect. Write your tests before you write a function (but feel free to add more after it's been writen).

The quality of your tests will be graded. Make sure to have enough test cases to demonstrate that the function is correct. I may take points off for a lack of testing (in addition to those taken off for incorrect behavior) if your function doesn't work on particular expected data and there is no test for it. It's much better to leave a test that fails (perhaps in comments) that shows that the function doesn't work on given data and you don't know how to fix it.

Shorter exercises (20 points total)

  1. Write a function last that consumes a list and returns its last element. If the list is empty, it gives an error. (4 points)
  2. Exercises 148, 149 in Section 11.1 (6 points)
  3. Write a function all-but-last that consumes a list and returns a list that consists of all elements of the original list except the very last one. If the list is empty, it gives an error. (4 points)
  4. Exercises 152, 153 in Section 11.2 (6 points)

Extended exercise (15 points total)

Exercises 178, 179, 180 in section 13.1


CSci 1301 course web site.