This assignment makes use of the files contained in this zip file. This assignment is due Friday, May 3.
The idea of this assignment is roughly this. Given a list of triples of positive integers, like this,
(5 8 3) (5 8 1) (8 6 7) (6 1 1) (1 9 6) (4 3 1) (8 4 6) (7 9 3) (8 8 3) (4 1 5)
write code that sorts the list in each of the following ways.
The real goal of the assignment is to implement these sorts in as little code as possible, hopefully by using carefully parameterized comparators. There are purposely a large number of sorts to try to force you to emphasize code reuse. (One obvious way to do this problem is to write ten different comparators, one for each sorting problem, but that will lead to a lot of redundant code.)
In the zip file there are solutions to this problem in three different languages, Java, Haskell, and Racket. The Java version is probably the one you will have the least trouble reading. The Haskell version is there because Rust takes a lot of ideas from Haskell, so the Rust solution may even end up looking more like Haskell than Java. The Racket version is in there because I wrote it several years ago, so why not include it.
Your Rust program needs to do three things. Generate a random list (or array) of integer three-tuples. Define a single "comparator factory function" that can be used to instantiate all ten of the needed comparators. Then sort the list of three-tuples ten times, using your comparator factory to generate a different comparator for each sort, and print the results.
Turn in a zip file called CS51520Hw4Surname.zip
(where Surname
is your last name) containing your version of triples.rs
.
This assignment is due Friday, May 3.