| Second Lisp Assignment: Sorting and Permutation Dave Matuszek, Spring 2003 |
This one is easy to describe. Write three functions:
sort, to sort a list of integers into ascending order;sortedp, to test whether a list of integers is in ascending
order; andpermutedp, to take two lists of atoms and determine if one
list is a permutation (rearrangement) of the atoms in the other list.You may, of course, write any additional functions you need in order to accomplish
the above. These functions form a nice related group, because sortedp
and permutedp can be used to test whether the sort
function works properly.
Lisp notes:
You will need to be able to compare integers. The functions <,
<=, =, /=, >=, and
> are all defined in Lisp (along with EQ, which
is the same as = when applied to integers). These are functions,
not operators, so you would say, for example, (< A B), not
(A < B).
XLisp has trouble with file names longer than 8.3 characters; they can be loaded
from the menu but not with the load function.
Due date:
Because I was late in getting this assignment posted, the due date will be Monday, February 3, before midnight. The following assignment (in Java) will be due the same week (Thursday, February 6), so there will be some overlap.