DEV Community

Discussion on: Factorialize a Number

Collapse
 
jwkicklighter profile image
Jordan Kicklighter

I love these types of functional examples because they showcase real situations that benefit from tail-call optimization. Some languages (e.g. Haskell, Scheme) are optimized for this sort of recursion. That means the equivalent Haskell program would actually not cause a stack overflow. This is vital considering Haskell has no concept of an iterative loop, so recursive functions like this are sometimes the only way to express certain logical behaviors 🙂