I want to use a for comprehension in Elixir for looping n times and accumulating some result for each time.
An example:
for i <- 0..n, y <- 1..3, do: y
This will loop 1 time when n is 0. I tried several other ways to get an empty list when n is 0, but can't see how to do it without using verbose constructs, which defeats the whole purpose of the comprehension. I realize this is because the range is inclusive. But I guess there must be a way to get exclusive ranges, or some other way to achieve empty for comprehensions while still being as readable. I just couldn't find it.
I want to know whether using a comprehension for this is reasonable in Elixir. If I have to make a long expression within the comprehension, or make my own helper functions, I'll just stick to other methods.