Hints on the Second Lisp Assignment
Dave Matuszek, Spring 2003

sortedp

This predicate just tests if the list is sorted. It does not sort or otherwise modify the list!

The notion of "sorted" only really applies to lists of numbers. It does not apply to lists of atoms.

A list is sorted if:

sort

A list is not an array. If you try to treat it as an array, using functions like setq and setf, you are only making things much more difficult for yourself. There's a reason I didn't teach these functions.

To insert an element into an already sorted list:

To sort a list:

permutedp

This predicate just tests if one list is a permutation of the other. It does not sort or otherwise modify either list!

Note that (a b b c d) is a permutation of (a b b c d), and that (x y z) is not a permutation of (x x y z). There is only one correct definition of permutation, and this assignment uses it.

To remove one element from a list:

To test if one list is a permutation of the other