From: Kevin M. Rosenberg Date: Sat, 14 Jun 2003 23:24:31 +0000 (+0000) Subject: r5122: *** empty log message *** X-Git-Tag: v1.96~186 X-Git-Url: http://git.kpe.io/?p=kmrcl.git;a=commitdiff_plain;h=19187833b40be4cf8bfa5b159da42bae5d365888 r5122: *** empty log message *** --- diff --git a/package.lisp b/package.lisp index 684de10..73926dd 100644 --- a/package.lisp +++ b/package.lisp @@ -7,7 +7,7 @@ ;;;; 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 ;;;; @@ -49,6 +49,7 @@ #:string-to-list-skip-delimiter #:string-starts-with #:count-string-char + #:count-string-char-if #:flatten diff --git a/strings.lisp b/strings.lisp index 6c3eb44..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.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 ;;;; @@ -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))))