Assignment 5 for CSCI 431

You'll write programs in LISP, ML, and PostScript for this assignment.

Problem 1 -- LISP

In class, we wrote a LISP function called reverse that would reverse the elements of a list. Now write a function called oddonly that will remove every other element of a list in two different ways. Here are some examples of what oddonly should do: remember that nil is LISP's way of writing the empty list.

The first way to write oddonly is as a function that recursively calls itself.

The second way to write oddonly is as two mutually recursive functions, oddonly and evenonly, that call each other. By the way

You should use the LISP interpreter of emacs to test your code.

Problem 2 -- ML

Repeat problem 1 in ML. However, write the oddonly function in three different ways.

The first two ways are the similar to those used in problem 1:

  1. Write a recursive function oddonly.
  2. Write mutually recursive functions oddonly and evenonly.
These implementations should be very similar to your LISP functions of Problem 1 and should use ML's list operators to manipulate the lists.

The third implementation should use ML's pattern matching operators to replace the if-then-else constructions you used in the preceding implementations.

You should use the Standard ML interpreter to test out your code. An implementation of Standard ML can be downloaded from Bell Labs for PC's running Windows. It is also available as sml on the Unix workstations.

Problem 3 -- PostScript

Write a PostScript program to draw a face. If you need some inspiration look at a few faces created by C++ programs of CSCI 201 students.

Creativity will be rewarded.

You should use Ghostscript to test your code. Ghostscript is available for PC's and is also called gs on the Unix workstations.

Be sure to print your code to a PostScript laser printer.

By the way, Ken Monk of Coventry University has written an on-line Postscript tutorial that provides more information about the language.

Turning in your assignment

Copy the code you have written for this assignment into a subdirectory csci/431/homework5 of your home directory on the CSCI Unix workstations.

This assignment is due 23 November, 1999.