Quelques fonctions qui traînent à la fac.
This commit is contained in:
parent
ffcb9ef65f
commit
9d7f31df2b
33
bootstrap/18-strings.lisp
Normal file
33
bootstrap/18-strings.lisp
Normal 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
|
||||
)
|
33
bootstrap/22.3.3-format.lisp
Normal file
33
bootstrap/22.3.3-format.lisp
Normal 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))))
|
8
bootstrap/6.3-equality-predicates.lisp
Normal file
8
bootstrap/6.3-equality-predicates.lisp
Normal file
|
@ -0,0 +1,8 @@
|
|||
;; NEED : stringp
|
||||
;; NEED : string=
|
||||
|
||||
(defun equal (a b)
|
||||
(cond ((and (stringp a) (stringp b))
|
||||
(string= a b))
|
||||
(t
|
||||
nil)))
|
Loading…
Reference in New Issue
Block a user