Math 6833 assignments
31. Use foldr1 to dene the composition function
compose : (a -> a) -> Int -> (a -> a), where compose f n is the function that
composes f with itself n-1 times (that is, compose f 3 is f f f).
32. Load the module Matrix (on the links
Math 6833 assignments
6. Another one: Set up structures to work with graphs. Write a function to determine
whether a graph is connected, or better yet to enumerate its components. Write a
function to nd a maximal tree in a connected graph.
7. Another one:
Math 6833 assignments
22. Use recursion to dene functions orList : [Bool] -> Bool and andList : [Bool]
-> Bool, where orList is true when at least one of the entries in the list is true, and
andList is true when all of them are true.
23. Use recursion to
Math 6833 assignments
12. Another open-ended project: For the case of alternating groups, modify genPairs.gap
to do some more rened investigation. For example, one reason a pair might not
generate is that they have a common xed element. Write routines tha
Getting started on the Haskell HUGS interpreter
The HUGS Haskell interpreter works similarly to the GAP interpreter. When you start it
up, you will see a prompt that looks like:
Hugs>
As with GAP, you can sit and type commands at the prompt, but for most
A rst look at Haskell functions
Functions are fundamental to Haskell, and it provides us with many ways to dene them.
First, we must look at how to dene their types.
The basic form of a function type denition:
f : a -> b
which says that f is a function th
Map, lter, and list comprehension Now that we have a basic knowledge of lists and functions, we can start to look at some of the powerful constructs available in Haskell. The rst is the map function, which comes originally (as far as I know) from the mapc
Recursive functions We have seen how to dene and use functions in Haskell, and how to work with lists. Some very nice things happen when one combines the two using recursion. A recursive function denition gives the function in terms of itself. Lets start
Example: working with matrices To illustrate some more complicated list manipulation, we will dene the basic mathematical functions on matrices. For simplicity, we will just use integer matrices. As in GAP, a vector will be a list of numbers, and a matrix
Math 6833 assignments
3. Get started on GAP:
(a) Try to download GAP and get it running on your machine.
(b) Once you have GAP installed, the next task is to be able to read the manual. The
best way is to put a link on your browser which takes you to the
Math 6833 assignments
15. (due 9/28) Write a brief report on your work with GAP to date. Also, describe your
work with any other software that you have examined as part of your eort for this
course. You can hand this in as a physical document or as email.
Math 6833 assignments
28. Write functions that do the following.
1. shuffle : [a] -> [a] -> [a], that has the eect
shuffle [x1,x2,x3,x4] [y1,y2,y3,y4] = [x1,y1,x2,y2,x3,y3,x4,y4]
Write a version robustShuffle that just drops extra terms, but write shuffle
Math 6833 assignments
19. Write the following functions in Haskell. For the rst two, try to write them in two or
three dierent ways, making use of dierent Haskell devices such as guards and where.
1. threeEqual : Int -> Int -> Int -> Bool for which threeE
Math 6833 assignments
1. Start thinking about how you might use computing in your current research or area
of research interest. The goal is to come up with a project or projects that you might
work on this semester so that you can work on developing the
A rst look at Haskell lists
Lists are fundamentally important in Haskell. Lets start by trying to dene a list, as we
would in GAP:
Hugs> x := [1,2]
We get the error
ERROR - Undefined data constructor ":="
OK, lets try
Hugs> x = [1,2]
ERROR - Syntax error