Recursion and while loops: pros and cons

What you are looking for is tail call elimination (also called as tail call optimization or tail recursion optimization). There have been a number of threads on the subject here, e.g. this one. According to this discussion, “Julia doesn’t have tco currently, and is fairly unlikely to add it.” That being said, a macro is being considered on Github.

1 Like