MemoizedDeepRecursiveFunction

fun <T, R> MemoizedDeepRecursiveFunction(cache: MemoizationCache<T, R> = AtomicMemoizationCache(), block: suspend DeepRecursiveScope<T, R>.(T) -> R): DeepRecursiveFunction<T, R>(source)

Defines a recursive pure function that:

  • keeps its stack on the heap, which allows very deep recursive computations that do not use the actual call stack;

  • memoizes every call, which means that the function is execute only once per argument.

MemoizedDeepRecursiveFunction takes one parameter of type T and returns a result of type R. The block of code defines the body of a recursive function. In this block callRecursive function can be used to make a recursive call to the declared function.