r5122: *** empty log message ***
[kmrcl.git] / strings.lisp
index efce49807b405fad6545fc6e284f8997e4abc5c0..f71c137c3cf8e2ce0a3780bca14ed9c3af693555 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Programmer:    Kevin M. Rosenberg
 ;;;; Date Started:  Apr 2000
 ;;;;
-;;;; $Id: strings.lisp,v 1.38 2003/06/12 11:10:38 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
 ;;;;
 
 (defun replaced-string-length (str repl-alist)
   (declare (simple-string str)
-    (declare (fixnum orig-len new-len))
+          (fixnum orig-len new-len)
           (optimize (speed 3) (safety 0) (space 0)))
     (do* ((i 0 (1+ i))
          (orig-len (length str))
@@ -351,3 +351,16 @@ Leading zeros are present."
     (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))))