r4659: *** empty log message ***
authorKevin M. Rosenberg <kevin@rosenberg.net>
Mon, 28 Apr 2003 16:07:43 +0000 (16:07 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Mon, 28 Apr 2003 16:07:43 +0000 (16:07 +0000)
math.lisp
strings.lisp

index 9772b7a52df849bfee3b40b4eebb4f5a6162c541..9a6862bad3f6168196b2838b69ef8eed1505f092 100644 (file)
--- a/math.lisp
+++ b/math.lisp
@@ -7,7 +7,7 @@
 ;;;; Programmer:    Kevin M. Rosenberg
 ;;;; Date Started:  Nov 2002
 ;;;;
-;;;; $Id: math.lisp,v 1.1 2002/11/08 06:43:34 kevin Exp $
+;;;; $Id: math.lisp,v 1.2 2003/04/28 16:07:42 kevin Exp $
 ;;;;
 ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
@@ -18,7 +18,6 @@
 
 
 (in-package :kmrcl)
-(declaim (optimize (speed 3) (safety 1) (compilation-speed 0) (debug 3)))
 
 (defun deriv (f dx)
   #'(lambda (x)
index 35a177e9715371cc38eea292eddb09c05d380518..9c6d4d1ebd61746262f6b7421feff40e58ef69f3 100644 (file)
@@ -7,7 +7,7 @@
 ;;;; Programmer:    Kevin M. Rosenberg
 ;;;; Date Started:  Apr 2000
 ;;;;
-;;;; $Id: strings.lisp,v 1.7 2003/02/07 14:21:55 kevin Exp $
+;;;; $Id: strings.lisp,v 1.8 2003/04/28 16:07:43 kevin Exp $
 ;;;;
 ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg
 ;;;;
   (when (stringp str)
     (null (find-if #'not-whitespace? str))))
 
-#+ignore
 (defun string-replace-chars-strings (str repl-alist)
   "Replace all instances of a chars with a string. repl-alist is an assoc
 list of characters and replacement strings."
+  (declare (string str))
   (let* ((orig-len (length str))
-        (new-len orign-len))
+        (new-len orig-len))
     (declare (fixnum orig-len new-len))
-    (dotimes (i orign-len)
+    (dotimes (i orig-len)
       (declare (fixnum i))
-      (let ((c (schar i str)))
-       )))
-  str)
+      (let* ((c (char str i))
+            (match (assoc c repl-alist :test #'char=)))
+       (declare (character c))
+       (when match
+         (incf new-len (length (cdr match))))))
+    (let ((new-string (make-string new-len))
+         (i 0))
+      (declare (string new-string)
+              (fixnum i))
+      (dotimes (i orig-len)
+       (declare (fixnum i))
+       (let* ((c (char str i))
+              (match (assoc c repl-alist :test #'char=)))
+         (declare (character c))
+         (if match
+             (let ((subst (cdr match)))
+               (dotimes (j (length subst))
+                 (setf (char new-string i) (char subst j))
+                 (incf i)))
+           (progn
+             (setf (char new-string i) c)))))
+      new-string)))
 
 (defun escape-xml-string (string)
   "Escape invalid XML characters"