X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=strings.lisp;h=f71c137c3cf8e2ce0a3780bca14ed9c3af693555;hb=19187833b40be4cf8bfa5b159da42bae5d365888;hp=efce49807b405fad6545fc6e284f8997e4abc5c0;hpb=72b483ebb9fd0f02acb1b20ef14ee8bac845eca8;p=kmrcl.git diff --git a/strings.lisp b/strings.lisp index efce498..f71c137 100644 --- a/strings.lisp +++ b/strings.lisp @@ -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 ;;;; @@ -169,7 +169,7 @@ (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))))