From 4c4b1ef874c75e87e0a8435c73a203e19820ac10 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Fri, 8 May 2009 03:45:02 -0400 Subject: quicky --- final_project/work/discovery.scm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'final_project') diff --git a/final_project/work/discovery.scm b/final_project/work/discovery.scm index e3756ab..1da7b21 100644 --- a/final_project/work/discovery.scm +++ b/final_project/work/discovery.scm @@ -9,8 +9,6 @@ ; If it isn't already.... ;(load "ghelper") -(define filter keep-matching-items) - ; takes two lists: the first is a set of predicates and the second a set ; of arguments; if any of the predicates are #t for the args, win, else fail (define (for-any? preds args) @@ -175,6 +173,16 @@ (apply discover:apply-name (cons x args))))) names)))) +(define (discover:satisfy pred? . args) + (let try ((objs (list args))) + (let ((goodies (keep-matching-items (lambda (x) (apply pred? x))))) + (if (not (null? goodies)) + (car goodies) + (lp (fold-right append + '() + (map (lambda (x) + (list (apply discover:apply-all x))) + objs))))))) -- cgit v1.2.3