diff options
-rw-r--r-- | final_project/work/discovery.scm | 12 |
1 files changed, 10 insertions, 2 deletions
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))))))) |