odds_and_evens2(L) ->
odds_and_evens_acc(L, [], []).
odds_and_evens_acc([H|T], Odds, Evens) ->
case (H rem 2) of
1 -> odds_and_evens_acc(T, [H|Odds], Evens);
0 -> odd_and_evens_acc(T, Odds, [H|Evens])
end;
odds_and_evens_acc([], Odds, Evens) ->
{Odds, Evens}.
================================================
This is from Kindle location 2235. Armstrong’s book. I’m reading 2nd Edition and this wasn’t, to my memory, in the first edition. I’m re-reading but there’s more in 2nd Edition. I thought it was important to really understand Erlang before jumping into Elixir.
Question is about the second line, where you see a period. What does that line DO then, with L, [], []?
I get the rest, just don’t see how this works with that second line. I didn’t see this question posted, obviously, and yes, I’m a noob to this. But with Elixir, at least it took like one minute to solve things like FizzBuzz and I feel retarded with anything BUT FP languages (imperative-style loops are my bane). I’d really appreciate explaining how this works with the second line in there.