So my first solution to the Bowling Game Kata was wrong! Well, a good chance to learn something.
Let's try to solve the problem again.
I added the last test to my test suite, which shows the previous bug:
Then I modified the code this way
The code now is not so clear, but it passes tests! What I learned from this exercise? Well, Ron Jeffries said:
I would bet, though, that if we were to take some set of problems that can be solved in a natural fashion both recursively and iteratively, and had a bunch of programmers write both versions, they would have more trouble with the recursive ones, on the average.
My experience seems to confirm his opinion, even if I should consider that it's more than twenty-five years that I solve problems iteratively, while I came to use recursive solutions only a few times. Thus, perhaps my way of seeing problems is not accustomed to think in a recursive fashion, and it requires some more time to get into this way of thinking. So, let's do more Erlang exercises!