• Collect when

    From B. Pym@Nobody447095@here-nor-there.org to comp.lang.lisp on Fri Jun 20 21:58:52 2025
    From Newsgroup: comp.lang.lisp

    (loop for x in y
    when (f x)
    collect (g x))

    Gauche Scheme:

    (define f positive?)
    (define (g x) (and (odd? x) (* x x)))
    (define y (iota 22 -8))

    (append-map
    (lambda(x) (if (f x) (list (g x)) '()))
    y)

    ===>
    (1 #f 9 #f 25 #f 49 #f 81 #f 121 #f 169)
    --- Synchronet 3.21d-Linux NewsLink 1.2