CS 2010 Homework 9   - Due October 21

Setup

There is no setup for this assignment.

Assignment

Exercise 9.1, Accumulating

Implement the function ok-dessert? that takes a list of symbols and checks that'cake appears in the list only after'veggies, and that'cake never appears twice in the list unless the two instances are separated by'veggies.

    (ok-dessert? empty) "should be" true
    (ok-dessert? '(cake)) "should be" false
    (ok-dessert? '(veggies hamburger cake)) "should be" true
    (ok-dessert? '(veggies hamburger cake cake)) "should be" false
    (ok-dessert? '(veggies hamburger cake veggies cake)) "should be" true

Start with a normal list-of-sym template, but add an accumulator that indicates whether dessert is currently allowed.


Last update: Wednesday, October 15th, 2003
mflatt@cs.utah.edu