News for hackers. Stuff that matters.
Re:Using Recursion in Elixir by zzalpha on Sunday September 06, 2015 @10:39AM (#10177763)
Gah, indeed it does! I pored over that code to find it and it was right there...

The post still seems to be more about pattern matching than recursion, but at least recursion is in there somewhere!

Re:Using Recursion in Elixir by segmondy on Sunday September 06, 2015 @10:48AM (#10177789)
Actually, you are correct. There is no recursion. It's perform pattern matching, the functions might have the same name, but it's not recursive, because they are different functions.

Let's pretend we can alias these functions using AS

  def map_single({:ok, res}) AS fun1

  def map_single({:cols_and_first, cols, first_row}) AS fun2

  def map_single({:zipped, list}) AS fun3

  def map_single({:error, err}) AS fun4

Notice how it's called.

fun1 calls fun2

fun2 calls fun3

fun4

to be recursive, a function must call itself or another function that calls it. neither of this is true. What the article is talking about is pattern matching.

Re:Using Recursion in Elixir by zzalpha on Sunday September 06, 2015 @10:55AM (#10177805)
Yup you're right. I thought they were mutually recursive but they're not.