HW 8: More ML -- Patterns and Local Variables

- Set up your system so you can run ML under emacs -- it's a much nicer
environment than at the command line. Instructions can be found under
Useful Information on the class web page.
- Read 7.1-7.7 of Webber. Do exercises 2-4 and 8-10 at the end
of chapter 7. You should be able to do these without using
*let*, but feel free to use it if you find it helpful. - Read 7.8 of Webber. Write an SML function
*selsort:'a list -> 'a list*that takes a list of ints and returns a sorted version of that list using the selection sort algorithm. Recall that selection sort works as follows:- An empty or single-element list is already sorted
- For a list of two or more elements, the sorted list is the smallest element in the list followed by a sorted version of the rest of the list.

I have written this so that you can see the recursive structure, even though we didn't think of it this way when we studied selection sort in previous classes. All you have to do is figure out how to find a) the smallest element in the list, and b) the rest of the list, that is, the list without the smallest element. Use

*let*as necessary to name and/or avoid recomputing intermediate values.