| |
Due 5PM Friday, October 29.
Chapter 14:
- Exercise 14.2 in SOE, but, as before, only for the 2nd fold law in Table
11.1,
and the third take/drop law in Table 11.2. If the property does not hold
for infinite lists, state so, and why.
- Exercise 14.3 in SOE.
- Exercise 14.5 in SOE.
Chapter 16:
- A mutable variable, or reference, in Haskell might have the
following interface:
newRef :: a -> IO (Ref a)
setRef :: Ref a -> a -> IO ()
getRef :: Ref a -> IO a
For example, here's a program that creates a
reference with an initial value of 42, then adds it to itself, finally
printing out the final value:
do r <- newRef 42
v <- getRef r
setRef r (v+v)
v' <- getRef r
print v'
Define these three functions using first-class
channels in Haskell. You should use good abstraction techniques to
make the implementation completely opaque to the user.
Solutions.
|