# [eeps] EEP 19 - clarification

Richard A. O'Keefe <>
Thu Aug 14 06:03:13 CEST 2008

```On 13 Aug 2008, at 11:29 pm, Bjorn Gustavsson wrote:

> How would comprehensions such as
>
> [f(X, Y, Z) || X <- Xs && Y <- Ys, Z <- Zs]
>
> be interpreted? Could you add some examples and
> examples to the EEP?

There *ARE* examples in the EEP.
It even discusses, in the rationale, how the
existing implementation of list comprehension
by means of a generated function can be
revised to handle multigeneration.
Of the five existing examples, one shows
the translation.

I've just sent off a revision of EEP 19.

I finally saw the point of your question.
First, the syntax in EEP 19 is quite clear:

In [f(X, Y, Z) || X <- Xs && Y <- Ys, Z <- Zs]
AAAAAAAAAAAAAAAAAA  BBBBBBB

AAAAAAAAAAAA  is a generator that steps over two
sequences at the same time, and BBBBB is a generator
that steps over one sequence, nested inside AAAAAAAAAA
in the usual fashion.  This would be

g0(Xs, Ys, Zs)
where
g0([X|Xs], [Y|Ys], Zs) ->
g1(X, Y, Zs, g0(Xs, Ys, Zs));
g0([], [], _) ->
[].

g1(X, Y, [Z|Zs], R) ->
[Z|g1(X, Y, Zs, R)];
g1(_, _, R) ->
R.

or something like that.
Second, the ONLY change in EEP 19 is the addition
of P1 <- L1 && ... && Pn <- Ln
as a substitute for
{P1,...,Pn} <- zip(L1,...,Ln)
If the lists are not proper lists of the same length,
multigenerators and zipping don't do exactly the same
thing, but there is still no reason to suppose that
the way nesting works in list comprehensions would be
affected in the least.

```