Assignment 8: Accumulators (due Nov 3)



Before you tackle the homework, remind yourself of our General Advice, Advice on Homeworks, and Grading Guidelines. Above all, keep your work neat and honest.


  1. (3 pts) Write an accumulator-style program length which consumes a list (of any type) and produces a number. The number should be the count of all elements in the list. For example:

    (length (list 4 5)) = 2

    (length (list 'a 3 'b "hi")) = 4

  2. (3 pts) Write an accumulator-style program palindrome which consumes a list of symbols and produces a list of symbols. The program creates a palindrome (a sequence of symbols that reads the same forwards as it does backwards) out of the input list. Here are some examples:

    (palindrome empty) = empty

    (palindrome (list 'a)) = (list 'a)

    (palindrome (list 'a 'b)) = (list 'a 'b 'a)

    (palindrome (list 'w 'e 't 's)) = (list 'w 'e 't 's 't 'e 'w)





Kathi Fisler This page was generated on Wed Oct 27 12:18:11 CDT 1999.