What is a Trampoline function?
In Computer Programming, trampoline is associated with Jump Instructions i.e. moving to different code paths.
In functional programming, a trampoline is a loop that iteratively invokes thunk-returning functions. i.e. instead of making a recursive call to a function, we return an instruction (thunk) to call that function, to be interpreted in a loop.
Trampoline calls the recursive function in pieces until it no longer produces iterative/recursive calls. It takes recursive function as its argument, wraps it and returns a new function. Within the new function, the recursive function is called. The loop keeps running until function resolves into a value.
Use: To implement tail-recursive calls in stack-oriented programming languages.