From: Chris Hanson Date: Sun, 15 Apr 2018 08:16:23 +0000 (-0700) Subject: Change find-{,not-}matching-items procedures to call find instead. X-Git-Tag: mit-scheme-pucked-x11-0.3.1~7^2~130 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=3af3e68fefd87f22654a363fef24cf7c1df8dbd0;p=mit-scheme.git Change find-{,not-}matching-items procedures to call find instead. Also eliminate find-unique-{,not-}matching-items procedures which aren't used and aren't documented. These are trivially solved with find-tail and any. --- diff --git a/src/runtime/list.scm b/src/runtime/list.scm index 096e69198..b5c427cad 100644 --- a/src/runtime/list.scm +++ b/src/runtime/list.scm @@ -878,56 +878,14 @@ USA. (error:not-a list? first 'fold-right)) initial))))) -;;;; Generalized list operations +;;;; Generalized list operations -- mostly deprecated in favor of SRFI-1 (define (find-matching-item items predicate) - (let loop ((items* items)) - (if (pair? items*) - (if (predicate (car items*)) - (car items*) - (loop (cdr items*))) - (begin - (if (not (null? items*)) - (error:not-a list? items 'find-matching-item)) - #f)))) + (find predicate items)) (define (find-non-matching-item items predicate) - (let loop ((items* items)) - (if (pair? items*) - (if (predicate (car items*)) - (loop (cdr items*)) - (car items*)) - (begin - (if (not (null? items*)) - (error:not-a list? items 'find-matching-item)) - #f)))) - -(define (find-unique-matching-item items predicate) - (let loop ((items* items)) - (if (pair? items*) - (if (predicate (car items*)) - (if (any predicate (cdr items*)) - #f - (car items*)) - (loop (cdr items*))) - (begin - (if (not (null? items*)) - (error:not-a list? items 'find-unique-matching-item)) - #f)))) + (find (lambda (item) (not (predicate item))) items)) -(define (find-unique-non-matching-item items predicate) - (let loop ((items* items)) - (if (pair? items*) - (if (predicate (car items*)) - (loop (cdr items*)) - (if (every predicate (cdr items*)) - (car items*) - #f)) - (begin - (if (not (null? items*)) - (error:not-a list? items 'find-unique-non-matching-item)) - #f)))) - (define (count-matching-items items predicate) (count predicate items))