CS 3304 Fall 2001 Homework Assignment 5

25 Points
Due: 10/1/01 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 © 2001 Virginia Tech, ALL RIGHTS RESERVED
Last modified: November 30, 2001, 09:18:59 EST, by Stephen H. Edwards <edwards@cs.vt.edu>