Ithaca College Logo Ithaca College Home Blue Header

Ithaca College, Ithaca, New York
*

Practicum 2

Due: Thursday, 7 February.


Objectives:

Reference: The Scheme Programming Language, R. Kent Dybvig, Addison-Wesley, 2003.


Requirements:


Practicum:

  1. Define a procedure called third that takes one parameter that is a list and that returns the third item in the list. The list may or may not contain three items. You must check to make sure that the argument is a list (and not some other data type). You may not use the list operator in your solution. Test your procedure on:
  2. Define a procedure juggle that rotates a three-element list. The procedure juggle returns a list that is a rearrangement of the input list so that the first element of this list becomes the second, the second element becomes the third, and the third element becomes the first. You may not use the list operator in your solution. You may assume that the argument you receive is a list of three items. Test your procedure on:
  3. Define a function subst-item(new old ls) that takes three parameters: an item new, an item old, and a list of items ls. The list may or may not be empty. The function subst-item looks for all top-level occurrences of the item old in ls and replaces it with the item new. Test your function on the following items. You may not use the list operator in your solution. Hint: use equal? to test items.


Last updated on 31 Jan 2008 by John Barr