• Re: I still don't get MAPCAN

    From B. Pym@21:1/5 to Ken Tilton on Thu Jun 26 23:09:37 2025
    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)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From B. Pym@21:1/5 to B. Pym on Thu Jun 26 23:32:38 2025
    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))

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)