[Haskell-cafe] Memoization in Haskell?

Angel de Vicente angelv at iac.es
Thu Jul 8 17:30:05 EDT 2010


I'm going through the first chapters of the Real World Haskell book,
so I'm still a complete newbie, but today I was hoping I could solve
the following function in Haskell, for large numbers (n > 108)

f(n) = max(n,f(n/2)+f(n/3)+f(n/4))

I've seen examples of memoization in Haskell to solve fibonacci
numbers, which involved computing (lazily) all the fibonacci numbers
up to the required n. But in this case, for a given n, we only need to
compute very few intermediate results.

How could one go about solving this efficiently with Haskell?

Thanks in advance,
Ángel de Vicente

High Performance Computing Support PostDoc
Instituto de Astrofísica de Canarias
ADVERTENCIA: Sobre la privacidad y cumplimiento de la Ley de Protección de Datos, acceda a http://www.iac.es/disclaimer.php
WARNING: For more information on privacy and fulfilment of the Law concerning the Protection of Data, consult http://www.iac.es/disclaimer.php?lang=en

More information about the Haskell-Cafe mailing list