# NOT RUN {
trampoline(factorial(13),
factorial = function(n, x = 1) {
force(x) ## necessary thanks to R's lazy evaluation
if(n <= 1) {
return(trm_return(x))
}
val <- trm_tailcall(factorial(n - 1, x * n))
return(val)
})
# }
Run the code above in your browser using DataLab