Received: by 10.68.125.201 with SMTP id ms9mr9084717pbb.3.1336707840469; Thu, 10 May 2012 20:44:00 -0700 (PDT) Path: pr3ni12238pbb.0!nntp.google.com!news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!69.16.185.11.MISMATCH!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!spln!extra.newsguy.com!newsp.newsguy.com!enews4 From: "WJ" Newsgroups: comp.lang.lisp Subject: Re: Loop puzzle Date: 11 May 2012 03:43:41 GMT Organization: NewsGuy - Unlimited Usenet $19.95 Lines: 44 Message-ID: References: NNTP-Posting-Host: pb8bebc2e7d44aacfd2b42b49d0101126ee0ceeab77c73e522c09adc09bdf4f1e.newsdawg.com Mime-Version: 1.0 User-Agent: XanaNews/1.18.1.6 X-Antivirus: avast! (VPS 120510-0, 05/10/2012), Outbound message X-Antivirus-Status: Clean X-Received-Bytes: 1815 Content-Type: text/plain; charset=utf-8 RG wrote: > In article , > Helmut Eller wrote: > > > 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 > > LOOP binds the variables in the FOR clauses in parallel before doing > anything else. It then evaluates all the IN clauses, again in parallel. > At that point, A is NIL. So B is looping over NIL. > > Try something like this: > > (let ((l '((a b) (0 1)))) > (loop for a in l > for b in (car l) > collect (list a b))) > > rg Very bad advice, Ron. You should tell him to use a Lisp instead of CL (COBOL-Like). Racket: (define lst '((a b) (0 1))) (map list lst (car lst)) => '(((a b) a) ((0 1) b)) "WE DON'T NEED NO STINKIN' LOOPS!"