If Enum.zip/2 solves your problem then consider using [head | tail] notation for lists like:
defmodule Example do
# when done or empty input do nothing returning empty list
def sample([], []), do: []
# optional code in case you have more items in one of the list
# def sample([], _non_empty_list), do: []
# def sample(_non_empty_list, []), do: []
# loop using [head | tail] notation together with your code
def sample([head1 | tail1], [head2 | tail2]) do
IO.puts(head1)
IO.puts(head2)
sample(tail1, tail2)
end
end
x = ["0001", "0002"]
y = [1, 1]
Example.sample(x, y)
This gave you exactly same result, but … Enum.zip is one loop and for is another one - this means that if you write a bit more code then using just one loop your code would be faster.