CS 3304 Homework Assignment 6

25 Points
Due: 10/28 at the start of class

Note: The following instructions are repeated from the Homework Dates/Guidelines page:

Your solutions for each homework assignment must be prepared with a word processor (e.g., LaTeX or Word), and are due at the beginning of class on the due date specified unless otherwise noted on the assignment itself.

Note that all homework problems taken from the text are in the Problem Sets. Do not turn in solutions to Review Questions by mistake!

Complete each of the following problems:

  1. Chapter 6, Problem 14 (p. 278 of 5E text, in 4E: Chapter 5, Problem 14 on p. 256)

  2. Chapter 16, Problem 6 (p. 663 of 5E text, in 4E: Chapter 15, Problem 6 on p. 639)

  3. In homework assignment 5, you wrote your own implementation of the Scheme built-in function list-head.

    1. Write an equivalent Prolog predicate called list_head that takes a list and a number k, and that binds its third parameter to the sublist consisting of the first k elements of the first list.

    2. Try out your predicate to ensure it works correctly. Then try it out with a goal such as list_head([a,b,c,d], X, [a,b]). Describe what result your predicate produces and explain its behavior in this case.