Paulo Silva Filho - 3 months ago 16

R Question

Does R support proper tail recursion and where can I find documentation about this?

Answer

It's quite easy to find out that R does not support tail recursion optimization:

```
f <- function(n) {
if (n != 0) f(n-1)
}
f(100000)
# Error: evaluation nested too deeply: infinite recursion / options(expressions=)?
```

Had tail calls been optimized to jumps, then this function would have terminated without problems.