Subject: Re: lisp newbie here
From: rpw3@rpw3.org (Rob Warnock)
Date: Sat, 10 Apr 2004 05:32:25 -0500
Newsgroups: comp.lang.lisp
Message-ID: <3K2dnaOCNcakUOrd4p2dnA@speakeasy.net>
B.B. <DoNotSpamthegoat4@airmail.net.com.org.gov.tw.ch.ru> wrote:
+---------------
| >(loop for (a b) on '(a b c d e) by 'cddr
| >       collecting (list a b))
| 
| So loop will set (a b) to corresponding elements in '(a b c d e)?
| Is it possible to use more complex lists?
+---------------

Of course it is:

    > (loop for (a b . rest) in '((a b c d e) (f g h) (i j k l) (m n))
        collect (list* a b :n-rest (length rest) :rest rest))

    ((A B :N-REST 3 :REST C D E)
     (F G :N-REST 1 :REST H)
     (I J :N-REST 2 :REST K L)
     (M N :N-REST 0 :REST))
    > (loop for ((a . b) (c . d)) on '((1 . 2) (3 . 4) (5 . 6) (7 . 8))
				  by #'cddr
        collect (list d c b a))

    ((4 3 2 1) (8 7 6 5))
    > 

+---------------
| <fires up clisp>  Nope, guess not.  
+---------------

Show us what you tried. It may have been bad syntax, or a CLISP bug.
But without seeing it, we'll never know.


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607