r5122: *** empty log message ***
authorKevin M. Rosenberg <kevin@rosenberg.net>
Sat, 14 Jun 2003 23:24:31 +0000 (23:24 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Sat, 14 Jun 2003 23:24:31 +0000 (23:24 +0000)
package.lisp
strings.lisp

index 684de103e5e440ca6eb612b3e76bc35dd82cc271..73926dd70e49857a655bb1cb25941e9064496ae3 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Programmer:    Kevin M. Rosenberg
 ;;;; Date Started:  Apr 2000
 ;;;;
 ;;;; 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
 ;;;;
 ;;;;
 ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
@@ -49,6 +49,7 @@
    #:string-to-list-skip-delimiter
    #:string-starts-with
    #:count-string-char
    #:string-to-list-skip-delimiter
    #:string-starts-with
    #:count-string-char
+   #:count-string-char-if
    
    #:flatten
    
    
    #:flatten
    
index 6c3eb448881c0d2c235cd5df3b0adffaeef33780..f71c137c3cf8e2ce0a3780bca14ed9c3af693555 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Programmer:    Kevin M. Rosenberg
 ;;;; Date Started:  Apr 2000
 ;;;;
 ;;;; 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
 ;;;;
 ;;;;
 ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
@@ -351,3 +351,16 @@ Leading zeros are present."
     (declare (fixnum i len count))
     (when (char= (schar s i) c)
       (incf count))))
     (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))))