3 ms·
In many cases, with tail call optimization, turning specific types of recursion into iteration (which doesn’t use more than a constant amount of stack space).
by elipsitz 5y ago
In many cases, with tail call optimization, turning specific types of recursion into iteration (which doesn’t use more than a constant amount of stack space).
- masklinn 5y agoNot tail call optimisation, tail call elimination. If the language is based on recursion, you can't just hope it happens commonly enough, it has to happen all the time, even for corecursive functions. Except I've never been super clear on Haskell having TCE or not, because laziness means there are limited opportunities for it to even fire.
- tome 5y agoBecause function evaluation is lazy all Haskell (well, GHC) calls are tail calls. The only thing that consumes stack is case.