From Newsgroup: comp.lang.lisp
(defun filter (fn list) ; CL has a separate namespace for variables,
; so LIST is a perfectly good variable name.
(loop
:for elt :in list
:when (funcall fn elt)
:collect elt))
Great, Pillsy, you just broke the OP's function. Let us hope it is
indeed "not used?". The Op was accumulating the fn return value, not the original list element. Ergo:
(loop for e in list when (funcall fn e) collect it)
Let's see if we can make it shorter by using a Lispy language
instead of CL.
Gauche Scheme:
(define (fn x) (and (zero? (mod x 3)) (* 10 x)))
(filter-map fn (iota 22 1))
===>
(30 60 90 120 150 180 210)
--- Synchronet 3.21d-Linux NewsLink 1.2