• Re: I still don't get MAPCAN

    From B. Pym@Nobody447095@here-nor-there.org to comp.lang.lisp on Thu Jun 26 23:09:37 2025
    From Newsgroup: comp.lang.lisp

    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)
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From B. Pym@Nobody447095@here-nor-there.org to comp.lang.lisp on Thu Jun 26 23:32:38 2025
    From Newsgroup: comp.lang.lisp

    B. Pym wrote:

    (mapcan (lambda (e) (if (interestingp e) (list e) nil)) huge-list))

    Shorter:

    (mapcan (lambda (e) (and (interestingp e) (list e))) huge-list))


    --- Synchronet 3.21d-Linux NewsLink 1.2