Advanced Search

Browse by Discipline

Scientific Societies

E-print Alerts

Add E-prints

E-print Network

  Advanced Search  

Programming Assignment 4 Haskell (20 Points)

Summary: Programming Assignment 4
Haskell (20 Points)
Rather than give you one large program to do, you are being asked to do a series of short
functions so that you have experience with a variety of features. Comments begin with
two hyphens and continue to the end of the line. Before each function, insert comments
which illustrate that the function works, i.e. show a few calls to the function and the
output produced.
1. Write isPrime :: Integer -> Bool which determines whether a given integer is
2. Define primes :: [Integer] which returns the list of all primes. This is an infinite
list, but because Haskell uses lazy evaluation, we will only generate as much of
the list as we need. A call such as take 5 primes would return the first five
3. Sets can be implemented using lists, provided that Ord and Eq operations are
available that implement a total order on potential set elements. Show how a
polymorphic set ADT based on lists can be implemented using Haskell
polymorphic types. Demonstrate that the same code works for sets of Int or sets
of Color. Color is defined as an enumerated type of your favorite colors.
data Color = Red | Blue| Green|Yellow|Purple|Orange|Pink
deriving (Show,Eq,Ord)


Source: Allan, Vicki H. - Department of Computer Science, Utah State University


Collections: Computer Technologies and Information Sciences