CS 3304 Fall 2001 Homework Assignment 9

25 Points
Due: 11/05/01 at the start of class

Complete each of the following problems:

  1. Write an implementation for the Prolog predicate nth(Index,List,Element) that finds the Nth element of the given List, where the first element is counted as number 1. (This predicate is actually called nth1 in SWI-Prolog; there is also an nth0 predicate; you may use neither in your solution for this question).

  2. Chapter 7, Problem 10 (pp. 306-307 of 5E text, in 4E: Chapter 6, Problem 10 on p. 285. In some older 4E texts, the "10" is missing. The problem starts with the paragraph "Assume the following rules of associativity ..." in the paragraph following problem 9.)

  3. Chapter 7, Problem 21 (p. 308 of 5E text, in 4E: Chapter 6, Problem 21 on p. 286)

copyright © 2001 Virginia Tech, ALL RIGHTS RESERVED
Last modified: November 30, 2001, 09:19:00 EST, by Stephen H. Edwards <edwards@cs.vt.edu>