From 9d7f31df2bfd8c5aa5e2f8fdaf90f177ff0c0eeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Thu, 9 Dec 2010 15:15:15 +0100 Subject: [PATCH] =?UTF-8?q?Quelques=20fonctions=20qui=20tra=C3=AEnent=20?= =?UTF-8?q?=C3=A0=20la=20fac.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bootstrap/18-strings.lisp | 33 ++++++++++++++++++++++++++ bootstrap/22.3.3-format.lisp | 33 ++++++++++++++++++++++++++ bootstrap/6.3-equality-predicates.lisp | 8 +++++++ 3 files changed, 74 insertions(+) create mode 100644 bootstrap/18-strings.lisp create mode 100644 bootstrap/22.3.3-format.lisp create mode 100644 bootstrap/6.3-equality-predicates.lisp diff --git a/bootstrap/18-strings.lisp b/bootstrap/18-strings.lisp new file mode 100644 index 0000000..68af4fb --- /dev/null +++ b/bootstrap/18-strings.lisp @@ -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 + ) \ No newline at end of file diff --git a/bootstrap/22.3.3-format.lisp b/bootstrap/22.3.3-format.lisp new file mode 100644 index 0000000..7bb8389 --- /dev/null +++ b/bootstrap/22.3.3-format.lisp @@ -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)))) \ No newline at end of file diff --git a/bootstrap/6.3-equality-predicates.lisp b/bootstrap/6.3-equality-predicates.lisp new file mode 100644 index 0000000..510a2e5 --- /dev/null +++ b/bootstrap/6.3-equality-predicates.lisp @@ -0,0 +1,8 @@ +;; NEED : stringp +;; NEED : string= + +(defun equal (a b) + (cond ((and (stringp a) (stringp b)) + (string= a b)) + (t + nil))) \ No newline at end of file