Trying to understand recursion in Elixir. Sometimes it is simple based on the problem, sometimes it is hard. Any suggestions on how to learn and understand it better?
Corresponding tweet for this thread:
Share link for this tweet.
Check out PragProg ‘Learn Functional Programming with Elixir’ chapter on recursion. That might help.
I agree - I learnt some really cool things in that book!
Here’s my review of it:
The book’s author @ulissesalmeida is here on Devtalk too
There’s an awesome book that’s not about Elixir at all called The Little Schemer which is a fun and illuminating way to learn recursion and functional-ish stuff like linked lists. It’s written as a fun quiz that asks questions before you could know the answer, so that you have to guess about things before being exposed to them. Scheme is a lisp, but it actually shares a great deal with Elixir. I printed out a copy of the book that I found online and went though it like that, without touching a keyboard. You’ll quickly be doing recursion in your head and it will makes total sense and will be fun, and I think several parts of the structure of a language like Elixir will open up to you. At least it seemed to help me in that way.
Thank you for this suggestion.
Think I’ve heard that book mentioned before… so might just have to get it one day!
Chapter 7 Lists and Recursion of Programming Elixir 1.6 was also good
It is necessary to do exercises on this topic and constantly review your understanding. This principle is called from particular to general.
Become Sherlock Holmes, as Joe Armstrong recommended in his book [Programming Erlang (2nd edition)].