[alexandria-devel] A clean-room implementation of FILTER-IF from Paul Graham's "On Lisp."

Samium Gromoff _deepfire at feelingofgreen.ru
Mon Apr 23 20:34:26 UTC 2007


Good day,

perhaps the function below meets the Alexandria's standards for
conservativeness/usefulness:

(defun filter-if (fn &rest sequences)
  (labels ((iterate (acc sequences)
	     (if (notany #'null sequences)
		 (iterate (if-let ((testval (apply fn (mapcar #'car sequences))))
				  (cons testval acc)
				  acc)
			  (mapcar #'cdr sequences))
		 acc)))
    (nreverse (iterate nil sequences))))

The idea, but not the implementation, was taken from Paul Graham's book "On Lisp".

Also, i cannot come up with a good docstring, so such one would be appreciated. 

regards, Samium Gromoff



More information about the alexandria-devel mailing list