• Re: chain of transformations

    From B. Pym@21:1/5 to Kaz Kylheku on Tue Sep 17 11:07:52 2024
    XPost: comp.lang.scheme

    Kaz Kylheku wrote:

    (defun tree-find (needle haystack &key (test #'eql))
    (dolist (item haystack)
    (if (funcall test needle item)
    (return item)
    (when (consp item)
    (let ((find (tree-find needle item :test test)))
    (when find
    (return find)))))))

    Gauche Scheme:

    (define (tree-find needle haystack :optional (test equal?))
    (any
    (lambda (item)
    (if (test needle item)
    item
    (and (pair? item) (tree-find needle item test))))
    haystack))

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