boot.lisp: implemented char-code
string.lisp: implemented string<
strings.lisp: added tests. The added tests pass.
(defun char= (x y)
(eql x y))
+(defun char< (x y)
+ (< (char-code x) (char-code y)))
+
(defun integerp (x)
(and (numberp x) (= (floor x) x)))
(return-from string= nil))))))
(defun string< (s1 s2)
- -1)
-
+ (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)))))))
+
(define-setf-expander char (string index)
(let ((g!string (gensym))
(g!index (gensym))
(test (not (string= "foo" "foox")))
(test (= (string< "one" "two") 0))
+(test (= (string< "oob" "ooc") 2))
+(test (null (string< "" "")))
+(test (null (string< "a" "")))
+(test (= (string< "" "a") 0))
;;; BUG: The compiler will macroexpand the forms below (char str N)
;;; will expand to internal SBCL code instead of our (setf char). It