Hi all,
This is my first post in this forum, and although I did look, please forgive me if it’s a duplicate (or something very simple, I’m quite new at elixir).
Onto the question: I have two streams which I create with File.Stream!. I want to create the Cartesian product of the two streams, but only until I have 10000 items (the full Cartesian product will be over double that). What I would like to really do is do this lazily, but I can’t seem to come up with an easy way to do that.
Currently, what I’m doing is this
for a <- File.stream!("a.txt"),
b <- File.stream!("b.txt"),
do: (
a = String.trim(a)
b = String.trim(b)
{a, b}
)
However, this seems to work eagerly. Of note is that I also need to apply some transformations to the elements (as exemplified by the String.trim).
Any idea as to how I could accomplish this in a lazy way, maybe with better use of Streams, or zipping them, or some such?
Thank you so much!