# How To Do A For Loop In Elixir (using only recursion)

**URL:** <https://forum.elixirforum.com/t/how-to-do-a-for-loop-in-elixir-using-only-recursion/595>\
**Category:** Discussions\
**Tags:** recursion, code-snippets\
**Created:** [May 13, 2016, 1:18pm UTC](https://forum.elixirforum.com/t/how-to-do-a-for-loop-in-elixir-using-only-recursion/595 "2016-05-13T13:18:56Z")\
**Posts on this page:** 1\
**Showing post:** 26

<div class="post-metadata">

**Author:** ![Qqwy](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/qqwy/32/1349_2.png) [@Qqwy](https://forum.elixirforum.com/u/Qqwy)\
**Post date:** [September 22, 2016, 7:28pm UTC](https://forum.elixirforum.com/t/how-to-do-a-for-loop-in-elixir-using-only-recursion/595/26 "2016-09-22T19:28:08Z")

</div>

I wonder, is using the [Y-combinator](http://rosettacode.org/wiki/Y_combinator) cheating? I would actually suggest that it might be the ‘nicest’ solution, because it sort of does ‘meta’-recursion; calling a function with itself as argument, so the function can recurse if and when it wants to, without using explicit recursion. (For instance, this will even work when using anonymous functions).

---

_[View the full topic](https://forum.elixirforum.com/t/how-to-do-a-for-loop-in-elixir-using-only-recursion/595)._
