CPSC 425 Spring 2006
HW 8: More ML -- Patterns and Local Variables

  1. 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.

  2. 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.

  3. 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:

    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.