Quelques fonctions qui traînent à la fac.

This commit is contained in:
Georges Dupéron 2010-12-09 15:15:15 +01:00
parent ffcb9ef65f
commit 9d7f31df2b
3 changed files with 74 additions and 0 deletions

33
bootstrap/18-strings.lisp Normal file
View File

@ -0,0 +1,33 @@
;; PRIMITIVE : stringp
;; NEED : aref
;; NEED : cond
;; NEED : characterp
;; NEED : symbolp
;; 18.1-string-access
;; 18.2-string-comparison
;; 18.3-string-construction-and-manipulation
(defun char (string index)
(aref string index))
(defun schar (string index)
(aref string index))
(defun string (stuff )
"STUFF must be a string, symbol or character."
(cond ((stringp stuff) stuff)
((characterp stuff)
;; TODO
)
((symbolp stuff)
;; TODO
)))
(defun string= (string1 string2 &key (:start1 0) :end1 (:start2 0) :end2)
;; TODO
)
(defun make-string (size &key :initial-element)
;; TODO
)

View File

@ -0,0 +1,33 @@
(defun my-format (destination control-string &rest arguments)
(let ((current nil)
(pos -1)
(length 0)
(stack '()))
(labels ((get-char () (setq current (char control-string (setq pos (+ pos 1))))))
(tagbody
(setq length (length control-string))
main
(get-char)
(when (char= current #\~)
(go special))
(push 'main-after-write stack)
(go write)
main-after-write
(setq pos (+ pos 1))
(when (>= pos length)
(go end-of-string))
(go main)
special
(error "niy")
write
(write-char current destination)
(go return)
return
(case stack
(main-after-write (go main-after-write)))
end-of-string))))

View File

@ -0,0 +1,8 @@
;; NEED : stringp
;; NEED : string=
(defun equal (a b)
(cond ((and (stringp a) (stringp b))
(string= a b))
(t
nil)))