[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Re: chain of transformations

William James

7/5/2015 7:07:00 AM

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 :key (test eqv?))
(any
(lambda (item)
(if (test needle item)
item
(and (pair? item) (tree-find needle item :test test))))
haystack))

--
They agitate for "equality" to facilitate the imposition of their own
immeasurable superiority, and for "economic justice" to mask their conviction
that all the property in the world justly belongs to them.... They denounce
"racism" and agitate for "human rights," with the secret reservation that they
are the only race that is human. --- R. P. Oliver