All homework and programming exercises must be prepared in accordance with the instructions given in the Syllabus. Each assignment must be submitted to your instructor by its stated deadline.
When complete, submit your Haskell source and testing files to the course Blackboard site. This is an individual assignment.
Develop Haskell functions to solve exercises 1, 3, 4, 5, 6, 7, and 8 from Chapter 2, Basic Haskell Functional Programming. You may put all these functions in the same module and include functions to test them appropriately.
Develop a Haskell function sumsqbig
that takes three numbers as arguments and returns the sum of the squares of the two larger numbers. That is sumsqbig 2.0 1.0 3.0
yields 13
.
OMITTED
Develop a Haskell Boolean function div23n5
such that div23n5 n
returns True
if and only if n
is divisible by 2 or divisible by 3 but not divisible by 5. That is, div23n5 6
yields True
and div23n5 30
yields False
.
Develop a Haskell function notDiv
such that notDiv n d
returns True
if and only if integer n
is not divisible by d
. That is, notDiv 10 5
yields False
and notDiv 11 5
yields True
.
Develop a Haskell function mult
that takes two natural numbers (i.e., nonnegative integers) and returns their product. The function must not use the multiplication (*
) or division (div
) operators. Hint: Multiplication can be done by repeated addition.
Develop a Haskell function addTax
that takes two Double
values such that addTax c p
returns c
with a sales tax of p
percent added. For example, addTax 2.0 9.0
returns 2.18
.
Also develop a function subTax
that is the inverse of addTax
. That is, subTax (addTax c p) p
yields c
.
The time of day can be represented by a tuple (hours,minutes,m)
where m
indicates either "AM" or "PM". Develop a Boolean Haskell function comesBefore
that takes two time-of-day tuples and determines whether the first is an earlier time than the second. (Note: Consider midnight and noon.)
Develop a Haskell function
minf :: (Int -> Int) -> Int
such that minf g
returns the smallest integer m
such that 0 <= m <= 10000000
and g m == 0
(if such an integer exists).