Your accumulator in Enum.reduce can be a more complex structure than a simple value. You could, for example, have a tuple that represents the current count of zero and a list of previous zero counts.
e.g.
{last_count, list_of_counts} = Enum.reduce(string_list, {0, []}, fn x, {current_count, list_of_counts} ->
# "if" version - I find it ugly
count = if x == "0" do current_count + 1 else 0 end
list_of_counts = if x == "0" do list_of_counts else [current_count | list_of_counts] end
{count, list_of_counts}
# or case version (delete one or other)
case x == "0" do
true -> {current_count + 1, list_of_counts}
false -> {0, [current_count | list_of_counts}
end
end
# Need to add last one
list_of_counts = if last_count > 0 do [last_count | list_of_counts] else list_of_counts end
# Then you can get max value from the list, or whatever...


















