Homework 1 ---------- Do pair programming! A) Write a sort function to sort a 1-dimensional array in place. Use *any* sorting algorithm -- the point is to get practice with using arrays. Write your tests *first*, and include these: sort [ ] = [ ] sort [ 3 ] = [ 3 ] sort [ 3 1 2 5 4 ] = [ 1 2 3 4 5 ] B) Now driver and navigator trade. Look at library List.fsi. Write a sorting function for pure lists. Pay attention to methods extractLeft and split. Write your tests *first*, and include these: sort <| |> = <| |> sort <| 3 |> = <| 3 |> sort <| 3, 1, 2, 5, 4 |> = <| 1, 2, 3, 4, 5 |> Once you get it working, use PureList in place of List. Homework 2 ---------- A) Write the definition of an operator MAX_WITH_INDEX that takes two 2-tuples (i1, v1) and (i2, v2) and returns the one whose value v1 is larger. Assume initially that indices are ZZ32 and values are Char. Write the corresponding Reduction. You might find it useful to import Constants.infinity. Write BIG MAX_WITH_INDEX. If presented with no data, you should throw the exception NotFound. If you wish for hints, take a look at the definition of BIG MAX. You should test your function on the following data: "" (note: see the definition of BIG MAX!) "a" "aa" "ab" "ba" "abracadabra" "dcba" "Fntlwrdlwrxx" B) Define a Generator with the following signature: object ConcatenationOfGenerators[\T\](a:Generator[\T\], b:Generator[\T\]) extends Generator[\T\] The natural order of this generator should be the elements of a, in natural order, followed by the elements of b in natural order. The generator should process a and b in parallel. Be sure to provide a corresponding sequential generator. Define an operator |||| that concatenates two generators using the above definition. Show that your generator works on the following expressions: BIG STRING (""||||"") BIG STRING ("A"||||"") BIG STRING ("Foo"||||"Bar") BIG STRING ((("The"||||"quick")||||"brown")||||"fox") Using a for loop, can you show that your generator is operating in parallel? (This may be tricky) Homework 3 ---------- Use test-driven development! Start by writing a test. Keep your partner from doing otherwise. Friends don't let friends delay testing. Find a new partner. Write a visitor over Nodes that walks over a component and produces a corresponding API, with the same name. Make use of any of the automatically generated visitors that you deem useful for completing the job.