# \#recursion

**URL:** https://erlangforums.com/tag/recursion/461.md

[Latest](https://erlangforums.com/latest.md) · [Categories](https://erlangforums.com/categories.md) · [Tags](https://erlangforums.com/tags.md)

---

## [Where do base cases fit into tail call optimization?](https://erlangforums.com/t/where-do-base-cases-fit-into-tail-call-optimization/2355)

<div class="topic-metadata">

**Author:** [@rust](https://erlangforums.com/u/rust)\
**Replies:** 2\
**Last updated:** [February 13, 2023, 1:23am UTC](https://erlangforums.com/t/where-do-base-cases-fit-into-tail-call-optimization/2355 "2023-02-13T01:23:33Z")

</div>

I’m doing some review. I understand last call optimization, with the last call in the function being a pure recursive function call. Overwrites are done to the arguments in the call stack. But what happens with the base …

---

## [Using try catch in recursion](https://erlangforums.com/t/using-try-catch-in-recursion/1564)

<div class="topic-metadata">

**Author:** [@dominic](https://erlangforums.com/u/dominic)\
**Replies:** 6\
**Last updated:** [June 22, 2022, 9:24am UTC](https://erlangforums.com/t/using-try-catch-in-recursion/1564 "2022-06-22T09:24:20Z")

</div>

just start with code: -module(test). -export(\[run/1, run\_1/1\]). run(N) -\> Self = self(), First = timer:tc(fun run\_1/1, \[N\]), Second = timer:tc(fun run\_1/1, \[N\]), erlang:garbage\_collect(), spawn(fun() -\> Self ! {r…

---

## [How use erlang:setelement/3 in tail recursive function at r23+](https://erlangforums.com/t/how-use-erlang-setelement-3-in-tail-recursive-function-at-r23/1350)

<div class="topic-metadata">

**Author:** [@caochuncheng](https://erlangforums.com/u/caochuncheng)\
**Replies:** 3\
**Last updated:** [April 28, 2022, 1:32am UTC](https://erlangforums.com/t/how-use-erlang-setelement-3-in-tail-recursive-function-at-r23/1350 "2022-04-28T01:32:14Z")

</div>

1.r23 + 2.fun setelement\_test:test\_c/2 how do it? 3.at r22, test\_c/2 and test\_d/2 results are the same. -module(setelement\_test). -export(\[ test\_a/2, test\_b/2, test\_c/2, test\_d/2, test/0 \]). -rec…
