;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Exercice 1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 1- ;; CL-USER> (require 'asdf-install) ;; ("ASDF-INSTALL") ;; CL-USER> (asdf-install:install 'mcclim) ;; 2- ;; première solution: on demande le chargement dans le fichier ;; d'initialisation .sbclrc ;; (require 'mcclim) ;; deuxième solution: on crée un fichier core après avoir chargé ;; mcclim dans SBCL ;; par la suite, on lance SBCL avec ce nouveau core ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Exercice 2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; CL-USER> (defparameter *flot* (open "data.txt")) ;; *FLOT* ;; CL-USER> (read-line *flot*) ;; "ligne un" ;; NIL ;; CL-USER> (read *flot*) ;; 123 ;; CL-USER> (read *flot*) ;; (+ 1 2 3) ;; CL-USER> (read *flot*) ;; "une chaine" ;; CL-USER> (read *flot* nil 'fin) ;; 10.2 ;; CL-USER> (read *flot* nil 'fin) ;; FIN ;; CL-USER> (read *flot* nil 'fin) ;; FIN ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Exercice 3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar *my-readtable* (copy-readtable)) (set-macro-character #\{ (lambda (stream char) (declare (ignore char)) (let ((letter (read stream)) (right-bracket (read stream))) (unless (eq right-bracket #\}) (error "} excepted")) (make-letter letter))) nil *my-readtable*) (set-macro-character #\} (lambda (stream char) (declare (ignore stream)) char) nil *my-readtable*) (set-syntax-from-char #\] #\) *my-readtable*) (set-macro-character #\[ (lambda (stream char) (declare (ignore char)) (let ((args (read-delimited-list #\] stream t))) (make-instance 'word :letters args))) nil *my-readtable*) ;; CL-USER> (defparameter *save-table* *readtable*) ;; *SAVE-TABLE* ;; CL-USER> (setf *readtable* *my-readtable*) ;; # ;; CL-USER> {a} ;; {A} ;; CL-USER> [{a}{b}] ;; [{A}{B}] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Exercice 4 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 1- (defclass compte () ((solde :initform 0.0 :initarg :solde :accessor solde))) ;; 2- (defmethod print-object :after ((compte compte) stream) (format stream " solde: ~,2f" (solde compte))) ;; 3- (defmethod transfert (montant (compte1 compte) (compte2 compte)) (decf (solde compte1) montant) (incf (solde compte2) montant)) ;; 4- (defclass compte-plafonne (compte plafonne-mixin) ()) ;; 5- (defmethod print-object :after ((compte plafonne-mixin) stream) (format stream " plafond: ~,2f" (plafond compte))) ;; 6- (defmethod transfert :before (montant (compte1 compte) (compte2 plafonne-mixin)) (assert (< (+ (solde compte2) montant) (plafond compte2))))