Paulo Silva Filho Paulo Silva Filho - 1 year ago 83
R Question

Tail recursion on R Statistical Environment

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

Answer Source

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

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

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download