CS 3304 Spring 2001 Homework Assignment 5

30 Points
Due: 2/21/01 at the start of class

Complete each of the following problems:

  1. Chapter 15, Problem 6 (p. 639). You may not use the predefined union predicate in your solution. If you are testing your answer out using a Prolog interpreter, call your predicate my_union so that it is not confused with the builtin version.

  2. Write and test a Prolog implementation of the predicate prefix(A, B) that tests to see if the list A is a valid prefix of the list B:
        ?- prefix([1,2,3],[1,2,3,4,5]).
        yes
    
        ?- prefix([1,2],[1,a,2,3]).
        No
    

  3. Write a Scheme implementation of prefix that behaves as closely as possible to this Prolog predicate. In what way(s), if any, is the behavior of your Scheme code different from the behavior of the Prolog code?

copyright © 2001 Virginia Tech, ALL RIGHTS RESERVED
Last modified: April 23, 2001, 15:39:00 EDT, by Stephen H. Edwards <edwards@cs.vt.edu>