Sujet : Re: I still don't get MAPCAN
De : Nobody447095 (at) *nospam* here-nor-there.org (B. Pym)
Groupes : comp.lang.lispDate : 27. Jun 2025, 00:09:37
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <103kjvg$3nlhj$1@dont-email.me>
User-Agent : XanaNews/1.18.1.6
Ken Tilton wrote:
MAPCAN is terribly useful when you want to collect only some things:
>
(defun find-interesting (huge-list)
(mapcan #'(lambda (e) (if (interestingp e) (list e) nil)) huge-list))
Why wasn't it simply:
(mapcan (lambda (e) (if (interestingp e) (list e) nil)) huge-list))
Users of CL (COBOL-Like) are extremely eager to make their
code as ugly as possible.
ick.
(loop for e in huge-list when (interestingp e) collect e)
Ick.
Scheme:
(filter interesting? huge-list)