This works, thanks a lot, you saved my day/night! :-)
As (memory) is a function, it
cannot be memoized (the function can be, but not its result, which is
what you're after).
How can a funcion be memoized but not it's result (what does this mean)!?
Since there are no side effects in Haskell why is it important that the
array is a CAF? Or let's say it that way, why can't the results of a (pure)
function be memoized since it always returns the same result for the same
parameters?
Regards
> ff t s hmm@(HMM s0 sss sts) = f t s
> where
> f 1 s = s ??? sts s0
> f t s = memory Map.! (t,s)
>
> f' 1 s = s ??? sts s0
> f' t s = sum [ (f (t-1) s') * (s ??? sts s') | s' <- sss ]
>
> memory = Map.fromList [ ((t,s), f' t s) | t <- [1..100], s <- sss ]
...which is of course completely untested. Of course, the "memoizing
fixed point combinator" Chris Okasaki posted a while ago would be far
more elegant, I'm just too lazy to dig it up.
_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now!
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe