Subject: Re: Multiple arguments to mapcar?
From: rpw3@rpw3.org (Rob Warnock)
Date: Tue, 06 Nov 2007 22:58:55 -0600
Newsgroups: comp.lang.lisp
Message-ID: <BrednTfo-4qS26zanZ2dnUVZ_qOknZ2d@speakeasy.net>
szergling  <senatorZergling@gmail.com> wrote:
+---------------
| Pascal Costanza <p...@p-cos.net> wrote:
| > (loop for n in '(1 2)
| >        for x = (+ n 1) then (+ n 2)
| >        collect x)
| 
| And incidentally, LOOP's more recent cousin,
| iterate, has this construct built in:
...
| CL-USER> (iter (for i below 10)
|                (if (first-time-p)
|                    (collect (+ i 1))
|                    (collect (+ i 2))))
| (1 3 4 5 6 7 8 9 10 11)
| 
| Just to provided an alternative, balancing point
| of view to LOOP :)
+---------------

But you didn't really, since you changed the style,
and of course LOOP can do *that* style, too:  ;-}  ;-}

    > (loop for i below 10
	    and first-time = t then nil
	if first-time
	  collect (+ i 1)
	else
	  collect (+ i 2))

    (1 3 4 5 6 7 8 9 10 11)
    > 

or, equivalently:

    > (loop for i below 10
	    and first-time = t then nil
	collect (if first-time
                  (+ i 1)
                  (+ i 2)))

    (1 3 4 5 6 7 8 9 10 11)
    > 

This is not to say that ITERATE doesn't have things which are
better than LOOP, only that (FIRST-TIME-P) isn't one of them.


-Rob

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