www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 9d7f31df2bfd8c5aa5e2f8fdaf90f177ff0c0eeb
parent ffcb9ef65f91e08d70f54f3c177c3307faf4cfd6
Author: Georges Dupéron <jahvascriptmaniac+github@free.fr>
Date:   Thu,  9 Dec 2010 15:15:15 +0100

Quelques fonctions qui traînent à la fac.

Diffstat:
Abootstrap/18-strings.lisp | 34++++++++++++++++++++++++++++++++++
Abootstrap/22.3.3-format.lisp | 34++++++++++++++++++++++++++++++++++
Abootstrap/6.3-equality-predicates.lisp | 9+++++++++
3 files changed, 77 insertions(+), 0 deletions(-)

diff --git a/bootstrap/18-strings.lisp 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 @@ -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 @@ -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