Wraps a recursive function inside a trampoline executor.
This function transforms a potentially recursive function (that returns a Trampoline)
into a stack-safe function that executes iteratively using the trampoline runner.
In other words, it allows you to write functions that look recursive,
but actually run in constant stack space.
Type Parameters
Args extends any[]
The tuple type representing the argument list of the original function.
Result
The final return type after all trampoline steps are resolved.
Wraps a recursive function inside a trampoline executor.
This function transforms a potentially recursive function (that returns a Trampoline)
into a stack-safe function that executes iteratively using the
trampolinerunner.In other words, it allows you to write functions that look recursive, but actually run in constant stack space.