CS 3304 Spring 2000 Homework Assignment 5

30 Points
Due: 2/24/00 at the start of class

Complete each of the following problems:

  1. Consider the following Prolog code, taken from an on-line tutorial linked from the class home page:
        takeout(X, [X|R], R).
        takeout(X, [F|R], [F|S]) :- takeout(X, R, S).
    
    1. Describe what this predicate does.
    2. Write a Scheme implementation of takeout that behaves as closely as possible to this Prolog predicate.
    3. In what way(s), if any, is the behavior of your Scheme code different from the behavior of the Prolog code?

  2. Write a Scheme implementation of takeout_all that removes every instance of its first parameter at the top level of its second parameter, which is a list.

  3. Write a Prolog implementation of takeout_all.

copyright © 2000 Virginia Tech, ALL RIGHTS RESERVED
Last modified: August 11, 2000, 15:51:21 EDT, by Stephen Edwards <edwards@cs.vt.edu>