But the defn of fib is a CAF so this should work.
> > fib = memoise (0,100) fib'
> > where
> > fib' 0 = 0
> > fib' 1 = 0
> > fib' n = fib (n-1) + fib (n-2)
Dont define fib as
fib x = memoise (0,100) fib' x
This will be very forgetful as it recomputes the memoisation on every
call to fib.
Patrick.
> From: Klemens Hemm <[EMAIL PROTECTED]>
> Date: Mon, 26 Jan 1998 17:22:24 +0100
> > > memoise :: (Ix a) => (a,a) -> (a -> b) -> a -> b
> > > memoise bds f = (!) arr
> > > where arr = array bds [ (t,f t) | t <- range bds ]
> >
>
> when using the the memoisation function for caching functions
> the cache is very forgetful.
>
> But making the cache array a CAF brings memoisation to work.
>
> Is this really necesarry ?
>
> Klemens
>