[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Extension to MAP



	
	    Date: 20 Mar 1987 16:24-EST
	    From: VERACSD@A.ISI.EDU
	
		 I'd really like to see MAP take a sequence as its first
	    argument, and have the results be put into that sequence.

Seems to me the answer is smarter compilers.  Then the code could read:

(replace seq1 (map (type-of seq1) fnc seq2))

and compile into the same thing as the proposed (map seq1 fnc seq2).
Similarly, one could have

(mapc f (mapcar g l1))  ==> (mapc #'(lambda (x) (funcall f (funcall g x))) l1)

where the "==>" stands for "optimizes into".  People expect such optimizations
from APL or SetL compilers; why not from CommonLisp? I admit there are
complications involving side effects and error signaling.  For example,

(first (mapcar #'not l))     ==>   (not (first l))

but

(first (mapcar #'print l))   ==>   (unless (null l)
				      (print (first l))
				      (mapc #'print (rest l)))

and

(dotimes (i 10000) (cons nil nil))  ==> nil

would be valid most of the time, but not when you're trying to test
the garbage collector.