[Haskell-cafe] Memoization local to a function
Sittampalam, Ganesh
ganesh.sittampalam at credit-suisse.com
Wed Feb 25 12:46:44 EST 2009
Dusan Kolar wrote:
> Nevertheless, local version does not
> work.
Restructure your code like this:
> fibL m =
> let
> allfib = 0:1:[allfib!!n + allfib!!(n+1) | n <- [0..]]
> in allfib !! m
fibL = let allfib = 0:1:[allfib!!n + allfib!!(n+1) | n <- [0..]]
in \m -> allfib !! m
i.e. move the definition of the memo table outside the scope of
the specific parameter you want to memoise over.
Cheers,
Ganesh
===============================================================================
Please access the attached hyperlink for an important electronic communications disclaimer:
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
===============================================================================
More information about the Haskell-Cafe
mailing list