Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Loop puzzle

Received: by 10.68.74.201 with SMTP id w9mr11094486pbv.0.1330340193633;
        Mon, 27 Feb 2012 02:56:33 -0800 (PST)
MIME-Version: 1.0
Path: h9ni14857pbe.0!nntp.google.com!news1.google.com!news.glorb.com!feeder.erje.net!news.mixmin.net!aioe.org!.POSTED!not-for-mail
From: Kaz Kylheku <k...@kylheku.com>
Newsgroups: comp.lang.lisp
Subject: Re: Loop puzzle
Date: Mon, 27 Feb 2012 10:56:30 +0000 (UTC)
Organization: Aioe.org NNTP Server
Lines: 26
Message-ID: <20120227024621.67@kylheku.com>
References: <m2sji6zqn1.fsf@gmail.com> <jie5pu0ll5@enews2.newsguy.com>
NNTP-Posting-Host: BM142O4vcNQaI+/lK/DZ1g.user.speranza.aioe.org
X-Complaints-To: abuse@aioe.org
User-Agent: slrn/pre1.0.0-18 (Linux)
X-Notice: Filtered by postfilter v. 0.8.2

On 2012-02-26, WJ <w_a_x_...@yahoo.com> wrote:
> 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.  
>
> MatzLisp:
>
> it = [[:a, :b], [0, 1]]
> it.zip( it.first )
>     ==>[[[:a, :b], :a], [[0, 1], :b]]

TXR Lisp's has the sequential binding Helmut Eller was looking for in loop:

 (collect-each* ((i '((a b) (0 1)))
                 (j (first i)))
   '(,i ,j))

This collect-each* can easily be ported to Common Lisp as a macro.