• Re: YANQ - When to map, when to iterate, when to recurse?

    From B. Pym@Nobody447095@here-nor-there.org to comp.lang.lisp on Tue Jun 17 15:17:48 2025
    From Newsgroup: comp.lang.lisp

    (defun find-indices (list test)
    (loop for element in list
    for index from 1
    when (funcall test element) collect index))

    Gauche Scheme

    (define (find-indices xs test)
    (filter-map
    (lambda (x i) (and (test x) i))
    xs
    (lrange 1)))

    (find-indices '(3 4 6 7) odd?)
    ===>
    (1 4)
    --- Synchronet 3.21d-Linux NewsLink 1.2