CS 351 Lisp and Symbolic Computation
Homework 1: Basic Lisp


Due: Feb 10, 2000


This is a beginning exercise which involves writing some simple functions in Lisp. Instructions on running Lisp on the departmental workstations is given at http://www.cs.utexas.edu/users/mooney/cs351/lisp.html. See /u/mooney/cs351-code/allegro-trace for a trace of loading and debugging in Allegro Common Lisp. Submit your homework solution file called "hw1-soln.lisp" to the TA electronically using turnin. Submitted files will be automatically run on a set of novel test cases and should be able to be directly loaded into Lisp without errors. Please include any additional information to the TA in Lisp comments in the file. A trace of loading and running a solution to this assignment is in /u/mooney/cs351-code/hw1-trace.

Interleave

Define a recursive function for interleaving the elements of two lists that have the same length. For example:
(interleave '(a b c) '(1 2 3)) -> (a 1 b 2 c 3)
(interleave '(this is very) '(one really easy)) -> (this one is really very easy)

All-pairings

Define a function that returns a list of all possible ways of uniquely pairing one element of one list with one element of another list that has same number of elements. One or more helper functions may be necessary.
(all-pairings '(a b) '(1 2))
-> (((A 1) (B 2)) ((B 1) (A 2)))
(all-pairings '(tom fred bob) '(mary kathy alice))
-> (((TOM MARY) (FRED KATHY) (BOB ALICE)) ((TOM MARY) (BOB KATHY) (FRED ALICE))
    ((FRED MARY) (TOM KATHY) (BOB ALICE)) ((FRED MARY) (BOB KATHY) (TOM ALICE))
    ((BOB MARY) (TOM KATHY) (FRED ALICE)) ((BOB MARY) (FRED KATHY) (TOM ALICE)))