;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Apr 2000
;;;;
-;;;; $Id: package.lisp,v 1.37 2003/06/12 11:10:38 kevin Exp $
+;;;; $Id: package.lisp,v 1.38 2003/06/14 23:24:31 kevin Exp $
;;;;
;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
#:string-to-list-skip-delimiter
#:string-starts-with
#:count-string-char
+ #:count-string-char-if
#:flatten
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Apr 2000
;;;;
-;;;; $Id: strings.lisp,v 1.39 2003/06/12 17:58:45 kevin Exp $
+;;;; $Id: strings.lisp,v 1.40 2003/06/14 23:24:31 kevin Exp $
;;;;
;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
(declare (fixnum i len count))
(when (char= (schar s i) c)
(incf count))))
+
+(defun count-string-char-if (pred s)
+ "Return a count of the number of times a predicate is true
+for characters in a string"
+ (declare (simple-string s)
+ (optimize (speed 3) (safety 0) (space 0)))
+ (do ((len (length s))
+ (i 0 (1+ i))
+ (count 0))
+ ((= i len) count)
+ (declare (fixnum i len count))
+ (when (funcall pred (schar s i))
+ (incf count))))