Program 1: Common Lisp
Due Date
This assignment is due at the beginning of
the lecture on Wednesday, September 22nd.
Partners
Everyone should complete this assignment individually.
Purpose
The purpose of this assignment is to give you practice solving
problems in Common Lisp.
Problem A: Permutations
Write a function called permutation that
has a single parameter called number. Assume
that the parameter will take on an integer value between
0 and 10 inclusive. (No error checking is needed.)
The function should print out all
of the permutations in descending lexigraphical order.
Sample Input
(permutation 3)
Required Output
The permutations are:
3 2 1
3 1 2
2 3 1
2 1 3
1 3 2
1 2 3
Problem B: Selection Sort
Write a function called selection-sort that
has a single parameter called alist. Assume
that the parameter will contain a list of some unknown
number of integers.
Furthermore, you may assume that all of the integers
are unique. (No error checking is needed.)
The function should sort the list into ascending order
using selection sort and then print out the
final list.
Sample Input
(selection-sort '(1 5 3 4 2))
Required Output
The original list was: '(1 5 3 4 2)
The sorted list is: '(1 2 3 4 5)
What to Submit
- A printout of the source code that you produce.
- A printout of your program running on the
sample output above.
- An e-mail of your solution to John at paxton@cs.montana.edu
on or before Wednesday, September 22nd at noon.
Grading
- 50% Correctness. The program produces the correct answer
on the sample inputs above, as well as on test data that I
will use in my office.
- 10% Error-Free and Warning-Free.
The program compiles with no errors and no warnings.
- 10% Elegant Code. Redundant code is minimized. The solution
is efficient. The solution is understandable.
The solution is concise. etc.
- 10% Good Style. There are no global variables. Variables names
are meaningful. Indentation is appropriate. Modern Lisp
constructs are used
(e.g. no use of car, etc.).
- 10% Appropriate Comments. The document includes a file header comment,
function header comments, tricky code comments, local variable
comments, etc. See 9/3 material for one example.
- 10% Matching the Output Format Above