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

    From B. Pym@21:1/5 to Wade Humeniuk on Sun Jun 9 08:12:11 2024
    Wade Humeniuk wrote:

    (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 0)))

    (find-indices '(-9 0 3 4 5) odd?)

    '(0 2 4)

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