| |
Due 5PM Friday, September 17.
Chapter 5:
- Exercise 5.3 in SOE.
- Exercise 5.5 in SOE. You should, of course, use higher-order functions
rather than direct recursion in solving these.
- Exercise 5.7 in SOE.
- Exercise 5.9 in SOE. Note that the
straightforward solution to this problem is not necessarily optimal for all sets
of coin values. For example, making change for an amount 6 given coin values
[4,3,1] is better solved as [0,2,0] rather than [1,0,2]. You are not
required to give the optimal solution, but feel free to do so if you wish.
Chapter 6:
- Define a function squares :: Int -> [Int]
such that squares n returns a list of all
perfect squares less than or equal to n.
For example, squares 50 returns
[1,4,9,16,25,36,49]. Do not use direct recursion.
- Using the function iterate from the
Standard Prelude (and possibly some other higher-order functions that we have
already discussed), define a function intSeq :: Int
-> Int -> Int -> [Int] such that intSeq a b c
is equivalent to [a, b .. c].
Solutions
|