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
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
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 i
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
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
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
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,
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 deni
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 i
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 i
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. Y
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 robus
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.
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 o
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