recursiveCalls.Rd
recursiveCalls
computes the result of a recursive function
call and prints all recursive calls
recursiveCalls(recFunc, ...)
... | the parameters of the function to be called |
---|---|
recfunc: | the recursive function to be called without the parenthesis or the arguments; must have at least one recursive function call |
the result of calling the input function with the given parameters
This function takes a recursive function and its parameters and returns the result of that function call and also prints all recursive calls. Useful for checking for errors in recursive functions.
recursiveCalls(fib,5)#> [1] "fib(5)" #> [1] "fib(4)" #> [1] "fib(3)" #> [1] "fib(2)" #> [1] "fib(1)" #> [1] "fib(0)" #> [1] "fib(1)" #> [1] "fib(2)" #> [1] "fib(1)" #> [1] "fib(0)" #> [1] "fib(3)" #> [1] "fib(2)" #> [1] "fib(1)" #> [1] "fib(0)" #> [1] "fib(1)"#> [1] 5