What is tail recursion?

前端 未结 28 3570
一个人的身影
一个人的身影 2020-11-21 05:03

Whilst starting to learn lisp, I\'ve come across the term tail-recursive. What does it mean exactly?

28条回答
  •  渐次进展
    2020-11-21 05:21

    It means that rather than needing to push the instruction pointer on the stack, you can simply jump to the top of a recursive function and continue execution. This allows for functions to recurse indefinitely without overflowing the stack.

    I wrote a blog post on the subject, which has graphical examples of what the stack frames look like.

提交回复
热议问题