ackermann <- function(m, n) {
	if (m == 0)
		return(n + 1)
	else if (m > 0 && n == 0)
		return(
			Recall(m - 1, 1)
		)
	else if (m > 0 && n > 0)
		return(
			Recall(
				m - 1,
				Recall(m, n - 1)
			)
		)
	stop("Should never get here")
}

counter <- 0

trace(ackermann, quote(counter <<- counter + 1), print=FALSE)
ackermann(3, 3)
untrace(ackermann)

cat("ackermann is called", counter, "time(s)\n")
