Nested for-loops, there has to be a better way to do this
Yves S. Garret
Fri Jul 31 04:02:05 CEST 2009
Yes, as Joe Armstrong pointed out, I did not do a good job of
explaining what I wanted *exactly*. But thanks for that piece of
code, it looks like something I could use at one point.
On Jul 28, 11:32 pm, "Richard O'Keefe" <> wrote:
> 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
> > array.
> 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
> special cases,
> ( 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.
> erlang-questions mailing list. Seehttp://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
More information about the erlang-questions