Subject: Re: Multiple evaluation
From: rpw3@rpw3.org (Rob Warnock)
Date: Sat, 26 Jul 2008 09:16:31 -0500
Newsgroups: comp.lang.lisp
Message-ID: <r8-dnZYl8u8irBbVnZ2dnUVZ_sjinZ2d@speakeasy.net>
Pascal J. Bourguignon <pjb@informatimago.com> wrote:
+---------------
| rpw3@rpw3.org (Rob Warnock) writes:
| > Ari Krupnik  <ari@lib.aero> wrote:
| > +---------------
| > | pjb@informatimago.com (Pascal J. Bourguignon) writes:
| > | > (map-into (make-list 5) (lambda () (random 1.0))) ; consing O(N).
| > | 
| > | But it still iterates twice, just doesn't create extra garbage, right?
| > +---------------
| >
| > No, it iterates *once* only!
| > Hint: Look at the (MAP-INTO A #'GENSYM) example in the CLHS.
| 
| MAP-INTO loops once, and MAKE-LIST too.
+---------------

*Yikes!* Sorry, you're right. Somehow I was reading the latter
as MAKE-ARRAY, which doesn't necessarily need to "loop" per se.

[Though since any sane CL:MAKE-ARRAY will initialize the block
it allocates with *something*, I suppose one could claim that
MAKE-ARRAY has to implicitly "loop", too. Unless you have a
compiler macro for MAP-INTO that notices the whole sequence
is being written and and transforms the MAKE-ARRAY into a
SYS::MAKE-ARRAY/NO-INIT or something...]

+---------------
| But I already gave the solution that LOOPs only once.
+---------------

Yes, well, I like LOOP, too.  ;-}  ;-}


-Rob

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