5 ms·
The author seems confused, as the code here doesn't actually involve recursion. I wouldn't normally nitpick too hard, here, but he spends a lot of time talking
by zzalpha 11y ago
The author seems confused, as the code here doesn't actually involve recursion. I wouldn't normally nitpick too hard, here, but he spends a lot of time talking about how Elixer made it possible for him to understand and use recursion... The trouble is neither of these things seemed to have happened...
- davidstump 11y agoI believe he is referencing the fact that the map_single function calls itself.
- zzalpha 11y agoGah, 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!
- segmondy 11y agoActually, 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.
- zzalpha 11y agoYup you're right. I thought they were mutually recursive but they're not.