Google Groups

Re: Loop puzzle


RG Feb 19, 2012 5:25 PM
Posted in group: comp.lang.lisp
In article <201202191...@kylheku.com>,
 Kaz Kylheku <k...@kylheku.com> wrote:

> On 2012-02-19, Raymond Wiker <raw@unknown-00-23-6c-8d-9e-26.lan> wrote:
> > Helmut Eller <eller....@gmail.com> writes:
> >
> >> I tried this code:
> >>
> >> (let ((a '(x y)))
> >>   (loop for a in '((a b) (0 1))
> >>         for b in a
> >>         collect (list a b)))
> >>
> >> and expected that it evaluates to '(((a b) a) ((0 1) b)) but all the
> >> implementations I tried return nil.  
> >>
> >> Can somebody give a pointer to the place in the spec that explains why
> >> this should/could return nil?
> >>
> >> Helmut
> >
> > I think this happens because the two "for" clauses are executed in
> > parallel, and the initial value for "a" seen by the second clause is
> > nil.
>
> But there is no AND between the clauses to make them parallel. This is pretty
> fucked up.

Helmut is wrong.  It is not "because the two "for" clauses are executed
in parallel."  It's because the A in "for b in a" is evaluated after A
is bound but before it is assigned to '(a b).

rg