[erlang-questions] Nested for-loops, there has to be a better way to do this
Wed Jul 29 05:32:50 CEST 2009
On Jul 29, 2009, at 2:55 PM, Yves S. Garret wrote:
> I was playing around with the idea of implementing a nested for-
> loop... a
> list [5, 5, 10] (for example) and go through it all like 3 dimensional
I don't understand what it is you want to do.
Will something like
D1 = lists:seq(1, 5),
D2 = lists:seq(1, 5),
D3 = lists:seq(1, 10),
% do this for effect, not result
[ effect(I1, I2, I3) || I1 <- D1, I2 <- D2, I3 <- D3 ]
do what you want?
I've been playing with a syntax that allows, amongst other
( effect(I1, I2, I3) || I1 <- D1, I2 <- D2, I3 <- D3 )
However, it's not really needed; all that's needed is for the
Erlang compiler to notice that the result of a list comprehension
is not being used, and just not bother constructing the result.
More information about the erlang-questions