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

mapcar and values interaction



    Date: Mon, 4 Mar 91 10:59:36 -0700
    From: drstrip@gnome.cs.sandia.gov (David R. Strip)

    Why does (mapcar #'(lambda (x) (values)) '(1 2 3)) eval to (nil nil
    nil) and not ()?  In general, how do you write a function for use in
    a mapcar so that it may or may not contribute to the resulting list?
    strip

As for the first question, I don't know.  As for the second, the usual
idiom is:

    (mapcan #'(lambda (thing)
		(if (goodp thing)
		    (list thing)
		    '()))
	    some-list)

--David Gadbois