Allow the user to create memoized recursive functions, by providing a function which can operate values as well as references to "itself".
Allow the user to create memoized recursive functions, by providing a function which can operate values as well as references to "itself".
For example, we can translate the naive recursive Fibonnaci definition (which is exponential) into an opimized linear-time (and linear-space) form:
Memoize.function[Int, Long] { case (0, _) => 1 case (1, _) => 1 case (i, f) => f(i - 1) + f(i - 2) }
Memoize a FunctionK using an HCache internally.