How to recognize what is, and what is not tail recursion?

后端 未结 4 1910
终归单人心
终归单人心 2020-12-29 09:47

Sometimes it\'s simple enough (if the self call is the last statement, it\'s tail recursion), but there are still cases that confuse me. A professor told me that \"if there\

4条回答
  •  情深已故
    2020-12-29 10:45

    All your functions are tail recursive.

    no instruction left after the self-call

    means: After the self-call, you return from the function, i.e. no more code has to be executed, and not that there is no more line of code in the function.

提交回复
热议问题