Oh, sure. You can use Enum.zip
which returns list of tuples:
posts_entries = ["a", "b", "c", "d", "e", "f", "g"]
colors = Stream.cycle(["purple", "red", "orange"])
for {el, color} <- Enum.zip(posts_entries, colors) do
IO.puts("#{el} (#{color})")
end
I’m not sure what you mean exactly, but would something like this work?
def colored_posts(posts, colors) do
Enum.zip(posts, Stream.cycle(colors))
end