#| -*-Scheme-*-
-$Id: list.scm,v 14.48 2005/03/29 05:02:11 cph Exp $
+$Id: list.scm,v 14.49 2005/04/28 04:33:36 cph Exp $
Copyright 1986,1987,1988,1989,1990,1991 Massachusetts Institute of Technology
Copyright 1992,1993,1994,1995,1996,2000 Massachusetts Institute of Technology
(error:not-list items 'FIND-MATCHING-ITEM))
#f))))
+(define (count-matching-items items predicate)
+ (do ((items* items (cdr items*))
+ (n 0 (if (predicate (car items*)) (+ n 1) n)))
+ ((not (pair? items*))
+ (if (not (null? items*))
+ (error:not-list items 'COUNT-MATCHING-ITEMS))
+ n)))
+
+(define (count-non-matching-items items predicate)
+ (do ((items* items (cdr items*))
+ (n 0 (if (predicate (car items*)) n (+ n 1))))
+ ((not (pair? items*))
+ (if (not (null? items*))
+ (error:not-list items 'COUNT-NON-MATCHING-ITEMS))
+ n)))
+
(define (keep-matching-items items predicate)
(let ((lose (lambda () (error:not-list items 'KEEP-MATCHING-ITEMS))))
(cond ((pair? items)
#| -*-Scheme-*-
-$Id: runtime.pkg,v 14.540 2005/04/16 04:05:27 cph Exp $
+$Id: runtime.pkg,v 14.541 2005/04/28 04:33:50 cph Exp $
Copyright 1988,1989,1990,1991,1992,1993 Massachusetts Institute of Technology
Copyright 1994,1995,1996,1997,1998,1999 Massachusetts Institute of Technology
circular-list
cons
cons*
+ count-matching-items
+ count-non-matching-items
del-assoc
del-assoc!
del-assq