X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fstring.lisp;h=8bead9b5573383120cf35282e09b0d0041052152;hb=6432dcb404266426cd0cbec1a47ec7d4a42b23af;hp=04aa7f1ac2ba048a6ae11f17cb3481fe9607ba8c;hpb=d3b2f238844c7036711885c73c1d39812259b43b;p=jscl.git diff --git a/src/string.lisp b/src/string.lisp index 04aa7f1..8bead9b 100644 --- a/src/string.lisp +++ b/src/string.lisp @@ -19,12 +19,28 @@ (t (char-to-string x)))) (defun string= (s1 s2) - (let ((n (length s1))) + (let* ((s1 (string s1)) + (s2 (string s2)) + (n (length s1))) (when (= (length s2) n) (dotimes (i n t) (unless (char= (char s1 i) (char s2 i)) (return-from string= nil)))))) +(defun string< (s1 s2) + (let ((len-1 (length s1)) + (len-2 (length s2))) + (cond ((= len-2 0) nil) + ((= len-1 0) 0) + (t (dotimes (i len-1 nil) + (when (char< (char s1 i) (char s2 i)) + (return-from string< i)) + (when (and (= i (1- len-1)) (> len-2 len-1)) + (return-from string< (1+ i)))))))) + +(defun stringp (s) + (stringp s)) + (define-setf-expander char (string index) (let ((g!string (gensym)) (g!index (gensym))