Midterm

Topics Covered

Topics Not Covered

Exam Rules

Practice Exam

Additional Practice Questions

  1. Write a function that takes a list and drops every second element, e.g. (1, 2, 3, 4, 5) -> (1, 3, 5). Use fold.
  2. Write a function that takes a list and swaps adjacent elements, e.g. (1, 2, 3, 4, 5) -> (2, 1, 4, 3, 5). Use fold.
  3. Write a Scala program that parses Lisp expressions. A Lisp expression has the form ( e1 e2 ... ), where ei is a list, integer, or identifier, or 'e, where e is a list or identifier.
  4. Change the arithmetic parser from the lab of lecture 10 so that it handles expressions of the form sqrt e, where e is an expression. (Compute the integer square root.) The sqrt operator should bind more strongly than multiplication—sqrt 4 * 10 is 20.