Nicely done, a big improvement! Probably the only other change I’d advocate for is to do this:
defp iterate(0, _refs, _table, _index, out) do
out
end
defp iterate(num, refs, table, index, out) do
ref = elem(refs, index)
cond do
num >= ref ->
sym = elem(table, index)
iterate(num - ref, refs, table, index, out <> sym)
true ->
iterate(num, refs, table, index + 1, out)
end
end
It’s conventional that when you’re doing recursion like this to define the “base case” or “termination case” as its own clause up front, and then you have other clauses after. This is entirely a stylistic thing though, so it’s up to you!






















