[erlang-questions] Nested for-loops, there has to be a better way to do this

Fred Hebert (MononcQc) mononcqc@REDACTED
Wed Jul 29 23:08:37 CEST 2009


I find nested lists comprehension to be the easiest to deal with when
representing nested loops:

[[ Fn(I,J) || J <- GenExp2 ] || I <- GenEXp1 ].

or indented in a different way:

 [[[ Fn(I, J, K) || K <- GenExp3 ]
                 || J <- GenExp2 ]
                 || I <- GenExp1 ].

This gives a nested list. If that's not what you want, you could use
lists:flatten/1 to change that, but overall I find this form to be the
cleanest (visually speaking).


More information about the erlang-questions mailing list