id
int64
0
45.1k
file_name
stringlengths
4
68
file_path
stringlengths
14
193
content
stringlengths
32
9.62M
size
int64
32
9.62M
language
stringclasses
1 value
extension
stringclasses
6 values
total_lines
int64
1
136k
avg_line_length
float64
3
903k
max_line_length
int64
3
4.51M
alphanum_fraction
float64
0
1
repo_name
stringclasses
779 values
repo_stars
int64
0
882
repo_forks
int64
0
108
repo_open_issues
int64
0
90
repo_license
stringclasses
8 values
repo_extraction_date
stringclasses
146 values
sha
stringlengths
64
64
__index_level_0__
int64
0
45.1k
exdup_ids_cmlisp_stkv2
listlengths
1
47
5,026
graf.lisp
informatimago_lisp/common-lisp/obsolete-or-incomplete/graf.lisp
;;;; -*- coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: graf.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;NOWEB: t ;;;;DESCRIPTION ;;;; ;;;; This file defines Graf classes. ;;;; ;;;; This is an old implementation adapted from a scheme version. ;;;; The GRAF class merely encapsulates list-based data structures ;;;; and functions manipulating graphs. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2004-08-06 <PJB> Added defgeneric. ;;;; 2003-06-17 <PJB> Updated to pure Common-Lisp. ;;;; 2003-01-09 <PJB> Added DEFPACKAGE. Made it DEFINE-PACKAGE. ;;;; 1996-10-25 <PJB> Updated to CLISP. ;;;; 1994-04-09 <PJB> Creation. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 1996 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (in-package "COMMON-LISP-USER") (defpackage "COM.INFORMATIMAGO.COMMON-LISP.OBSOLETE-OR-INCOMPLEPTE.GRAF" (:use "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.LIST" "COMMON-LISP") (:export "MAKE-TREE" "MAKE-UNION" "MAKE-INTERSECTION" "TERMINAL-TOKENS" "INITIAL-TOKENS" "TERMINAL-NODES" "INITIAL-NODES" "FOLLOW" "PRECEDE" "DISPLAY-GAMMAS-INV" "DISPLAY-GAMMAS" "GAMMAS-INV" "GAMMAS" "GAMMA-INV-OF-NODE" "GAMMA-OF-NODE" "MINIMIZE-CROSSES" "IS-SUBSET-OF?" "IS-PARTIAL-OF?" "EQUAL?" "MAKE-REFLEXIVE" "IS-REFLEXIVE?" "MAKE-SYMETRIC" "SYMETRIC" "IS-SYMETRIC?" "REVERSE-EDGES" "REMOVE-EDGES" "REMOVE-EDGE" "CONTAINS-EDGE?" "ADD-EDGES" "ADD-EDGE" "EDGES" "REMOVE-NODES" "REMOVE-NODE" "CONTAINS-NODE?" "ADD-NODES" "ADD-NODE" "NODES" "EMPTY" "GRAF" "GRAF-SUMMARY" "GRAF-MINIMIZE-CROSSES-VERBOSELY" "GRAF-ONLIF-BUILD-EDGES" "GRAF-ONLIF-BUILD-EDGES-CURRENT" "GRAF-ONLIFBE-REPLACE" "FIND-ONLIFBE" "GRAF-ONL-ADD-INDICES-IJ" "GRAF-BUILD-ORDERED-NODE-LIST" "GRAF-BUILD-ORDERED-NODE-LIST" "GRAF-BUILD-ORDERED-NODE-LIST-STEP" "GRAF-MAKE-TREE" "GRAF-MAKE-REFLEXIVE" "GRAF-REFLEXIVE?" "AND-L" "GRAF-TERMINAL-TOKENS" "GRAF-INITIAL-TOKENS" "GRAF-TERMINAL-NODES" "GRAF-INITIAL-NODES" "SET-UNION-L" "GRAF-PRECEDE-L" "GRAF-FOLLOW-L" "GRAF-PRECEDE" "GRAF-FOLLOW" "GRAF-REPLACE-NODE" "GRAF-MINIMIZE-CROSSES" "LPRINT" "GRAF-MAKE-SYMETRIC" "GRAF-SYMETRIC?" "GRAF-SYMETRIC" "GRAF-REVERSE-EDGES" "EDGES-REVERSE" "GRAF-DISPLAY-GAMMAS-INV" "GRAF-DISPLAY-GAMMAS" "GRAF-GAMMAS-INV" "GRAF-GAMMAS" "GRAF-CONNECTED-CLASSES" "GRAF-GAMMA-INV-CLOSURE" "GRAF-GAMMA-CLOSURE" "GRAF-GAMMA-INV" "GRAF-GAMMA" "EDGES-PREV-NODES" "EDGES-NEXT-NODES" "GRAF-INTERSECTION" "GRAF-UNION" "GRAF-SUBSET?" "GRAF-PARTIAL?" "GRAF-EQUAL?" "EDGES-REMOVE-NODES" "EDGES-REMOVE-NODE" "GRAF-REMOVE-EDGE" "GRAF-REMOVE-EDGES" "GRAF-ADD-EDGES" "GRAF-ADD-EDGE" "GRAF-CONTAINS-EDGE?" "GRAF-EDGES" "GRAF-REMOVE-NODE" "GRAF-ADD-NODES" "GRAF-ADD-NODE" "GRAF-CONTAINS-NODE?" "GRAF-NODES" "GRAF-EMPTY" "SET-UNIQUE-L" "SET-MEMBER" "SET-INTERSECTION" "SET-DIFF" "SET-UNION" "SET-REMOVE" "SET-EQUAL?" "SET-SUBSET?" "SET-CONTAINS?") (:documentation "This file defines the GRAF class. These are oriented graphs This is an old implementation adapted from a scheme version. The GRAF class merely encapsulates list-based data structures and functions manipulating graphs. Copyright Pascal J. Bourguignon 1996 - 2003 This package is provided under the GNU General Public License. See the source file for details.")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.OBSOLETE-OR-INCOMPLEPTE.GRAF") ;; egrep -e '^[(]DEFUN|^[(]DEFMETHOD|^[(]DEFCLASS' pjb-graph.lisp | sed -e 's/\((DEFUN\|(DEFMETHOD\|(DEFCLASS\)/;;/' | sort ;; ADD-EDGE ((SELF GRAF) E) ;; ADD-EDGES ((SELF GRAF) LE) ;; ADD-NODE ((SELF GRAF) N) ;; ADD-NODES ((SELF GRAF) LN) ;; AND-L (L) ;; CONTAINS-EDGE? ((SELF GRAF) E) ;; CONTAINS-NODE? ((SELF GRAF) N) ;; DISPLAY-GAMMAS ((SELF GRAF)) ;; DISPLAY-GAMMAS-INV ((SELF GRAF)) ;; EDGES ((SELF GRAF)) ;; EDGES-NEXT-NODES (LE N) ;; EDGES-PREV-NODES (LE N) ;; EDGES-REMOVE-NODE (LE N) ;; EDGES-REMOVE-NODES (LE LN) ;; EDGES-REVERSE (LE) ;; EMPTY ((SELF GRAF)) ;; EQUAL? ((SELF GRAF) OTHER-GRAF) ;; FIND-ONLIFBE (LI E) ;; FOLLOW ((SELF GRAF) N) ;; GAMMA-INV-OF-NODE ((SELF GRAF) N) ;; GAMMA-OF-NODE ((SELF GRAF) N) ;; GAMMAS ((SELF GRAF)) ;; GAMMAS-INV ((SELF GRAF)) ;; GRAF () ;; GRAF-ADD-EDGE (G E) ;; GRAF-ADD-EDGES (G LE) ;; GRAF-ADD-NODE (G N) ;; GRAF-ADD-NODES (G LN) ;; GRAF-BUILD-ORDERED-NODE-LIST (G) ;; GRAF-BUILD-ORDERED-NODE-LIST (G) ;; GRAF-BUILD-ORDERED-NODE-LIST-STEP (G L) ;; GRAF-BUILD-ORDERED-NODE-LIST-STEP (G L) ;; GRAF-CONNECTED-CLASSES (G) ;; GRAF-CONTAINS-EDGE? (G E) ;; GRAF-CONTAINS-NODE? (G N) ;; GRAF-DIAGRAM (G OUT NODE-NAME) ;; GRAF-DIAGRAM-GENERATE-EDGES (OUT LEIJ N) ;; GRAF-DIAGRAM-GENERATE-LINE (OUT N L FROM TO VERTICES) ;; GRAF-DIAGRAM-GENERATE-NODE (OUT N L X Y SX SY NODE) ;; GRAF-DIAGRAM-GENERATE-VERTEX (OUT N L X Y) ;; GRAF-DISPLAY-GAMMAS (G) ;; GRAF-DISPLAY-GAMMAS-INV (G) ;; GRAF-EDGES (G) ;; GRAF-EMPTY () ;; GRAF-EQUAL? (G1 G2) ;; GRAF-FOLLOW (G N) ;; GRAF-FOLLOW-L (G LN) ;; GRAF-GAMMA (G N) ;; GRAF-GAMMA-CLOSURE (G N) ;; GRAF-GAMMA-INV (G N) ;; GRAF-GAMMA-INV-CLOSURE (G N) ;; GRAF-GAMMAS (G) ;; GRAF-GAMMAS-INV (G) ;; GRAF-INITIAL-NODES (G) ;; GRAF-INITIAL-TOKENS (G) ;; GRAF-INTERSECTION (G1 G2) ;; GRAF-MAKE-REFLEXIVE (G) ;; GRAF-MAKE-SYMETRIC (G) ;; GRAF-MAKE-TREE (G ROOT) ;; GRAF-MINIMIZE-CROSSES (G) ;; GRAF-MINIMIZE-CROSSES-COUNT-CROSSES (G NV) ; private ;; GRAF-MINIMIZE-CROSSES-SEARCH-SWAP (G NV NC CC SCC) ; private ;; GRAF-NODES (G) ;; GRAF-ONL-ADD-INDICES-IJ (LL I J N) ;; GRAF-ONLIF-BUILD-EDGES (G LI N) ;; GRAF-ONLIF-BUILD-EDGES-CURRENT (G LI CLI N) ;; GRAF-ONLIFBE-REPLACE (LI LE N) ;; GRAF-PARTIAL? (G1 G2) ;; GRAF-PRECEDE (G N) ;; GRAF-PRECEDE-L (G LN) ;; GRAF-REFLEXIVE? (G) ;; GRAF-REMOVE-EDGE (G E) ;; GRAF-REMOVE-EDGES (G LE) ;; GRAF-REMOVE-NODE (G N) ;; GRAF-REMOVE-NODES (G LN) ;; GRAF-REPLACE-NODE (G ON NN) ;; GRAF-REVERSE-EDGES (G) ;; GRAF-SUBSET? (G1 G2) ;; GRAF-SUMMARY () ;; GRAF-SYMETRIC (G) ;; GRAF-SYMETRIC? (G) ;; GRAF-TERMINAL-NODES (G) ;; GRAF-TERMINAL-TOKENS (G) ;; GRAF-UNION (G1 G2) ;; INITIAL-NODES ((SELF GRAF)) ;; INITIAL-TOKENS ((SELF GRAF)) ;; IS-PARTIAL-OF? ((SELF GRAF) OTHER-GRAF) ;; IS-REFLEXIVE? ((SELF GRAF)) ;; IS-SUBSET-OF? ((SELF GRAF) OTHER-GRAF) ;; IS-SYMETRIC? ((SELF GRAF)) ;; LPRINT (L) ;; MAKE-INTERSECTION ((SELF GRAF) OTHER-GRAF) ;; MAKE-REFLEXIVE ((SELF GRAF)) ;; MAKE-SYMETRIC ((SELF GRAF)) ;; MAKE-TREE ((SELF GRAF) ROOT) ;; MAKE-UNION ((SELF GRAF) OTHER-GRAF) ;; MINIMIZE-CROSSES ((SELF GRAF)) ;; NODE-POS-X (N) ;; NODE-POS-Y (N) ;; NODE-SIZE-X (N) ;; NODE-SIZE-Y (N) ;; NODES ((SELF GRAF)) ;; PRECEDE ((SELF GRAF) N) ;; REMOVE-EDGE ((SELF GRAF) E) ;; REMOVE-EDGES ((SELF GRAF) LE) ;; REMOVE-NODE ((SELF GRAF) N) ;; REMOVE-NODES ((SELF GRAF) N) ;; REVERSE-EDGES ((SELF GRAF)) ;; SET-CONTAINS? (S E) ;; SET-DIFF (S1 S2) ;; SET-EQUAL? (S1 S2) ;; SET-INTERSECTION (S1 S2) ;; SET-MEMBER (S LS) ;; SET-REMOVE (S E) ;; SET-SUBSET? (S1 S2) ;; SET-UNION (S1 S2) ;; SET-UNION-L (LS) ;; SET-UNIQUE-L (LS) ;; SYMETRIC ((SELF GRAF)) ;; TERMINAL-NODES ((SELF GRAF)) ;; TERMINAL-TOKENS ((SELF GRAF)) ;;---------------------------------------------------------------------- (defun set-contains? (s e) (cond ((null s) nil) ((equalp (car s) e) t) (t (set-contains? (cdr s) e))) ) ;;SET-CONTAINS? (defun set-subset? (s1 s2) (cond ((null s1) t) ((set-contains? s2 (car s1)) (set-subset? (cdr s1) s2))) ) ;;SET-SUBSET? (defun set-equal? (s1 s2) (and (set-subset? s1 s2) (set-subset? s2 s1)) ) ;;SET-EQUAL? (defun set-remove (s e) (cond ((null s) s) ((equalp (car s) e) (cdr s)) ; e is unique in a set (t (cons (car s) (set-remove (cdr s) e)))) ) ;;SET-REMOVE (defun set-union (s1 s2) (if (null s2) s1 (if (set-contains? s1 (car s2)) (set-union s1 (cdr s2)) (set-union (cons (car s2) s1) (cdr s2)))) ) ;;SET-UNION ;; ls = list of set '((a b c) (c d e) (f i)) --> '(a b c d e f i) (defun set-union-l (ls) (cond ((null ls) ls) ((null (cdr ls)) (car ls)) (t (set-union-l (cons (set-union (car ls) (cadr ls)) (cddr ls))))) ) ;;SET-UNION-L (defun set-diff (s1 s2) (if (null s1) s1 (if (set-contains? s2 (car s1)) (set-diff (cdr s1) s2) (cons (car s1) (set-diff (cdr s1) s2)))) ) ;;SET-DIFF (defun set-intersection (s1 s2) (if (null s1) s1 (if (set-contains? s2 (car s1)) (cons (car s1) (set-intersection (cdr s1) s2)) (set-intersection (cdr s1) s2))) ) ;;SET-INTERSECTION (defun set-member (s ls) (if (null ls) nil (if (set-equal? s (car ls)) t (set-member s (cdr ls)))) ) ;;SET-MEMBER (defun set-unique-l (ls) (if (null ls) nil (if (set-member (car ls) (cdr ls)) (set-unique-l (cdr ls)) (cons (car ls) (set-unique-l (cdr ls))))) ) ;;SET-UNIQUE-L (defun graf-empty () '(()) ) ;;GRAF-EMPTY (defun graf-nodes (g) (car g) ) ;;GRAF-NODES (defun graf-edges (g) (cdr g) ) ;;GRAF-EDGES (defun graf-contains-node? (g n) (set-contains? (graf-nodes g) n) ) ;;GRAF-CONTAINS-NODE? (defun graf-add-node (g n) (if (set-contains? (graf-nodes g) n) g (cons (cons n (graf-nodes g)) (graf-edges g))) ) ;;GRAF-ADD-NODE (defun graf-add-nodes (g ln) (if (null ln) g (graf-add-nodes (graf-add-node g (car ln)) (cdr ln))) ) ;;GRAF-ADD-NODES (defun edges-remove-node (le n) (cond ((null le) le) ((or (equalp (caar le) n) (equalp (cadar le) n)) (edges-remove-node (cdr le) n)) (t (cons (car le) (edges-remove-node (cdr le) n)))) ) ;;EDGES-REMOVE-NODE (defun edges-remove-nodes (le ln) (if (null ln) le (edges-remove-nodes (edges-remove-node le (car ln)) (cdr ln))) ) ;;EDGES-REMOVE-NODES (defun graf-remove-node (g n) (cons (set-remove (graf-nodes g) n) (edges-remove-node (graf-edges g) n)) ) ;;GRAF-REMOVE-NODE (defun graf-remove-nodes (g ln) (cons (set-diff (graf-nodes g) ln) (edges-remove-nodes (graf-edges g) ln)) ) ;;GRAF-REMOVE-NODES (defun graf-contains-edge? (g e) (set-contains? (graf-edges g) e) ) ;;GRAF-CONTAINS-EDGE? (defun graf-add-edge (g e) (if (and (consp e) (null (cddr e)) (graf-contains-node? g (car e)) (graf-contains-node? g (cadr e)) (not (graf-contains-edge? g e))) (cons (graf-nodes g) (cons e (graf-edges g))) g) ) ;;GRAF-ADD-EDGE (defun graf-add-edges (g le) (if (null le) g (graf-add-edges (graf-add-edge g (car le)) (cdr le))) ) ;;GRAF-ADD-EDGES (defun graf-remove-edges (g le) (cons (graf-nodes g) (set-diff (graf-edges g) le)) ) ;;GRAF-REMOVE-EDGES (defun graf-remove-edge (g e) (graf-remove-edges g (list e)) ) ;;GRAF-REMOVE-EDGE (defun graf-equal? (g1 g2) (and (set-equal? (graf-nodes g1) (graf-nodes g2)) (set-equal? (graf-edges g1) (graf-edges g2))) ) ;;GRAF-EQUAL? (defun graf-partial? (g1 g2) (and (set-equal? (graf-nodes g1) (graf-nodes g2)) (set-subset? (graf-edges g1) (graf-edges g2))) ) ;;GRAF-PARTIAL? (defun graf-subset? (g1 g2) (and (set-subset? (graf-nodes g1) (graf-nodes g2)) (set-subset? (graf-edges g1) (graf-edges g2))) ) ;;GRAF-SUBSET? (defun graf-union (g1 g2) (cons (set-union (graf-nodes g1) (graf-nodes g2)) (set-union (graf-edges g1) (graf-edges g2))) ) ;;GRAF-UNION (defun graf-intersection (g1 g2) (let ((nodes (set-intersection (graf-nodes g1) (graf-nodes g2)))) (cons nodes (edges-remove-nodes (set-intersection (graf-edges g1) (graf-edges g2)) (set-diff (set-union (graf-nodes g1) (graf-nodes g2)) nodes)))) ) ;;GRAF-INTERSECTION (defun edges-next-nodes (le n) (cond ((null le) le) ((equalp (caar le) n) (cons (car le) (edges-next-nodes (cdr le) n))) (t (edges-next-nodes (cdr le) n))) ) ;;EDGES-NEXT-NODES (defun edges-prev-nodes (le n) (cond ((null le) le) ((equalp (cadar le) n) (cons (car le) (edges-prev-nodes (cdr le) n))) (t (edges-prev-nodes (cdr le) n))) ) ;;EDGES-PREV-NODES (defun graf-gamma (g n) (edges-next-nodes (graf-edges g) n) ) ;;GRAF-GAMMA (defun graf-gamma-inv (g n) (edges-prev-nodes (graf-edges g) n) ) ;;GRAF-GAMMA-INV (defun graf-follow (g n) (mapcar 'cadr (graf-gamma g n)) ) ;;GRAF-FOLLOW (defun graf-precede (g n) (mapcar 'car (graf-gamma-inv g n)) ) ;;GRAF-PRECEDE (defun graf-follow-l (g ln) (if (null ln) nil (set-union (graf-follow g (car ln)) (graf-follow-l g (cdr ln)))) ) ;;GRAF-FOLLOW-L (defun graf-precede-l (g ln) (if (null ln) nil (set-union (graf-precede g (car ln)) (graf-precede-l g (cdr ln)))) ) ;;GRAF-PRECEDE-L (defun graf-gamma-closure (g n) (let* ( (prev-closure '()) (new-closure (list n)) (next (graf-follow-l g new-closure))) (loop while (not (set-equal? prev-closure new-closure)) do (setq prev-closure new-closure) (setq new-closure (set-union new-closure next)) (setq next (graf-follow-l g new-closure)) ) new-closure) ) ;;GRAF-GAMMA-CLOSURE (defun graf-gamma-inv-closure (g n) (let* ( (prev-closure '()) (new-closure (list n)) (next (graf-precede-l g new-closure))) (loop while (not (set-equal? prev-closure new-closure)) do (setq prev-closure new-closure) (setq new-closure (set-union new-closure next)) (setq next (graf-precede-l g new-closure)) ) new-closure) ) ;;GRAF-GAMMA-INV-CLOSURE (defun graf-connected-classes (g) (set-unique-l (mapcar (lambda (x) (set-intersection (graf-gamma-inv-closure g x) (graf-gamma-closure g x))) (graf-nodes g))) ) ;;GRAF-CONNECTED-CLASSES (defun graf-gammas (g) (mapcar 'graf-gamma (make-list (length (graf-nodes g)) :initial-element g) (graf-nodes g)) ) ;;GRAF-GAMMAS (defun graf-gammas-inv (g) (mapcar 'graf-gamma-inv (make-list (length (graf-nodes g)) :initial-element g) (graf-nodes g)) ) ;;GRAF-GAMMAS-INV (defun graf-display-gammas (g) (mapcar (lambda (n) (format t "~a -> ~a ~%" n (mapcar 'cadr (graf-gamma g n)))) (graf-nodes g)) ) ;;GRAF-DISPLAY-GAMMAS (defun graf-display-gammas-inv (g) (mapcar (lambda (n) (format t "~a <- ~a ~%" n (mapcar 'car (graf-gamma-inv g n)))) (graf-nodes g)) ) ;;GRAF-DISPLAY-GAMMAS-INV (defun edges-reverse (le) (if (null le) le (cons (list (cadar le) (caar le)) (edges-reverse (cdr le)))) ) ;;EDGES-REVERSE (defun graf-reverse-edges (g) (cons (graf-nodes g) (edges-reverse (graf-edges g))) ) ;;GRAF-REVERSE-EDGES (defun graf-symetric (g) (graf-reverse-edges g) ) ;;GRAF-SYMETRIC (defun graf-symetric? (g) (set-equal? (graf-edges g) (edges-reverse (graf-edges g))) ) ;;GRAF-SYMETRIC? (defun graf-make-symetric (g) (graf-union g (graf-reverse-edges g)) ) ;;GRAF-MAKE-SYMETRIC (defun lprint (l) (progn (print (length l)) (cond ((null l) (print "---")) ((not (consp l)) (print l)) (t (progn (print (car l)) (lprint (cdr l)))))) ) ;;LPRINT (defun graf-minimize-crosses-count-crosses (g nv) ; private (declare (type (simple-array cons *) nv)) (let ( (nc (array-dimension nv 0)) (cc (make-array (array-dimension nv 0) :initial-element 0)) ) (do ((i 0 (1+ i))) ((>= i nc)) (do ((j (1+ i) (1+ j))) ((>= j nc)) (do ((k (1+ j) (1+ k))) ((>= k nc)) (do ((l (1+ k) (1+ l))) ((>= l nc)) ;; (format t ;; "~s ~s ~s ~s ([~s]~s,[~s]~s)=~s ([~s]~s,[~s]~s)=~s ~s ~s~%" ;; i j k l ;; i (aref nv i) ;; k (aref nv k) ;; (graf-contains-edge? g ;; (list (aref nv i) (aref nv k))) ;; j (aref nv j) ;; l (aref nv l) ;; (graf-contains-edge? g ;; (list (aref nv j) (aref nv l))) ;; (and ;; (graf-contains-edge? g ;; (list (aref nv i) (aref nv k))) ;; (graf-contains-edge? g ;; (list (aref nv j) (aref nv l))) ;; ) ;; cc) (when (and (graf-contains-edge? g (list (aref nv i) (aref nv k))) (graf-contains-edge? g (list (aref nv j) (aref nv l)))) (setf (aref cc i) (1+ (aref cc i)) (aref cc j) (1+ (aref cc j)) (aref cc k) (1+ (aref cc k)) (aref cc l) (1+ (aref cc l))) ) )))) cc) ;;LET ) ;;GRAF-MINIMIZE-CROSSES-COUNT-CROSSES (defvar graf-minimize-crosses-verbosely nil) (defun graf-minimize-crosses-search-swap (g nv nc cc scc) ; private (declare (type (simple-array cons *) nv) (type (or null (simple-array integer *)) cc) (type integer nc scc)) (let ( (bi nc) ; best swap index. (bj nc) ; best swap index. (bsv (copy-seq nv)) ; best swapped array. (bsc (and cc (copy-seq cc))) ; best swapped count of crosses array. (bssc scc) ; best sum of swapped count of crosses array. (sv nil) ; swapped array. (sc nil) ; swapped counts of crosses array. (ssc 0) ; sum of swapped count of crosses array. ) (declare (type (or null (simple-array integer *)) sc bsc) (type (or null (simple-array cons *)) sv bsv)) (do ((i 0 (1+ i))) ((<= nc i)) (do ((j (1+ i) (1+ j))) ((<= nc j)) (setq sv (copy-seq nv)) (psetf (aref sv i) (aref sv j) (aref sv j) (aref sv i)) (setq sc (graf-minimize-crosses-count-crosses g sv)) (setq ssc (reduce (function +) sc)) (if (< ssc bssc) (progn (if graf-minimize-crosses-verbosely (format t "found less: ~s~%" (/ ssc 4))) (setq bi i) (setq bj i) (setq bsv (copy-seq sv)) (setq bsc (copy-seq sc)) (setq bssc ssc) )))) (if (= bi nc) nil (list bsv bsc bssc) )) ) ;;GRAF-MINIMIZE-CROSSES-SEARCH-SWAP ;;----------------------- ;;graf-minimize-crosses: ;;----------------------- ;;compute the new count of crosses ;;search for a better swap ;;while we can find a better swap do ;; swap the nodes ;; compute the new count of crosses ;; search for a better swap ;;end (defun graf-minimize-crosses (g) (if (not (graf-symetric? g)) (graf-minimize-crosses (graf-make-symetric g)) (let* ((nv (make-array (length (graf-nodes g)) :initial-contents (graf-nodes g))) (nc (length (graf-nodes g))) (cc (graf-minimize-crosses-count-crosses g nv)) ; count of crosses array. (scc (reduce (function +) cc)) ; sum of cc. (ss (graf-minimize-crosses-search-swap g nv nc cc scc)) ; search-swap result. ) (declare (type (or null (simple-array integer *)) cc) (type (simple-array cons *) nv) (type integer nc scc) (type list ss)) (loop while (not (null ss)) do (setq nv (car ss)) (setq cc (cadr ss)) (setq scc (caddr ss)) (setq ss (graf-minimize-crosses-search-swap g nv nc cc scc)) ) (if graf-minimize-crosses-verbosely (format t "crosses: ~s ~%" cc)) nv )) ) ;;GRAF-MINIMIZE-CROSSES (defun graf-replace-node (g on nn) (graf-add-edges (graf-add-nodes (graf-empty) (mapcar (lambda (n) (if (eq n on) nn n)) (graf-nodes g))) (mapcar (lambda (e) (mapcar (lambda (n) (if (eq n on) nn n)) e)) (graf-edges g))) ) ;;GRAF-REPLACE-NODE ;;TODO:(defun graf-collapse-links (g) ;;TODO: (if (not (graf-symetric? g)) ;;TODO: (graf-collapse-links (graf-make-symetrical g)) ;;TODO: (graf-collapse-links-remove-link-nodes ;;TODO: (graf-collapse-link-collapse-paths g)))) ;;TODO: ;;TODO: ;;TODO:(defun graf-collapse-link-get-path-from (path links) ;;TODO: (if (null links) ;;TODO: (cons links ;;TODO:(defun graf-collapse-link-get-a-path (links) ;;TODO: (if (null links) ;;TODO: links ;;TODO: (graf-collapse-link-get-path-from (car links) (cdr links)))) ;;TODO: ;;TODO:(defun graf-collapse-link-collapse-paths (g) ;;TODO: (let ( ;;TODO: (links (flatten (mapcar (lambda (gam) ;;TODO: (if (= (length gam) 2) gam '())) ;;TODO: (graf-gammas g)))) ;;TODO: (paths '()) ;;TODO: (res) ;;TODO: ) ;;TODO: ;;TODO: (setq res (graf-collapse-link-get-a-path links)) ;;TODO: (loop while (not (null res)) do ;;TODO: (setq links (car res)) ;;TODO: (append! paths (cdr res)) ;;TODO: (setq res (graf-collapse-link-get-a-path links)) ;;TODO: ) ;;TODO: ;;TODO: (do ((curps paths (cdr curps))) ((null curps)) ;;TODO: (mapcar (lambda (oldnode) ;;TODO: (setq g (graf-replace-node g oldnode (cdar curps)))) ;;TODO: (caar curps))) ;;TODO: g)) ;;TODO: ;;TODO: ;;TODO:(graf-collapse-link-collapse-paths cg) ;;TODO: (mapcar (lambda (link) ;;TODO: (let ((links '())) ;;TODO: ; find the links ie. nodes with two adjacent nodes. ;;TODO: (do ((nodes (graf-nodes g) (cdr nodes))) ((null nodes)) ;;TODO: (let ((gamma (set-remove ;;TODO: (graf-gamma g (car nodes)) ;;TODO: (list (car nodes) (car nodes))))) ;;TODO: (if (= 2 (length gamma)) ;;TODO: (setq links (cons (cons (list (car nodes)) gamma) ;;TODO: links))))) ;;TODO:(format t "links=~s~%" links) ;;TODO: (let ((linkheads (mapcar 'car links))) ;;TODO: ; foreach linkhead ;;TODO: ; foreach edge from linkhead ;;TODO: ; if adjacent node from linkhead is in linkheads then ;;TODO: ; collapse them ;;TODO: (mapcar (lambda (link) ;;TODO: (mapcar (lambda (edges) ;;TODO: (if (set-contains? linkheads (cdr edges)) ;;TODO: (graf-replace-node g (car link) ;;TODO: (list (car link) (cdr edges))))) ;;TODO: (cdr link))) ;;TODO: links) ;;TODO: (do ((nodes links (cdr nodes))) ((null nodes)) ;;TODO: (let ( ;;TODO: (node (caar nodes)) ;;TODO: (next (set-remove (mapcar 'cadr (cdar nodes)) (caar nodes))) ;;TODO: ) ;;TODO: (format t "linkheads=~s node=~s nexts=~s ~%" linkheads node next) ;;TODO: (do ((tails next (cdr tails))) ((null tails)) ;;TODO: (if (set-contains? linkheads (car tails)) ;;TODO: (progn ;;TODO: ;;TODO: )) ;;TODO: ) ;;TODO: ) ;;TODO: )) ;;TODO: ))) ;;TODO:(graf-collapse-links cg) ;;TODO: ;;TODO: (defun graf-initial-nodes (g) (let ((tn '()) (nn (graf-nodes g))) (loop while (not (set-equal? tn nn)) do (setq tn nn) (setq nn (set-union-l (mapcar (lambda (x) (let ((f (graf-precede g x))) (if (null f) (list x) f))) tn)))) nn) ) ;;GRAF-INITIAL-NODES (defun graf-terminal-nodes (g) (let ((tn '()) (nn (graf-nodes g))) (loop while (not (set-equal? tn nn)) do (setq tn nn) (setq nn (set-union-l (mapcar (lambda (x) (let ((f (graf-follow g x))) (if (null f) (list x) f))) tn)))) nn) ) ;;GRAF-TERMINAL-NODES (defun graf-initial-tokens (g) (delete nil (mapcar (lambda (x) (if (graf-precede g x) nil x)) (graf-nodes g))) ) ;;GRAF-INITIAL-TOKENS (defun graf-terminal-tokens (g) (delete nil (mapcar (lambda (x) (if (graf-follow g x) nil x)) (graf-nodes g))) ) ;;GRAF-TERMINAL-TOKENS (defun and-l (l) (cond ((null l) t) ((car l) (and-l (cdr l))) (t nil)) ) ;;AND-L (defun graf-reflexive? (g) (and-l (mapcar (lambda (n) (graf-contains-edge? g (list n n))) (graf-nodes g))) ) ;;GRAF-REFLEXIVE? (defun graf-make-reflexive (g) (graf-add-edges g (mapcar (lambda (x) (list x x)) (graf-nodes g))) ) ;;GRAF-MAKE-REFLEXIVE (defun graf-make-tree (g root) (cons root (mapcar (lambda (x) (graf-make-tree (graf-remove-node g root) x)) (graf-follow g root))) ) ;;GRAF-MAKE-TREE ;; let s[0] be the set of terminal tokens of g ;; let s[i+1] be the set of precedent nodes of s[i] less the nodes already in ;; union(s[j],j in [0..i]). ;; k=MU i, s[k] equals the set of initial tokens of g ;; result=(s[k],...,s[0]) (defun graf-build-ordered-node-list-step (g l) (if (null (car l)) (cdr l) (graf-build-ordered-node-list-step g (cons (set-diff (graf-precede-l g (car l)) (set-union-l l)) l))) ) ;;GRAF-BUILD-ORDERED-NODE-LIST-STEP ;;; (DEFUN GRAF-BUILD-ORDERED-NODE-LIST (G) ;;; (GRAF-BUILD-ORDERED-NODE-LIST-STEP G (LIST (GRAF-TERMINAL-TOKENS G)))) (defun graf-build-ordered-node-list (g) (reverse (graf-build-ordered-node-list-step g (list (graf-initial-tokens g)))) ) ;;GRAF-BUILD-ORDERED-NODE-LIST ;;; (let* ((first-layer (graf-initial-tokens g)) ;;; (previous-layers first-layer) ;;; (next-layer (graf-follow-l g first-layer))) ;;; ;; si un noed dans next-layer a un precedant non dans previous-layers ;;; ;; alors on le laisse pour plus tard. ;;; (graf-build-ordered-node-list-step g (list (graf-terminal-tokens g)))) ;;; layers_suite[0]=((graf-inital-tokens g)) ;;; previous_layers[0]=union(i,layers_suite[0][i]) ;;; ;;; new_layer[i]=(graf-follow-l g layers_suite[i][0]) ;;; minus nodes who has a previous not in previous_layers[i]. (defun graf-onl-add-indices-ij (ll i j n) (cond ((null ll) nil) ((null (car ll)) (if (null (cdr ll)) (list nil) (cons nil (graf-onl-add-indices-ij (cdr ll) (1+ i) 0 n)))) (t (let ((r (graf-onl-add-indices-ij (cons (cdar ll) (cdr ll)) i (1+ j) (1+ n)))) (cons (cons (list (caar ll) i j n) (car r)) (cdr r))))) ) ;;GRAF-ONL-ADD-INDICES-IJ (defun find-onlifbe (li e) (cond ((null li) nil) ((equal (caar li) e) (car li)) (t (find-onlifbe (cdr li) e))) ) ;;FIND-ONLIFBE (defun graf-onlifbe-replace (li le n) (if (null le) nil (cons (list (find-onlifbe li (caar le)) (find-onlifbe li (cadar le)) n) (graf-onlifbe-replace li (cdr le) (1+ n)))) ) ;;GRAF-ONLIFBE-REPLACE (defun graf-onlif-build-edges-current (g li cli n) (if (null cli) nil (let* ((ni (car cli)) (le (graf-gamma g (car ni))) (lr (if (null le) nil (graf-onlifbe-replace li le n))) (m (if (null le) n (1+ (apply 'max (mapcar #'third lr)))))) (append lr (graf-onlif-build-edges-current g li (cdr cli) m)))) ) ;;GRAF-ONLIF-BUILD-EDGES-CURRENT (defun graf-onlif-build-edges (g li n) (graf-onlif-build-edges-current g li li n) ) ;;GRAF-ONLIF-BUILD-EDGES (defun graf-diagram-generate-node (out n l x y sx sy node) (format out "symbol ~s~%" n) (format out " layer ~s~%" l) (format out " shape \"Rectangle\"~%") (format out " location ~d.00 ~d.00~%" x y) (format out " size ~d.00 ~d.00~%" sx sy) (format out " framed~%") (format out " fillColor colorIndex 0~%") (format out " frameColor colorIndex 1~%") (format out " shadowColor colorIndex 2~%") (format out " lineWidth 1.00~%") (format out " filled~%") (format out " rtfText {\\rtf0\\ansi{\\fonttbl\\f0\\fswiss Helvetica;}\\margl40\\margr40\\pard\\tx960\\tx1920\\tx2880\\tx3840\\tx4800\\tx5760\\tx6720\\tx7680\\tx8640\\tx9600\\f0\\b\\i0\\ulnone\\qc\\fs20\\fc0\\cf0 ~a}~%" node) (format out " textPlacement middle~%") (format out "end~%~%") ) ;;GRAF-DIAGRAM-GENERATE-NODE (defun graf-diagram-generate-vertex (out n l x y) (format out "vertex ~s~%" n) (format out " layer ~s~%" l) (format out " location ~d.00 ~d.00~%" x y) (format out "end~%~%") ) ;;GRAF-DIAGRAM-GENERATE-VERTEX (defun graf-diagram-generate-line (out n l from to vertices) (format out "line ~s~%" n) (format out " from ~s~%" from) (format out " to ~s~%" to) (do ((v vertices (cdr v))) ((null v) nil) (format out " ~s~%" (caar v))) (format out " layer ~s~%" l) (format out " headType arrow~%") (format out " lineWidth ~s~%" 1.00) (format out " filled~%") (format out " frameColor colorIndex ~s~%" 1) (format out " fillColor colorIndex ~s~%" 0) (format out "end~%~%") ) ;;GRAF-DIAGRAM-GENERATE-LINE (defun node-size-x (n) (declare (ignore n)) 100) ;;NODE-SIZE-X (defun node-size-y (n) (declare (ignore n)) 20) ;;NODE-SIZE-Y (defun node-pos-x (n) (+ 50 (* 180 (second n))) ) ;;NODE-POS-X (defun node-pos-y (n) (+ 50 (* 50 (third n))) ) ;;NODE-POS-Y ;;from-to ;; v[0]=(from.pos.x+from.size.x, from.pos.y+from.size.y/2) ;; v[1]=(from.pos.x+from.size.x+4, from.pos.y+from.size.y/2) ;; v[2]=(to.pos.x-4, to.pos.y+to.size.y/2) ;; v[3]=(to.pos.x, to.pos.y+to.size.y/2) ;; ;;from-+-+-to ;; v[0]=(from.pos.x+from.size.x, from.pos.y+from.size.y/2) ;; v[1]=(from.pos.x+from.size.x+4, from.pos.y+from.size.y/2) ;; v[2]=(from.pos.x+from.size.x+20,to.pos.y-4) ;; v[3]=(to.pos.x-20, to.pos.y-4) ;; v[4]=(to.pos.x-4, to.pos.y+to.size.y/2) ;; v[5]=(to.pos.x, to.pos.y+to.size.y/2) (defun graf-diagram-generate-edges (out leij n) (if (null leij) nil (let ((nn n) (allv nil) (alli nil)) (do ((cur-eij leij (cdr cur-eij)) ) ((null cur-eij) nil) (let* ((eij (car cur-eij)) (from (first eij)) (to (second eij)) (linenum (third eij)) (lv nil)) (setq lv (append lv (list (cons nn (list (+ (node-pos-x from) (node-size-x from)) (+ (node-pos-y from) (/ (node-size-y from) 2)))) (cons (1+ nn) (list (+ (node-pos-x from) (node-size-x from) 16) (+ (node-pos-y from) (/ (node-size-y from) 2))))))) (setq nn (+ nn 2)) (when (not (equal (1+ (second from)) (second to))) (setq lv (append lv (list (cons nn (list (+ (node-pos-x from) (node-size-x from) 24) (+ (node-pos-y to) (node-size-y to) 16 (* 2 (- (second from) (second to)))))) (cons (1+ nn) (list (- (node-pos-x to) 24) (+ (node-pos-y to) (node-size-y to) 16 (* 2 (- (second from) (second to)))))) )) nn (+ nn 2))) (setq lv (append lv (list (cons nn (list (- (node-pos-x to) 16) (+ (node-pos-y to) (/ (node-size-y to) 2)))) (cons (1+ nn) (list (node-pos-x to) (+ (node-pos-y to) (/ (node-size-y to) 2))))))) (setq nn (+ nn 2)) (setq allv (append lv allv)) (setq alli (cons (list out linenum linenum (fourth from) (fourth to) lv) alli)) ) ;;LET* ) ;;DO (mapcar (lambda (x) (graf-diagram-generate-vertex out (first x) (first x) (second x) (third x))) allv) (mapcar (lambda (x) (apply 'graf-diagram-generate-line x)) alli) )) ) ;;GRAF-DIAGRAM-GENERATE-EDGES (defun graf-diagram (g out node-name) (declare (type function node-name)) (format out "#!DG_TEXT-Version-2~%") (format out "# D2 Version: Built by rob on Tue Sep 27 14:01:06 PDT 1994~%") (format out "~%") (format out "windowOrigin 222.00 2.00~%") (format out "viewOrigin 1.00 9.00~%") (format out "viewSize 825.00 617.00~%") (format out "visibleOrigin 0.00 0.00~%") (format out "showTools~%") (format out "snapToGrid~%") (format out "gridSize 4.000~%") (format out "defaultFont \"helvetica\"~%") (format out "defaultFontSize 10.00~%") (format out "printInfoFile \"printinfo\"~%") (format out "colorFile \"colors.clr\"~%") (format out "~%") (let* ((lnij (flatten (graf-onl-add-indices-ij (graf-build-ordered-node-list g) 0 0 1000))) (leij (graf-onlif-build-edges g lnij (1+ (apply 'max (mapcar #'fourth lnij)))))) (mapcar (lambda (x) (graf-diagram-generate-node out (fourth x) (fourth x) (node-pos-x x) (node-pos-y x) (node-size-x x) (node-size-y x) (funcall node-name (car x)))) lnij) (graf-diagram-generate-edges out leij (1+ (apply 'max (mapcar #'third leij)))) ) ) ;;GRAF-DIAGRAM ;;---------------------------------------------------------------------- ;;; (graf-onlif-build-edges fam ;;; (flatten (graf-onl-add-indices-ij ;;; (graf-build-ordered-node-list fam) 0 0 1000)) 2000) ;;; (graf-Diagram fam ;;; (open "/users/pascal/src/common/lisp/graf.diagram2/DiagramText") ;;; #'string) ;;---------------------------------------------------------------------- (defun graf-summary () (format t "~%") ;; use the following two lines to update the class summary, but skip the first ;; semicolon. ;; egrep 'DEFCLASS|DEFMETHOD' pjb-graph.lisp |sed -e 's/(DEFCLASS \(.*\)/ (FORMAT T "Class \1~%")/' -e 's/(DEFMETHOD\(.*\)/ (FORMAT T "\1~%")/' (format t "Class GRAF ()~%") (format t " EMPTY ((SELF GRAF))~%") (format t " NODES ((SELF GRAF))~%") (format t " ADD-NODE ((SELF GRAF) N)~%") (format t " ADD-NODES ((SELF GRAF) LN)~%") (format t " CONTAINS-NODE? ((SELF GRAF) N)~%") (format t " REMOVE-NODE ((SELF GRAF) N)~%") (format t " REMOVE-NODES ((SELF GRAF) N)~%") (format t " EDGES ((SELF GRAF))~%") (format t " ADD-EDGE ((SELF GRAF) E)~%") (format t " ADD-EDGES ((SELF GRAF) LE)~%") (format t " CONTAINS-EDGE? ((SELF GRAF) E)~%") (format t " REMOVE-EDGE ((SELF GRAF) E)~%") (format t " REMOVE-EDGES ((SELF GRAF) LE)~%") (format t " REVERSE-EDGES ((SELF GRAF))~%") (format t " IS-SYMETRIC? ((SELF GRAF))~%") (format t " SYMETRIC ((SELF GRAF))~%") (format t " MAKE-SYMETRIC ((SELF GRAF))~%") (format t " IS-REFLEXIVE? ((SELF GRAF))~%") (format t " MAKE-REFLEXIVE ((SELF GRAF))~%") (format t " EQUAL? ((SELF GRAF) OTHER-GRAF)~%") (format t " IS-PARTIAL-OF? ((SELF GRAF) OTHER-GRAF)~%") (format t " IS-SUBSET-OF? ((SELF GRAF) OTHER-GRAF)~%") (format t " MINIMIZE-CROSSES ((SELF GRAF))~%") (format t " GAMMA-OF-NODE ((SELF GRAF) N)~%") (format t " GAMMA-INV-OF-NODE ((SELF GRAF) N)~%") (format t " GAMMAS ((SELF GRAF))~%") (format t " GAMMAS-INV ((SELF GRAF))~%") (format t " DISPLAY-GAMMAS ((SELF GRAF))~%") (format t " DISPLAY-GAMMAS-INV ((SELF GRAF))~%") (format t " PRECEDE ((SELF GRAF) N)~%") (format t " FOLLOW ((SELF GRAF) N)~%") (format t " INITIAL-NODES ((SELF GRAF))~%") (format t " TERMINAL-NODES ((SELF GRAF))~%") (format t " INITIAL-TOKENS ((SELF GRAF))~%") (format t " TERMINAL-TOKENS ((SELF GRAF))~%") (format t " MAKE-INTERSECTION ((SELF GRAF) OTHER-GRAF)~%") (format t " MAKE-UNION ((SELF GRAF) OTHER-GRAF)~%") (format t " MAKE-TREE ((SELF GRAF) ROOT)~%") ) ;;GRAF-SUMMARY (defgeneric empty (self)) (defgeneric nodes (self)) (defgeneric add-node (self n)) (defgeneric add-nodes (self ln)) (defgeneric contains-node\? (self n)) (defgeneric remove-node (self n)) (defgeneric remove-nodes (self ln)) (defgeneric edges (self)) (defgeneric add-edge (self e)) (defgeneric add-edges (self le)) (defgeneric contains-edge\? (self e)) (defgeneric remove-edge (self e)) (defgeneric remove-edges (self le)) (defgeneric reverse-edges (self)) (defgeneric is-symetric\? (self)) (defgeneric symetric (self)) (defgeneric make-symetric (self)) (defgeneric is-reflexive\? (self)) (defgeneric make-reflexive (self)) (defgeneric equal\? (self other-graf)) (defgeneric is-partial-of\? (self other-graf)) (defgeneric is-subset-of\? (self other-graf)) (defgeneric minimize-crosses (self)) (defgeneric gamma-of-node (self n)) (defgeneric gamma-inv-of-node (self n)) (defgeneric gammas (self)) (defgeneric gammas-inv (self)) (defgeneric display-gammas (self)) (defgeneric display-gammas-inv (self)) (defgeneric precede (self n)) (defgeneric follow (self n)) (defgeneric initial-nodes (self)) (defgeneric terminal-nodes (self)) (defgeneric initial-tokens (self)) (defgeneric terminal-tokens (self)) (defgeneric make-intersection (self other-graf)) (defgeneric make-union (self other-graf)) (defgeneric make-tree (self root)) (defclass graf () ((graf :accessor graf :initform (graf-empty)))) (defmethod empty ((self graf)) (setf (graf self) (graf-empty)) ) ;;EMPTY (defmethod nodes ((self graf)) (graf-nodes (graf self)) ) ;;NODES (defmethod add-node ((self graf) n) (setf (graf self) (graf-add-node (graf self) n)) ) ;;ADD-NODE (defmethod add-nodes ((self graf) ln) (setf (graf self) (graf-add-nodes (graf self) ln)) ) ;;ADD-NODES (defmethod contains-node? ((self graf) n) (graf-contains-node? (graf self) n) ) ;;CONTAINS-NODE? (defmethod remove-node ((self graf) n) (setf (graf self) (graf-remove-node (graf self) n)) ) ;;REMOVE-NODE (defmethod remove-nodes ((self graf) ln) (setf (graf self) (graf-remove-nodes (graf self) ln)) ) ;;REMOVE-NODES (defmethod edges ((self graf)) (graf-edges (graf self)) ) ;;EDGES (defmethod add-edge ((self graf) e) (setf (graf self) (graf-add-edge (graf self) e)) ) ;;ADD-EDGE (defmethod add-edges ((self graf) le) (setf (graf self) (graf-add-edges (graf self) le)) ) ;;ADD-EDGES (defmethod contains-edge? ((self graf) e) (graf-contains-edge? (graf self) e) ) ;;CONTAINS-EDGE? (defmethod remove-edge ((self graf) e) (setf (graf self) (graf-remove-edge (graf self) e)) ) ;;REMOVE-EDGE (defmethod remove-edges ((self graf) le) (setf (graf self) (graf-remove-edges (graf self) le)) ) ;;REMOVE-EDGES (defmethod reverse-edges ((self graf)) (setf (graf self) (graf-reverse-edges (graf self))) ) ;;REVERSE-EDGES (defmethod is-symetric? ((self graf)) (graf-symetric? (graf self) ) ) ;;IS-SYMETRIC? (defmethod symetric ((self graf)) (let ((g (make-instance 'graf))) (setf (graf g) (graf-symetric (graf self))) g) ) ;;SYMETRIC (defmethod make-symetric ((self graf)) (setf (graf self) (graf-make-symetric (graf self))) ) ;;MAKE-SYMETRIC (defmethod is-reflexive? ((self graf)) (graf-reflexive? (graf self)) ) ;;IS-REFLEXIVE? (defmethod make-reflexive ((self graf)) (graf-make-reflexive (graf self)) ) ;;MAKE-REFLEXIVE (defmethod equal? ((self graf) other-graf) (graf-equal? (graf self) (graf other-graf)) ) ;;EQUAL? (defmethod is-partial-of? ((self graf) other-graf) (graf-partial? (graf self) (graf other-graf)) ) ;;IS-PARTIAL-OF? (defmethod is-subset-of? ((self graf) other-graf) (graf-subset? (graf self) (graf other-graf)) ) ;;IS-SUBSET-OF? (defmethod minimize-crosses ((self graf)) (setf (graf self) (graf-minimize-crosses (graf self))) ) ;;MINIMIZE-CROSSES (defmethod gamma-of-node ((self graf) n) (graf-gamma (graf self) n) ) ;;GAMMA-OF-NODE (defmethod gamma-inv-of-node ((self graf) n) (graf-gamma-inv (graf self) n) ) ;;GAMMA-INV-OF-NODE (defmethod gammas ((self graf)) (graf-gammas (graf self)) ) ;;GAMMAS (defmethod gammas-inv ((self graf)) (graf-gammas-inv (graf self)) ) ;;GAMMAS-INV (defmethod display-gammas ((self graf)) (graf-display-gammas (graf self)) ) ;;DISPLAY-GAMMAS (defmethod display-gammas-inv ((self graf)) (graf-display-gammas-inv (graf self)) ) ;;DISPLAY-GAMMAS-INV (defmethod precede ((self graf) n) (graf-precede (graf self) n) ) ;;PRECEDE (defmethod follow ((self graf) n) (graf-follow (graf self) n) ) ;;FOLLOW (defmethod initial-nodes ((self graf)) (graf-initial-nodes (graf self)) ) ;;INITIAL-NODES (defmethod terminal-nodes ((self graf)) (graf-terminal-nodes (graf self)) ) ;;TERMINAL-NODES (defmethod initial-tokens ((self graf)) (graf-initial-tokens (graf self)) ) ;;INITIAL-TOKENS (defmethod terminal-tokens ((self graf)) (graf-terminal-tokens (graf self)) ) ;;TERMINAL-TOKENS (defmethod make-intersection ((self graf) other-graf) (let ((g (make-instance 'graf))) (setf (graf g) (graf-intersection (graf self) (graf other-graf))) g) ) ;;MAKE-INTERSECTION (defmethod make-union ((self graf) other-graf) (let ((g (make-instance 'graf))) (setf (graf g) (graf-union (graf self) (graf other-graf))) g) ) ;;MAKE-UNION (defmethod make-tree ((self graf) root) (graf-make-tree (graf self) root) ) ;;MAKE-TREE ;;;; graf.lisp -- -- ;;;;
44,338
Common Lisp
.lisp
1,157
32.372515
228
0.5557
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
16a40069a085ba9be3c39c82021aaea0912ee420cef139c3129d228af2913250
5,026
[ -1 ]
5,027
web-cache.lisp
informatimago_lisp/common-lisp/obsolete-or-incomplete/web-cache.lisp
;;;; -*- coding:utf-8 -*- ;;**************************************************************************** ;;FILE: web-cache.lisp ;;LANGUAGE: Common-Lisp ;;SYSTEM: Common-Lisp ;;USER-INTERFACE: NONE ;;DESCRIPTION ;; ;; This package implements a cache for web pages, ;; mapping urls to HTML text and parsed tree. ;; ;;AUTHORS ;; <PJB> Pascal J. Bourguignon <[email protected]> ;;MODIFICATIONS ;; 2004-11-20 <PJB> Created. ;;BUGS ;; On clisp rename-file is not atomic. ;;LEGAL ;; GPL ;; ;; Copyright Pascal J. Bourguignon 2004 - 2004 ;; ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License ;; as published by the Free Software Foundation; either version ;; 2 of the License, or (at your option) any later version. ;; ;; This program is distributed in the hope that it will be ;; useful, but WITHOUT ANY WARRANTY; without even the implied ;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ;; PURPOSE. See the GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public ;; License along with this program; if not, write to the Free ;; Software Foundation, Inc., 59 Temple Place, Suite 330, ;; Boston, MA 02111-1307 USA ;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (in-package "COMMON-LISP-USER") (declaim (declaration also-use-packages)) (declaim (also-use-packages "COM.INFORMATIMAGO.COMMON-LISP.HTML-PARSER.PARSE-HTML")) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.OBSOLETE-OR-INCOMPLEPTE.WEB-CACHE" (:use "COMMON-LISP" "COM.INFORMATIMAGO.PA.PROCESS-HTML" "COM.INFORMATIMAGO.PA.HTTP-CLIENT") #+mocl (:shadowing-import-from "COM.INFORMATIMAGO.MOCL.KLUDGES.MISSING" "*TRACE-OUTPUT*" "*LOAD-VERBOSE*" "*LOAD-PRINT*" "ARRAY-DISPLACEMENT" "CHANGE-CLASS" "COMPILE" "COMPLEX" "ENSURE-DIRECTORIES-EXIST" "FILE-WRITE-DATE" "INVOKE-DEBUGGER" "*DEBUGGER-HOOK*" "LOAD" "LOGICAL-PATHNAME-TRANSLATIONS" "MACHINE-INSTANCE" "MACHINE-VERSION" "NSET-DIFFERENCE" "RENAME-FILE" "SUBSTITUTE-IF" "TRANSLATE-LOGICAL-PATHNAME" "PRINT-NOT-READABLE" "PRINT-NOT-READABLE-OBJECT") (:export "*CACHE-DIRECTORY-PATH*" "SYNCHRONIZE-CACHE" "FORGET-ALL" "FORGET-URI" "FREE-PARSED-HTML-AT-URI" "FREE-RESOURCE-AT-URI" "GET-PARSED-HTML-AT-URI" "GET-RESOURCE-AT-URI") (:documentation " This package implements a cache for web pages, mapping urls to HTML text and parsed tree. Copyright Pascal J. Bourguignon 2004 - 2004 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.OBSOLETE-OR-INCOMPLEPTE.WEB-CACHE") (defclass web-cache () ((directory-path :reader cache-directory-path :initarg :directory-path :type pathname :initform (make-pathname :directory (append (pathname-directory (user-homedir-pathname)) '("WEB-CACHE")) :defaults (user-homedir-pathname)) :documentation "Path to the directory where the cache data is stored.") (index-file-path :reader cache-index-file-path :type (or null pathname) :initform nil :documentation "Path to the cache index file.") (index :accessor cache-index :type hash-table :initform (make-cache-index) :documentation "An equal hash table mapping urls to cache-entries") (cache-date :accessor cache-date :type cons :initform (cons 0 0) :documentation "The date (universal time) and increment of last modification of the index map.") (resource-file-type :accessor cache-resource-file-type :initarg :resource-file-type :type string :initform "DAT") (parsed-html-file-type :accessor cache-parsed-html-file-type :initarg :parsed-html-file-type :type string :initform "LHT") ) (:documentation "A cache for web pages."));;web-cache (defmethod set-directory-path ((self web-cache) new-path) (assert (typep new-path 'pathname)) (setf (slot-value self 'directory-path) new-path (slot-value self 'index-file-path) (make-pathname :name "CACHE" :type "IDX" :defaults new-path))) (defsetf 'directory-path 'set-directory-path) (defun compare-cache-date (a b) " Time stamps (cache date) are (unversal-time . increment). " (cond ((null a) (if b -1 0)) ((null b) 1) ((< (car a) (car b)) -1) ((> (car a) (car b)) 1) (t (cond ((< (cdr a) (cdr b)) -1) ((> (cdr a) (cdr b)) 1) (t 0))))) (defmethod touch-cache-date ((self web-cache)) (if (and (cache-date self) (= (car (cache-date self)) (get-universal-time))) (incf (cdr (cache-date self))) (setf (cache-date sefl) (cons (get-universal-time) 0)))) (defstruct cache-entry "A cache index entry, mapping an url with the date the resource was fetched and the file-name of the files where the resource and the parsed html are stored, and references to these data when they are loaded in core." (url "" :type string) (date-fetched 0 :type (integer 0)) ; the universal time. (file-name "" :type string) ; name of the files. (header nil :type list) ; http header (resource-p nil :type boolean) ; resource is loaded. (resource nil :type (or string (vector (unsigned-byte 8)))) (parsed-html-p nil :type boolean) ; parsed-html is loaded. (parsed-html nil :type list)) ; the parsed html tree. (defun make-cache () (make-hash-table :test (function equal))) (defun cache-enter (cache entry) " DO: Enter the entry into the CACHE. " (setf (gethash (cache-entry-url entry) cache) entry)) ;; cache-index file: ;; header: (:type :web-cache-index :date cache-date) ;; record: (:url str :date-fetched int :file-name str :header lst) (defun cache-header-p (header) " RETURN: Whether HEADER is a cache index file header. " (and (listp header) (eq (getf header :type) :web-cache-index) (consp (getf header :date)) (typep (car (getf header :date)) '(integer 0)) (typep (cdr (getf header :date)) '(integer 0)))) (defun cache-record-p (record) " RETURN: Whether RECORD is a cache index file record. " (and (listp record) (typep (getf record :date-fetched) '(integer 0)) (typep (getf record :url) 'string) (typep (getf record :file-name) 'string) (typep (getf record :header) 'list))) (defmethod cache-index-read-date ((self web-cache)) " RETURN: If the file (cache-index-file-path self) exists and is a cache index file, then the cache-date of the cache index file, else NIL. " (with-open-file (index (cache-index-file-path self) :direction :input :if-does-not-exist nil) (when index (with-standard-io-syntax (let* ((*read-eval* nil) (header (read index nil nil))) (and (cache-header-p header) (getf header :date))))))) (defmethod load-cache ((self web-cache)) " DO: Load the cache index from the file (cache-index-file-path self). " (with-open-file (index (cache-index-file-path self) :direction :input :if-does-not-exist :error) (when index (with-standard-io-syntax (let* ((*read-eval* nil) (header (read index nil nil)) (cache (make-cache)) (cache-date)) (when (cache-header-p header) (setf cache-date (getf header :date)) (loop for record = (read index nil nil) while (cache-record-p record) do (cache-enter cache (make-cache-entry :url (getf record :url) :date-fetched (getf record :date-fetched) :file-name (getf record :file-name) :header (getf record :header))) finally (when record (error "Invalid cache index record: ~S" record)))) (setf (cache-index self) cache (cache-date self) cache-date))))));;load-cache (defmethod save-cache ((self web-cache)) " DO: Save the cache index to the file (cache-index-file-path self). " (ensure-directories-exist (cache-index-file-path)) (with-open-file (index (make-pathname :type "NEW" :defaults (cache-index-file-path self)) :direction :output :if-does-not-exist :create :if-exists :supersede) (prin1 `(:type :web-cache-index :date ,(cache-date self)) index) (terpri index) (maphash (lambda (k v) (declare (ignore k)) (prin1 `(:url ,(cache-entry-url v) :date-fetched ,(cache-entry-date-fetched v) :file-name ,(cache-entry-file-name v) :header ,(cache-entry-header v)) index) (terpri index)) (cache-index self)) (handler-case (rename-file index (cache-index-file-path self)) ;; CLISP<=2.33.2 RENAME-FILE is buggy: (file-error (err) (unless (and (equal (cache-index-file-path self) (file-error-pathname err)) (probe-file (cache-index-file-path self))) (signal err)) (let ((old (make-pathname :type "OLD" :defaults (cache-index-file-path self)))) (when (probe-file old) (delete-file old)) (rename-file (cache-index-file-path self) old) (unwind-protect (rename-file index (cache-index-file-path self)) (when (and (probe-file old) (probe-file (cache-index-file-path self))) (ignore-errors (delete-file (cache-index-file-path self)))) (rename-file old (cache-index-file-path self)) (signal err)))))));;save-cache (defmethod synchronize-cache ((self web-cache)) " DO: Ensure the cache index in core and on disk are synchronized. " (let ((disk-date (cache-index-read-date self))) (case (compare-cache-date (cache-date self) disk-date) ((-1) (load-cache self)) ((1) (save-cache self))))) (defun make-new-name (type directory) (loop for name = (format nil "~36,4,'0R~36,4,'0R" (random (expt 36 4)) (mod (get-universal-time) (expt 36 4))) for count from 0 if (<= 512 count) then (error "Cannot come with a unique file name.") until (ignore-errors (not (probe-file (make-pathname :name name :type type :directory directory)))) finally (return name))) (defun cache-file-path (directory name type) (make-pathname :name name :type type :directory (append (pathname-directory directory) (list (subseq name 0 1) (subseq name 1 2))) :defaults directory)) (defmethod free-resource-at-uri ((self web-cache) uri) (let ((entry (gethash uri (cache-index self)))) (when entry (setf (cache-entry-resource entry) nil (cache-entry-resource-p entry) nil)))) (defmethod free-parsed-html-at-uri ((self web-cache) uri) (let ((entry (gethash uri (cache-index self)))) (when entry (setf (cache-entry-parsed-html entry) nil (cache-entry-parsed-html-p entry) nil)))) (defmethod forget-uri ((self web-cache) uri) " DO: Forget the resource at URI; delete the cached files. " (synchronize-cache) (let ((entry (gethash uri (cache-index self)))) (when entry (ignore-errors (delete-file (cache-file-path (cache-entry-file-name entry) (cache-resource-file-type self) (cache-directory-path self)))) (ignore-errors (delete-file (cache-file-path (cache-entry-file-name entry) (cache-parsed-html-file-type self) (cache-directory-path self)))) (remhash uri (cache-index self)) (touch-cache-date self)))) (defmethod forget-all ((self web-cache)) " DO: Forget all the URI, deleting all the cached files. " (maphash (lambda (uri entry) (declare (ignore entry)) (forget-uri self uri)) (cache-index self)) (synchronize-cache self)) ;; (defstruct cache-entry ;; "A cache index entry, mapping an url with the date the resource ;; was fetched and the file-name of the files where the resource and ;; the parsed html are stored, and references to these data when they ;; are loaded in core." ;; (url "" :type string) ;; (date-fetched 0 :type (integer 0)) ; the universal time. ;; (file-name "" :type string) ; name of the files. ;; (header nil :type list) ; http header ;; (resource-p nil :type boolean) ; resource is loaded. ;; (resource nil :type (or string (vector (unsigned-byte 8)))) ;; (parsed-html-p nil :type boolean) ; parsed-html is loaded. ;; (parsed-html nil :type list)) ;; (cache-enter ;; cache (make-cache-entry ;; :url (getf record :url) ;; :date-fetched (getf record :date-fetched) ;; :file-name (getf record :file-name) ;; :header (getf record :header))) (defmethod put-resource-at-uri ((self web-cache) uri resource-file) (let ((entry (gethash uri (cache-index self)))) (if entry (setf (cache-entry-reresouce-file)) (not-implemented-yet)))) (defun get-resource-at-uri (uri) (unless *cache* (synchronize-cache)) (when *cache* (gethash uri *cache*)) (unless entry (multiple-value-bind (header body) (fetch-resource-at-uri uri) ))) (define-message html-page-req (sender uri)) (define-message html-page-rep (sender page-ref)) (define-message html-tree-req (sender uri)) (define-message html-tree-rep (sender tree-ref)) (send (make-instance 'html-page-req :sender myself :uri uri)) (loop for mesg = (message-receive-sexp queue +cache-message-type+) (case (car mesg) ((:get-html-page) (let* ((sender (first mesg)) (uri (second mesg)) (page (get-resource-at-uri uri))) (if page ;; TODO: actually copy page to shared memory and send only a reference. (message-send-sexp queue sender (list :html-page uri page)) (progn ;; if the request is already in the queue, then forget it. ;; if it comes from somebody else, then keep it ;; keep the request in a queue: (save-request mesg) ;; only proceed if the uri is not in the request queue. (message-send-sexp queue *fetcher* (list :fetch-uri uri)))))) ((:get-html-tree) ;; about the same, but if the tree is not in the cache, check first for ;; the page and skip fetching: just request processing ) ((:fetched-resource) ))) (defun get-parsed-html-at-uri (uri) ) ;; (ensure-directories-exist (cache-index-file-path)) ;; (close (open (cache-index-file-path) :direction :output :if-does-not-exist :create)) ;;;; web-cache.lisp -- -- ;;;;
16,712
Common Lisp
.lisp
385
34.812987
87
0.577103
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
70b0ff41631ad327a1a327b81ac474be8917fd88dc5925abb9cfbc22093ef87f
5,027
[ -1 ]
5,028
iso15924.lisp
informatimago_lisp/common-lisp/obsolete-or-incomplete/iso15924.lisp
;;;; -*- coding:utf-8 -*- ;; http://www.unicode.org/iso15924/iso15924-codes.html #| Code|N°|English Name|Nom français|Property Value Alias|Date| Arab|160|Arabic|arabe|Arabic|2004-05-01| Armn|230|Armenian|arménien|Armenian|2004-05-01| Bali|360|Balinese|balinais||2004-05-29| Batk|365|Batak|batak||2004-05-01| Beng|325|Bengali|bengalî|Bengali|2004-05-01| Blis|550|Blissymbols|symboles Bliss||2004-05-01| Bopo|285|Bopomofo|bopomofo|Bopomofo|2004-05-01| Brah|300|Brahmi|brâhmî||2004-05-01| Brai|570|Braille|braille|Braille|2004-05-01| Bugi|367|Buginese|bouguis||2004-05-01| Buhd|372|Buhid|bouhide|Buhid|2004-05-01| Cans|440|Unified Canadian Aboriginal Syllabics|syllabaire autochtone canadien unifié|Canadian&#x200B ;_Aboriginal|2004-05-29| Cham|358|Cham|cham (čam, tcham)||2004-05-01| Cher|445|Cherokee|tchérokî|Cherokee|2004-05-01| Cirt|291|Cirth|cirth||2004-05-01| Copt|204|Coptic|copte||2004-05-29| Cprt|403|Cypriot|syllabaire chypriote|Cypriot|2004-05-01| Cyrl|220|Cyrillic|cyrillique|Cyrillic|2004-05-01| Cyrs|221|Cyrillic (Old Church Slavonic variant)|cyrillique (variante slavonne)||2004-05-01| Deva|315|Devanagari (Nagari)|dévanâgarî|Devanagari|2004-05-01| Dsrt|250|Deseret (Mormon)|déseret (mormon)|Deseret|2004-05-01| Egyd|070|Egyptian demotic|démotique égyptien||2004-05-01| Egyh|060|Egyptian hieratic|hiératique égyptien||2004-05-01| Egyp|050|Egyptian hieroglyphs|hiéroglyphes égyptiens||2004-05-01| Ethi|430|Ethiopic (Ge‘ez)|éthiopique (éthiopien, ge‘ez, guèze)|Ethiopic|2004-05-29| Geor|240|Georgian (Mkhedruli)|géorgien (mkhédrouli)|Georgian|2004-05-29| Glag|225|Glagolitic|glagolitique||2004-05-01| Goth|206|Gothic|gotique|Gothic|2004-05-01| Grek|200|Greek|grec|Greek|2004-05-01| Gujr|320|Gujarati|goudjarâtî (gujrâtî)|Gujarati|2004-05-01| Guru|310|Gurmukhi|gourmoukhî|Gurmukhi|2004-05-01| Hang|286|Hangul (Hangŭl, Hangeul)|hangûl (hangŭl, hangeul)|Hangul|2004-05-29| Hani|500|Han (Hanzi, Kanji, Hanja)|idéogrammes han|Han|2004-05-01| Hano|371|Hanunoo (Hanunóo)|hanounóo|Hanunoo|2004-05-29| Hans|501|Han (Simplified variant)|idéogrammes han (variante simplifiée)||2004-05-29| Hant|502|Han (Traditional variant)|idéogrammes han (variante traditionnelle)||2004-05-29| Hebr|125|Hebrew|hébreu|Hebrew|2004-05-01| Hira|410|Hiragana|hiragana|Hiragana|2004-05-01| Hmng|450|Pahawh Hmong|pahawh hmong||2004-05-01| Hrkt|412|(alias for Hiragana + Katakana)|(alias pour hiragana + katakana)|Katakana&#x200B ;_Or&#x200B;_Hiragana|2004-05-01| Hung|176|Old Hungarian|ancien hongrois||2004-05-01| Inds|610|Indus (Harappan)|indus||2004-05-01| Ital|210|Old Italic (Etruscan, Oscan, etc.)|ancien italique (étrusque, osque, etc.)|Old&#x200B ;_Italic|2004-05-29| Java|361|Javanese|javanais||2004-05-29| Kali|357|Kayah Li|kayah li||2004-05-01| Kana|411|Katakana|katakana|Katakana|2004-05-01| Khar|305|Kharoshthi|kharochthî||2004-05-29| Khmr|355|Khmer|khmer|Khmer|2004-05-29| Knda|345|Kannada|kannara (canara)|Kannada|2004-05-29| Laoo|356|Lao|laotien|Lao|2004-05-01| Latf|217|Latin (Fraktur variant)|latin (variante brisée)||2004-05-01| Latg|216|Latin (Gaelic variant)|latin (variante gaélique)||2004-05-01| Latn|215|Latin|latin|Latin|2004-05-01| Lepc|335|Lepcha (Róng)|lepcha (róng)||2004-05-01| Limb|336|Limbu|limbou|Limbu|2004-05-29| Lina|400|Linear A|linéaire A||2004-05-01| Linb|401|Linear B|linéaire B|Linear&#x200B ;_B|2004-05-29| Mand|140|Mandaean|mandéen||2004-05-29| Maya|090|Mayan hieroglyphs|hiéroglyphes mayas||2004-05-01| Mero|100|Meroitic|méroïtique||2004-05-01| Mlym|347|Malayalam|malayâlam|Malayalam|2004-05-01| Mong|145|Mongolian|mongol|Mongolian|2004-05-01| Mymr|350|Myanmar (Burmese)|birman|Myanmar|2004-05-01| Ogam|212|Ogham|ogam|Ogham|2004-05-01| Orkh|175|Orkhon|orkhon||2004-05-01| Orya|327|Oriya|oriyâ|Oriya|2004-05-01| Osma|260|Osmanya|osmanais|Osmanya|2004-05-01| Perm|227|Old Permic|ancien permien||2004-05-01| Phag|331|Phags-pa|’phags pa||2004-05-29| Phnx|115|Phoenician|phénicien||2004-05-01| Plrd|282|Pollard Phonetic|phonétique de Pollard||2004-05-01| Qaaa|900|Reserved for private use (start)|réservé à l’usage privé (début)||2004-05-29| Qabx|949|Reserved for private use (end)|réservé à l’usage privé (fin)||2004-05-29| Roro|620|Rongorongo|rongorongo||2004-05-01| Runr|211|Runic|runique|Runic|2004-05-01| Sara|292|Sarati|sarati||2004-05-29| Shaw|281|Shavian (Shaw)|shavien (Shaw)|Shavian|2004-05-01| Sinh|348|Sinhala|singhalais|Sinhala|2004-05-01| Sylo|316|Syloti Nagri|sylotî nâgrî||2004-05-29| Syrc|135|Syriac|syriaque|Syriac|2004-05-01| Syre|138|Syriac (Estrangelo variant)|syriaque (variante estranghélo)||2004-05-01| Syrj|137|Syriac (Western variant)|syriaque (variante occidentale)||2004-05-01| Syrn|136|Syriac (Eastern variant)|syriaque (variante orientale)||2004-05-01| Tagb|373|Tagbanwa|tagbanoua|Tagbanwa|2004-05-01| Tale|353|Tai Le|taï le|Tai&#x200B ;_Le|2004-05-29| Talu|354|Tai Lue|taï lue||2004-05-29| Taml|346|Tamil|tamoul|Tamil|2004-05-01| Telu|340|Telugu|télougou|Telugu|2004-05-01| Teng|290|Tengwar|tengwar||2004-05-01| Tfng|120|Tifinagh (Berber)|tifinagh (berbère)||2004-05-01| Tglg|370|Tagalog|tagal|Tagalog|2004-05-01| Thaa|170|Thaana|thâna|Thaana|2004-05-01| Thai|352|Thai|thaï|Thai|2004-05-01| Tibt|330|Tibetan|tibétain|Tibetan|2004-05-01| Ugar|040|Ugaritic|ougaritique|Ugaritic|2004-05-01| Vaii|470|Vai|vaï||2004-05-01| Visp|280|Visible Speech|parole visible||2004-05-01| Xpeo|030|Old Persian|cunéiforme persépolitain||2004-05-01| Xsux|020|Cuneiform, Sumero-Akkadian|cunéiforme suméro-akkadien||2004-05-01| Yiii|460|Yi|yi|Yi|2004-05-01| Zxxx|997|Code for unwritten languages|codet pour les langues non écrites||2004-05-01| Zyyy|998|Code for undetermined script|codet pour écriture indéterminée|Common|2004-05-29| Zzzz|999|Code for uncoded script|codet pour écriture non codée||2004-05-01| Code|N°|English Name|Nom français|Property Value Alias|Date| Copyright © 2004 ISO, Unicode, Inc., & Everson Typography. All Rights Reserved| |# ;;;; iso15924.lisp -- -- ;;;;
6,064
Common Lisp
.lisp
111
52.711712
125
0.782259
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
fa43016dfec48194710d5496fdda9544517345159663760e12c25e035441363e
5,028
[ -1 ]
5,029
iso646.lisp
informatimago_lisp/common-lisp/obsolete-or-incomplete/iso646.lisp
;;;; -*- coding:utf-8 -*- ;;;;*************************************************************************** ;;;;FILE: iso646.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; This package exports contants naming the ISO646 control codes. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2005-09-01 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2005 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;***************************************************************************
1,359
Common Lisp
.lisp
33
40.181818
83
0.580694
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
89741453491266b4e3043f4660c511f264fb3bb8625983f7568266bf97cdbfb8
5,029
[ -1 ]
5,030
source-form.lisp
informatimago_lisp/common-lisp/lisp-sexp/source-form.lisp
;;;; -*- coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: source-form.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; This package exports functions to parse and manipulate ;;;; Common Lisp sources as lisp forms (such as in macros). ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2021-06-09 <PJB> Added remove-whole-parameter and remove-environment-parameter. ;;;; 2016-01-16 <PJB> Added parameter-parameter-list and make-parameter-list. ;;;; 2014-11-05 <PJB> make-parameter-list now returns also ;;;; parameters from ;;;; sub-destructuring-lambda-lists. ;;;; 2010-02-06 <PJB> Corrected the superclass of orakawbe-ll. ;;;; preqvars instanciated the wrong parameter class. ;;;; bodyvar poped the body parameter name. ;;;; 2006-05-25 <PJB> Created ;;;;BUGS ;;;; ;;;; "3.4.4.1 Destructuring by Lambda Lists" seems to apply only ;;;; to macro lambda lists (therefore to destructuring lambda ;;;; lists only when used in a macro lambda list). Unless "and ;;;; supports destructuring in the same way." in "3.4.5 ;;;; Destructuring Lambda Lists" means that 3.4.4.1 also applies ;;;; to destructuring lambda lists. ;;;; ;;;; (parse-lambda-list '(a b . r) :destructuring) is not implemented yet. ;;;; ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2006 - 2021 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.LISP-SEXP.SOURCE-FORM" (:use "COMMON-LISP") (:export ;; Parameter Classes: "PARAMETER" "ENVIRONMENT-PARAMETER" "WHOLE-PARAMETER" "REST-PARAMETER" "BODY-PARAMETER" "SPECIALIZED-PARAMETER" "AUXILIARY-PARAMETER" "OPTIONAL-PARAMETER" "GENERIC-OPTIONAL-PARAMETER" "KEYWORD-PARAMETER" "GENERIC-KEYWORD-PARAMETER" ;; Parameter Methods: "PARAMETER-NAME" "PARAMETER-LABEL" #|"PARAMETER-HELP-LABEL"|# "PARAMETER-LAMBDA-LIST-KEYWORD" "PARAMETER-SPECIFIER" "PARAMETER-INDICATOR" "PARAMETER-INDICATOR-P" "PARAMETER-INITFORM" "PARAMETER-INITFORM-P" "PARAMETER-KEYWORD" "PARAMETER-KEYWORD-P" "ENSURE-PARAMETER-KEYWORD" "PARAMETER-SPECIALIZER" "PARAMETER-SPECIALIZER-P" "PARAMETER-PARAMETER-LIST" ;; Lambda-List Classes: "LAMBDA-LIST" "ORDINARY-LAMBDA-LIST" "BOA-LAMBDA-LIST" "SPECIALIZED-LAMBDA-LIST" "MODIFY-MACRO-LAMBDA-LIST" "GENERIC-LAMBDA-LIST" "MACRO-LAMBDA-LIST" "TYPE-LAMBDA-LIST" "DESTRUCTURING-LAMBDA-LIST" "SETF-LAMBDA-LIST" "METHOD-COMBINATION-LAMBDA-LIST" ;; Lambda-List Methods: "ORIGINAL-LAMBDA-LIST" "LAMBDA-LIST-PARAMETERS" "LAMBDA-LIST-MANDATORY-PARAMETERS" "LAMBDA-LIST-OPTIONAL-PARAMETERS" "LAMBDA-LIST-REST-PARAMETER" "LAMBDA-LIST-ALLOW-OTHER-KEYS-P" "LAMBDA-LIST-KEY-P" "LAMBDA-LIST-KEYWORD-PARAMETERS" "LAMBDA-LIST-ENVIRONMENT-PARAMETER" "LAMBDA-LIST-AUXILIARY-PARAMETERS" "LAMBDA-LIST-WHOLE-PARAMETER" "LAMBDA-LIST-ENVIRONMENT-PARAMETER" "LAMBDA-LIST-BODY-PARAMETER" "LAMBDA-LIST-KIND" "LAMBDA-LIST-ALLOWED-KEYWORDS" "LAMBDA-LIST-MANDATORY-PARAMETER-COUNT" "LAMBDA-LIST-OPTIONAL-PARAMETER-COUNT" "LAMBDA-LIST-REST-P" "LAMBDA-LIST-MANDATORY-PARAMETERS-P" "LAMBDA-LIST-OPTIONAL-PARAMETERS-P" "LAMBDA-LIST-REST-PARAMETER-P" "LAMBDA-LIST-AUXILIARY-PARAMETERS-P" "LAMBDA-LIST-WHOLE-PARAMETER-P" "LAMBDA-LIST-BODY-PARAMETER-P" "LAMBDA-LIST-ENVIRONMENT-PARAMETER-P" ;; Parsing lambda-lists: "PARSE-LAMBDA-LIST" "PARSE-ORIGINAL-LAMBDA-LIST" ;; Generating information from a lambda-list instance: "MAKE-HELP" "MAKE-ARGUMENT-LIST" "MAKE-ARGUMENT-LIST-FORM" "MAKE-FLAT-ARGUMENT-LIST" "MAKE-FLAT-ARGUMENT-LIST-FORM" "MAKE-LAMBDA-LIST" "MAKE-PARAMETER-LIST" ;; Parsing sources: "EXTRACT-DOCUMENTATION" "EXTRACT-DECLARATIONS" "EXTRACT-BODY" "PARSE-BODY" "DECLARATIONS-HASH-TABLE" "EXTRACT-METHOD-QUALIFIERS" "EXTRACT-METHOD-LAMBDA-LIST" "EXTRACT-METHOD-DDL" "EXTRACT-METHOD-DOCUMENTATION" "EXTRACT-METHOD-DECLARATIONS" "EXTRACT-METHOD-BODY" ;; "DEFUN""DEFGENERIC""DEFMETHOD" ;; *CALL-STACK*" ;; not yet "LIST-SOURCE-FORM") (:export "REMOVE-WHOLE-PARAMETER" "REMOVE-ENVIRONMENT-PARAMETER") (:documentation " This package exports functions to parse and manipulate Common Lisp sources as lisp forms (such as in macros). Copyright Pascal J. Bourguignon 2003 - 2021 This package is provided under the GNU Affero General Public License. See the source file for details. ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.LISP-SEXP.SOURCE-FORM") ;;;---------------------------------------- ;;; Parameter specifications in lambda-lists ;;;---------------------------------------- ;; Syntax of parameter specifications: ;; ;; name ;; | (name [ specializer ]) ; for specialized lambda-lists ;; | (name [ init-form [ indicator ]]) ; for &key &optional ;; | ((name keyword) [ init-form [ indicator ]]) ; for &key (defmacro define-default-generic (name class default-value) `(defgeneric ,name (self) (:method ((self ,class)) (declare (ignore self)) ,default-value))) ;;;-------------------- (defgeneric parameter-name-p (self)) (defgeneric parse-parameter (self form)) (defgeneric parse-parameter-name (self form)) (defgeneric ensure-parameter-keyword (self)) (defgeneric lambda-list-mandatory-parameter-count (self)) (defgeneric lambda-list-optional-parameter-count (self)) (defgeneric parse-optvars (self current slot lambda-list-keyword class)) (defgeneric auxvars (self current)) (defgeneric optvars (self current)) (defgeneric goptvars (self current)) (defgeneric parse-keyvars (self current class)) (defgeneric keyvars (self current)) (defgeneric gkeyvars (self current)) (defgeneric parse-reqvars (self current class)) (defgeneric reqvars (self current)) (defgeneric sreqvars (self current)) (defgeneric preqvars (self current)) (defgeneric parse-original-lambda-list (self)) (defgeneric make-help (self)) (defgeneric make-argument-list (self)) (defgeneric make-argument-list-form (self)) (defgeneric make-flat-argument-list (self)) (defgeneric make-flat-argument-list-form (self)) (defgeneric make-lambda-list (self)) (defgeneric make-parameter-list (ll) (:documentation "Return a list of all the symbols naming parameters in the lambda list.")) (defgeneric parameter-parameter-list (parameter) (:documentation "Return a list of symbols naming parameters for a parameter object. In the case of &optional or &key parameters, the result may contain two symbols: one for the parameter and one for the indicator.")) ;;;-------------------- (defclass parameter () ((name :accessor parameter-name :initarg :name :type symbol :documentation "The name of the parameter.")) (:documentation "A generic parameter.")) (defmethod parameter-name-p ((self parameter)) (slot-boundp self 'name)) (defmethod parameter-parameter-list ((parameter parameter)) (if (parameter-indicator-p parameter) (list (parameter-name parameter) (parameter-indicator parameter)) (list (parameter-name parameter)))) (define-default-generic parameter-indicator parameter nil) (define-default-generic parameter-indicator-p parameter nil) (define-default-generic parameter-initform parameter nil) (define-default-generic parameter-initform-p parameter nil) (define-default-generic parameter-keyword parameter nil) (define-default-generic parameter-keyword-p parameter nil) (define-default-generic parameter-specializer parameter nil) (define-default-generic parameter-specializer-p parameter nil) (defmethod parse-parameter-name ((self parameter) form) (if (symbolp form) (setf (parameter-name self) form) (error "Invalid parameter name: ~S" form)) self) (defmethod parse-parameter ((self parameter) form) (parse-parameter-name self form)) (defmethod print-object ((self parameter) stream) (print-unreadable-object (self stream :identity t) (format stream "~A ~S" (parameter-lambda-list-keyword self) (parameter-specifier self)))) ;;;-------------------- (defclass environment-parameter (parameter) () (:documentation "An &ENVIRONMENT parameter.")) (defclass whole-parameter (parameter) () (:documentation "A &WHOLE parameter.")) (defclass rest-parameter (parameter) () (:documentation "A &REST parameter.")) (defclass body-parameter (rest-parameter) () (:documentation "A &BODY parameter.")) ;;;-------------------- (defclass specialized-parameter (parameter) ((specializer :accessor parameter-specializer :initarg :specializer :type (or symbol cons) :documentation " A specializer can be either NIL (no specializer),p a symbol denoting a class, or a cons (eql object) denoting an EQL specializer.")) (:documentation "A specialized parameter.")) (defmethod parameter-specializer-p ((self specialized-parameter)) (slot-boundp self 'specializer)) (defmethod parse-parameter ((self specialized-parameter) form) (etypecase form (symbol (call-next-method)) (cons (call-next-method self (first form)) (when (cdr form) (setf (parameter-specializer self) (second form)) (when (cddr form) (error "~A specification must be a ~ list of two elements at most, not ~S" (parameter-label self) form))))) self) ;;;-------------------- (defclass parameter-with-initform () ((initform :accessor parameter-initform :initarg :initform :documentation "The initial form for the parameter.")) (:documentation "A mixin for a parameter that may have an initform.")) (defmethod parameter-initform-p ((self parameter-with-initform)) (slot-boundp self 'initform)) (defmethod parse-parameter ((self parameter-with-initform) form) (etypecase form (symbol (call-next-method)) (cons (call-next-method self (first form)) (when (cdr form) (setf (parameter-initform self) (second form))))) self) ;;;-------------------- (defclass auxiliary-parameter (parameter-with-initform parameter) ;; The order of the superclasses is important ;; to find the methods in the right order! () (:documentation "An auxiliary parameter.")) (defmethod parse-parameter ((self auxiliary-parameter) form) (etypecase form (symbol (call-next-method)) (cons (call-next-method) (when (cddr form) (error "~A specification must be a ~ list of two elements at most, not ~S" (parameter-label self) form)))) self) ;;;-------------------- (defclass optional-parameter (parameter-with-initform parameter) ;; The order of the superclasses is important ;; to find the methods in the right order! ((indicator :accessor parameter-indicator :initarg :indicator :type symbol :documentation "NIL, or the name of the indicator parameter.")) (:documentation "An optional parameter. Note that while auxiliary-parameter and optional-parameter have the same initform attribute, an optional-parameter is a different kind from an auxiliary-parameter, semantically.")) (defmethod parameter-initform-p ((self optional-parameter)) (slot-boundp self 'initform)) (defmethod parameter-indicator-p ((self optional-parameter)) (slot-boundp self 'indicator)) (defmethod parse-parameter ((self optional-parameter) form) (etypecase form (symbol (call-next-method)) (cons (call-next-method) (when (cddr form) (setf (parameter-indicator self) (third form)) (when (cdddr form) (error "~A specification must be a ~ list of three elements at most, not ~S" (parameter-label self) form))))) self) ;;;-------------------- (defclass generic-optional-parameter (parameter) () (:documentation "An optional parameter in generic lambda-lists.")) (defmethod parse-parameter ((self generic-optional-parameter) form) (etypecase form (symbol (call-next-method)) (cons (call-next-method self (first form)) (when (cdr form) (error "~A specification must be a ~ list of one element at most, not ~S" (parameter-label self) form))))) ;;;-------------------- (defclass parameter-with-keyword () ((keyword :accessor parameter-keyword :initarg :keyword :type symbol :documentation "NIL, or the keyword specified for the parameter.")) (:documentation "A mixin for keyword parameters.")) (defmethod parameter-keyword-p ((self parameter-with-keyword)) (slot-boundp self 'keyword)) (defmethod parse-parameter-name ((self parameter-with-keyword) form) (etypecase form (symbol (call-next-method)) (cons (if (= 2 (length form)) (progn (call-next-method self (second form)) (setf (parameter-keyword self) (first form))) (error "~A specification must be a ~ list of two elements, not ~S" (parameter-label self) form)))) self) (defmethod ensure-parameter-keyword ((self parameter-with-keyword)) (if (parameter-keyword-p self) (parameter-keyword self) (intern (string (parameter-name self)) "KEYWORD"))) ;;;-------------------- (defclass keyword-parameter (parameter-with-keyword optional-parameter) ;; The order of the superclasses is important ;; to find the methods in the right order! () (:documentation "A keyword parameter.")) ;;;-------------------- (defclass generic-keyword-parameter (parameter-with-keyword generic-optional-parameter) ;; The order of the superclasses is important ;; to find the methods in the right order! () (:documentation "A generic keyword parameter.")) ;;;-------------------- (defgeneric parameter-label (parameter) (:method ((self parameter)) (declare (ignorable self)) "A mandatory parameter") (:method ((self environment-parameter)) (declare (ignorable self)) "An environment parameter") (:method ((self whole-parameter)) (declare (ignorable self)) "A whole parameter") (:method ((self rest-parameter)) (declare (ignorable self)) "A rest parameter") (:method ((self body-parameter)) (declare (ignorable self)) "A body parameter") (:method ((self specialized-parameter)) (declare (ignorable self)) "A specialized parameter") (:method ((self auxiliary-parameter)) (declare (ignorable self)) "An auxiliary parameter") (:method ((self optional-parameter)) (declare (ignorable self)) "An optional parameter") (:method ((self generic-optional-parameter)) (declare (ignorable self)) "A generic optional parameter") (:method ((self keyword-parameter)) (declare (ignorable self)) "A keyword parameter") (:method ((self generic-keyword-parameter)) (declare (ignorable self)) "A generic keyword parameter")) (defgeneric parameter-lambda-list-keyword (parameter) (:method ((self parameter)) (declare (ignorable self)) '&mandatory) (:method ((self environment-parameter)) (declare (ignorable self)) '&environment) (:method ((self whole-parameter)) (declare (ignorable self)) '&whole) (:method ((self rest-parameter)) (declare (ignorable self)) '&rest) (:method ((self body-parameter)) (declare (ignorable self)) '&body) (:method ((self specialized-parameter)) (declare (ignorable self)) '&specialized) (:method ((self auxiliary-parameter)) (declare (ignorable self)) '&aux) (:method ((self optional-parameter)) (declare (ignorable self)) '&optional) (:method ((self generic-optional-parameter)) (declare (ignorable self)) '&generic-optional) (:method ((self keyword-parameter)) (declare (ignorable self)) '&key) (:method ((self generic-keyword-parameter)) (declare (ignorable self)) '&generic-key)) (defgeneric parameter-specifier (parameter) (:documentation "Return a parameter specifier sexp, which can be used to build a lambda list.") (:method ((self parameter)) (parameter-name self)) (:method ((self specialized-parameter)) (cons (parameter-name self) (when (parameter-specializer-p self) (list (parameter-specializer self))))) (:method ((self auxiliary-parameter)) (if (parameter-initform-p self) (list (parameter-name self) (parameter-initform self)) (parameter-name self))) (:method ((self parameter-with-initform)) (if (parameter-initform-p self) (cons (parameter-name self) (cons (parameter-initform self) (when (parameter-indicator-p self) (list (parameter-indicator self))))) (parameter-name self))) (:method ((self parameter-with-keyword)) (if (or (parameter-keyword-p self) (parameter-initform-p self)) (cons (if (parameter-keyword-p self) (list (parameter-keyword self) (parameter-name self)) (parameter-name self)) (when (parameter-initform-p self) (cons (parameter-initform self) (when (parameter-indicator-p self) (list (parameter-indicator self)))))) (parameter-name self))) (:method ((self generic-keyword-parameter)) (if (parameter-keyword-p self) (list (list (parameter-keyword self) (parameter-name self))) (parameter-name self)))) ;;;-------------------- (defclass or-ll () ((mandatories :accessor lambda-list-mandatory-parameters :initarg :mandatory-parameters :initform '() :type list) (optionals :accessor lambda-list-optional-parameters :initarg :optional-parameters :initform '() :type list) (rest :accessor lambda-list-rest-parameter :initarg :rest-parameter :type (or null rest-parameter))) (:documentation "This class and its subclasses are mixin declaring formally the attributes for the various lambda-list classes. Semantically, some constraints may be different from one lambda-list to the other.")) (defgeneric lambda-list-mandatory-parameters-p (self) (:method ((self or-ll)) (not (not (lambda-list-mandatory-parameters self)))) (:method ((self t)) (declare (ignorable self)) nil)) (defgeneric lambda-list-optional-parameters-p (self) (:method ((self or-ll)) (not (not (lambda-list-optional-parameters self)))) (:method ((self t)) (declare (ignorable self)) nil)) (defgeneric lambda-list-rest-parameter-p (self) (:method ((self or-ll)) (slot-boundp self 'rest)) (:method ((self t)) (declare (ignorable self)) nil)) (define-default-generic lambda-list-allow-other-keys-p or-ll nil) (define-default-generic lambda-list-key-p or-ll nil) (define-default-generic lambda-list-keyword-parameters or-ll nil) (define-default-generic lambda-list-environment-parameter or-ll nil) (define-default-generic lambda-list-auxiliary-parameters or-ll nil) (define-default-generic lambda-list-whole-parameter or-ll nil) (define-default-generic lambda-list-body-parameter or-ll nil) (defclass orak-ll (or-ll) ((allow-other-keys-p :accessor lambda-list-allow-other-keys-p :initarg :allow-other-keys-p :initform nil :type boolean :documentation "Whether &ALLOW-OTHER-KEYS is present.") (key-p :accessor lambda-list-key-p :initarg :key-p :initform nil :type boolean :documentation "Whether &KEY is present.") ;; We can have &KEY &ALLOW-OTHER-KEYS without any keyword. (keys :accessor lambda-list-keyword-parameters :initarg :keyword-parameters :initform '() :type list))) (defgeneric lambda-list-keyword-parameters-p (self) (:method ((self or-ll)) (not (not (lambda-list-keyword-parameters self))))) (defclass orake-ll (orak-ll) ((environment :accessor lambda-list-environment-parameter :initarg :environment-parameter :type environment-parameter))) (defclass oraka-ll (orak-ll) ((aux :accessor lambda-list-auxiliary-parameters :initarg :auxiliary-parameters :initform '() :type list))) (defclass orakawb-ll (oraka-ll) ((whole :accessor lambda-list-whole-parameter :initarg :whole-parameter :type whole-parameter) (body :accessor lambda-list-body-parameter :accessor lambda-list-rest-parameter :initarg :body-parameter :type rest-parameter))) (defclass orakawbe-ll (orakawb-ll) ((environment :accessor lambda-list-environment-parameter :initarg :environment-parameter :type environment-parameter))) (defgeneric lambda-list-auxiliary-parameters-p (self) (:method ((self oraka-ll)) (not (not (lambda-list-auxiliary-parameters self)))) (:method ((self t)) (declare (ignorable self)) nil)) (defgeneric lambda-list-whole-parameter-p (self) (:method ((self orakawb-ll)) (slot-boundp self 'whole)) (:method ((self t)) (declare (ignorable self)) nil)) (defgeneric lambda-list-body-parameter-p (self) (:method ((self orakawb-ll)) (slot-boundp self 'body)) (:method ((self t)) (declare (ignorable self)) nil)) (defgeneric lambda-list-environment-parameter-p (self) (:method ((self orakawbe-ll)) (slot-boundp self 'environment)) (:method ((self orake-ll)) (slot-boundp self 'environment)) (:method ((self t)) (declare (ignorable self)) nil)) (defgeneric remove-environment-parameter (ll) (:method ((ll orake-ll)) (slot-makunbound ll 'environment)) (:method ((ll orakawbe-ll)) (slot-makunbound ll 'environment)) (:method ((ll t)))) (defgeneric remove-whole-parameter (ll) (:method ((ll orakawb-ll)) (slot-makunbound ll 'whole)) (:method ((ll t)))) ;;;---------------------------------------- (defclass lambda-list () ((original :accessor original-lambda-list :initarg :lambda-list :type list)) (:documentation "An abstract lambda-list.")) (defgeneric lambda-list-parameters (lambda-list) (:documentation "An ordered list of the parameters or destructuring-lambda-list instances.")) (defclass ordinary-lambda-list (lambda-list oraka-ll) ()) (defclass boa-lambda-list (lambda-list oraka-ll) ()) (defclass specialized-lambda-list (lambda-list oraka-ll) ()) (defclass modify-macro-lambda-list (lambda-list or-ll) ()) (defclass generic-lambda-list (lambda-list orak-ll) ()) (defclass macro-lambda-list (lambda-list orakawbe-ll) ()) (defclass type-lambda-list (lambda-list orakawbe-ll) ()) (defclass destructuring-lambda-list (lambda-list orakawb-ll) ()) (defclass setf-lambda-list (lambda-list orake-ll) ()) (defclass method-combination-lambda-list (lambda-list oraka-ll) ()) (defgeneric lambda-list-kind (lambda-list) (:method ((self ordinary-lambda-list)) (declare (ignorable self)) :ordinary) (:method ((self boa-lambda-list)) (declare (ignorable self)) :boa) (:method ((self specialized-lambda-list)) (declare (ignorable self)) :specialized) (:method ((self modify-macro-lambda-list)) (declare (ignorable self)) :modify-macro) (:method ((self generic-lambda-list)) (declare (ignorable self)) :generic) (:method ((self macro-lambda-list)) (declare (ignorable self)) :macro) (:method ((self type-lambda-list)) (declare (ignorable self)) :type) (:method ((self destructuring-lambda-list)) (declare (ignorable self)) :destructuring) (:method ((self setf-lambda-list)) (declare (ignorable self)) :setf) (:method ((self method-combination-lambda-list)) (declare (ignorable self)) :method-combination)) (defgeneric lambda-list-allowed-keywords (lambda-list) (:method ((self ordinary-lambda-list)) (declare (ignorable self)) '(&optional &rest &allow-other-keys &key &aux)) (:method ((self boa-lambda-list)) (declare (ignorable self)) '(&optional &rest &allow-other-keys &key &aux)) (:method ((self specialized-lambda-list)) (declare (ignorable self)) '(&optional &rest &allow-other-keys &key &aux)) (:method ((self modify-macro-lambda-list)) (declare (ignorable self)) '(&optional &rest)) (:method ((self generic-lambda-list)) (declare (ignorable self)) '(&optional &rest &allow-other-keys &key)) (:method ((self macro-lambda-list)) (declare (ignorable self)) '(&optional &rest &allow-other-keys &key &aux &whole &body &environment)) (:method ((self type-lambda-list)) (declare (ignorable self)) '(&optional &rest &allow-other-keys &key &aux &whole &body &environment)) (:method ((self destructuring-lambda-list)) (declare (ignorable self)) '(&optional &rest &allow-other-keys &key &aux &whole &body)) (:method ((self setf-lambda-list)) (declare (ignorable self)) '(&optional &rest &allow-other-keys &key &environment)) (:method ((self method-combination-lambda-list)) (declare (ignorable self)) '(&optional &rest &allow-other-keys &key &aux &whole))) (defmethod lambda-list-mandatory-parameter-count ((self or-ll)) "RETURN: The number of mandatory parameters." (length (lambda-list-mandatory-parameters self))) (defmethod lambda-list-optional-parameter-count ((self or-ll)) "RETURN: The number of optional parameters." (length (lambda-list-mandatory-parameters self))) (defgeneric lambda-list-rest-p (self) (:documentation "RETURN: Whether &REST or &BODY parameters are present.") (:method ((self or-ll)) (lambda-list-rest-parameter-p self)) (:method ((self orakawb-ll)) (or (lambda-list-rest-parameter-p self) (lambda-list-body-parameter-p self)))) ;; auxvars ::= [&aux {var | (var [init-form])}*] ;; optvars ::= [&optional {var | (var [init-form [supplied-p-parameter]])}*] ;; goptvars ::= [&optional {var | (var)}*] (defmethod parse-optvars ((self or-ll) current slot lambda-list-keyword class) " DO: Parses optional parameters. RETURN: The remaining tokens. " (when (eq (car current) lambda-list-keyword) (pop current) (setf (slot-value self slot) (loop :while (and current (not (member (car current) lambda-list-keywords))) :collect (parse-parameter (make-instance class) (pop current))))) current) (defmethod auxvars ((self or-ll) current) (parse-optvars self current 'aux '&aux 'auxiliary-parameter)) (defmethod optvars ((self or-ll) current) (parse-optvars self current 'optionals '&optional 'optional-parameter)) (defmethod goptvars ((self or-ll) current) (parse-optvars self current 'optionals '&optional 'generic-optional-parameter)) ;; keyvars ::= [&key {var | ({var | (keyword-name var)} [init-form [supplied-p-parameter]])}* [&allow-other-keys]] ;; gkeyvars ::= [&key {var | ({var | (keyword-name var)})}* [&allow-other-keys]]) (defmethod parse-keyvars ((self orak-ll) current class) " DO: Parses keywork parameters. RETURN: The remaining tokens. " (when (eq '&key (car current)) (pop current) (setf (lambda-list-key-p self) t (lambda-list-keyword-parameters self) (loop :while (and current (not (member (car current) lambda-list-keywords))) :collect (parse-parameter (make-instance class) (pop current))) (lambda-list-allow-other-keys-p self) (and (eq '&allow-other-keys (car current)) (pop current) t))) current) (defmethod keyvars ((self orak-ll) current) (parse-keyvars self current 'keyword-parameter)) (defmethod gkeyvars ((self orak-ll) current) (parse-keyvars self current 'generic-keyword-parameter)) ;; reqvars ::= var* ;; sreqvars ::= {var | (var [specializer])}* ;; preqvars ::= {var | destructuring-lambda-list}* (defmethod parse-reqvars ((self or-ll) current class) " DO: Parses required parameters. RETURN: (values list-of-parameters following) " (setf (lambda-list-mandatory-parameters self) (loop :while (and current (not (member (car current) lambda-list-keywords))) :collect (parse-parameter (make-instance class) (pop current)))) current) (defmethod reqvars ((self or-ll) current) (parse-reqvars self current 'parameter)) (defmethod sreqvars ((self or-ll) current) (parse-reqvars self current 'specialized-parameter)) (defmethod preqvars ((self or-ll) current) " DO: Parses required parameters or patterns. RETURN: (values list-of-parameters following) " (setf (lambda-list-mandatory-parameters self) (loop :while (and current (not (member (car current) lambda-list-keywords))) :collect (if (consp (car current)) (parse-original-lambda-list (make-instance 'destructuring-lambda-list :lambda-list (pop current))) (parse-parameter (make-instance 'parameter) (pop current))))) current) ;; bodyvar ::= [{&rest | &body} var] ;; restvar ::= [&rest var] ;; wholevar ::= [&whole var] ;; envvar ::= [&environment var] (defun bodyvar (self current) " RETURN: (values parameter following) " (flet ((check-duplicate (lambda-list-keyword) (when (lambda-list-rest-p self) (error "~:[&BODY~;&REST~] parameter already given before ~A in ~S" (lambda-list-rest-parameter-p self) lambda-list-keyword (original-lambda-list self))))) (case (car current) ((&rest) (check-duplicate (pop current)) (setf (lambda-list-rest-parameter self) (parse-parameter (make-instance 'rest-parameter) (pop current)))) ((&body) (check-duplicate (pop current)) (setf (lambda-list-body-parameter self) (parse-parameter (make-instance 'body-parameter) (pop current))))) current)) (defun parse-var (self current slot lambda-list-keyword class ) " RETURN: (values parameter following) " (when (eq (car current) lambda-list-keyword) (pop current) (when (slot-boundp self slot) (error "~A parameter duplicated in ~S" lambda-list-keyword (original-lambda-list self))) (setf (slot-value self slot) (parse-parameter (make-instance class) (pop current)))) current) (defun restvar (self current) (parse-var self current 'rest '&rest 'rest-parameter)) (defun wholevar (self current) (parse-var self current 'whole '&whole 'whole-parameter)) (defun envvar (self current) (parse-var self current 'environment '&environment 'environment-parameter)) ;; macro-lambda-list ::= (wholevar envvar preqvars envvar optvars envvar ;; bodyvar envvar keyvars envvar auxvars envvar) ;; | (wholevar envvar preqvars envvar optvars envvar . var) ;; ;; destructuring-lambda-list ::= (wholevar preqvars optvars bodyvar keyvars auxvars) ;; | (wholevar preqvars optvars . var) ;; ;; type-lambda-list ::= macro-lambda-list ;; ;; ;; ordinary-lambda-list ::= (reqvars optvars restvar keyvars auxvars) ;; boa-lambda-list ::= ordinary-lambda-list ;; specialized-lambda-list ::= (sreqvars optvars restvar keyvars auxvars) ;; generic-lambda-list ::= (reqvars goptvars restvar gkeyvars) ;; setf-lambda-list ::= (reqvars optvars restvar keyvars envvar) ;; modify-macro-lambda-list ::= (reqvars optvars restvar) ;; method-combination-lambda-list ::= (wholevar reqvars optvars restvar keyvars auxvars) (defun parse-rest (self current syntax) (if (listp current) (dolist (fun syntax current) (setf current (funcall fun self current))) (restvar self (list '&rest current)))) (defun destructuring-rest (self current) (parse-rest self current '(bodyvar keyvars auxvars))) (defun macro-rest (self current) (parse-rest self current '(bodyvar envvar keyvars envvar auxvars envvar))) (defgeneric lambda-list-syntax (self) (:method ((self ordinary-lambda-list)) (declare (ignorable self)) '(reqvars optvars restvar keyvars auxvars)) (:method ((self boa-lambda-list)) (declare (ignorable self)) '(reqvars optvars restvar keyvars auxvars)) (:method ((self specialized-lambda-list)) (declare (ignorable self)) '(sreqvars optvars restvar keyvars auxvars)) (:method ((self generic-lambda-list)) (declare (ignorable self)) '(reqvars goptvars restvar gkeyvars)) (:method ((self setf-lambda-list)) (declare (ignorable self)) '(reqvars optvars restvar keyvars envvar)) (:method ((self modify-macro-lambda-list)) (declare (ignorable self)) '(reqvars optvars restvar)) (:method ((self method-combination-lambda-list)) (declare (ignorable self)) '(wholevar reqvars optvars restvar keyvars auxvars)) (:method ((self macro-lambda-list)) (declare (ignorable self)) '(wholevar envvar preqvars envvar optvars envvar macro-rest)) (:method ((self type-lambda-list)) (declare (ignorable self)) '(wholevar envvar preqvars envvar optvars envvar macro-rest)) (:method ((self destructuring-lambda-list)) (declare (ignorable self)) '(wholevar preqvars optvars destructuring-rest))) (defmethod parse-original-lambda-list ((self lambda-list)) (let ((current (original-lambda-list self))) (dolist (fun (lambda-list-syntax self)) (setf current (funcall fun self current))) (when current (error "Syntax error in ~(~A~) at: ~S~%in ~S" (class-name (class-of self)) current (original-lambda-list self))) self)) (defun parse-lambda-list (lambda-list &optional (kind :ordinary)) " DO: Parse a lambda-list of the specified kind. KIND: (MEMBER :ORDINARY :BOA :SPECIALIZED :MODIFY-MACRO :GENERIC :MACRO :TYPE :DESTRUCTURING :SETF :METHOD-COMBINATION) RETURN: A lambda-list instance. NOTE: In the case of :macro, :destructuring lambda lists, some parameter lists may further contain destructuring-lambda-list instances instead of lambda-list-parameter instances. " (parse-original-lambda-list (make-instance (or (cdr (assoc kind '((:ordinary . ordinary-lambda-list) (:boa . boa-lambda-list) (:specialized . specialized-lambda-list) (:modify-macro . modify-macro-lambda-list) (:generic . generic-lambda-list) (:macro . macro-lambda-list) (:type . type-lambda-list) (:destructuring . destructuring-lambda-list) (:setf . setf-lambda-list) (:method-combination . method-combination-lambda-list)))) (error "Invalid lambda-list kind ~S" kind)) :lambda-list lambda-list))) ;;------------------------------------------------------------------------ (defgeneric parameter-help-label (self) (:method ((self parameter)) (format nil "~A" (parameter-name self))) (:method ((self optional-parameter)) (format nil "[~A]" (parameter-name self))) (:method ((self rest-parameter)) (format nil "~A..." (parameter-name self))) (:method ((self body-parameter)) (format nil "~A..." (parameter-name self))) (:method ((self keyword-parameter)) (format nil "~A" (ensure-parameter-keyword self)))) (defmethod make-help ((self lambda-list)) " RETURN: A list describing the lambda-list for the user. Each item is a cons: (lambda-list-keyword . description) where - the lambda-list-keyword is either :mandatory, :optional, :rest, :body, :key, or :allow-other-keys. - the description is a string indicating the name of the parameter, and whether it's optional '[n]' or takes several arguments 'n...'. " (append ;; mandatory: (mapcar (lambda (par) (cons :mandatory (parameter-help-label par))) (lambda-list-mandatory-parameters self)) ;; optional: (mapcar (lambda (par) (cons :optional (parameter-help-label par))) (lambda-list-optional-parameters self)) (when (lambda-list-rest-parameter-p self) (list (cons :rest (parameter-help-label (lambda-list-rest-parameter self))))) (when (lambda-list-body-parameter-p self) (list (cons :body (parameter-help-label (lambda-list-body-parameter self))))) ;; keywords: (mapcar (lambda (par) (cons :key (parameter-help-label par))) (lambda-list-keyword-parameters self)) (when (lambda-list-allow-other-keys-p self) (list (cons :allow-other-keys "(other keys allowed)"))))) (defmethod make-argument-list ((self lambda-list)) " RETURN: A list of arguments taken from the parameters usable with apply to call a function with the same lambda-list. NOTE: If no there is no &rest parameter in the lambda-list, then a NIL is put at the end of the result, for APPLY. EXAMPLE: `(apply ,@(make-argument-list ll)) " (let ((rest (lambda-list-rest-p self))) (append (mapcar (function parameter-name) (lambda-list-mandatory-parameters self)) (mapcar (function parameter-name) (lambda-list-optional-parameters self)) (when (lambda-list-key-p self) (mapcan (lambda (par) (list (ensure-parameter-keyword par) (parameter-name par))) (lambda-list-keyword-parameters self))) (list (if rest (parameter-name (lambda-list-rest-parameter self)) '()))))) (defgeneric parameters-by-category (ll) (:method ((self lambda-list)) (flet ((destructp (parameter) (typep parameter 'destructuring-lambda-list))) (let* ((mandatories (lambda-list-mandatory-parameters self)) (destructs (remove-if-not (function destructp) mandatories)) (desman '()) (desopt '()) (desres '()) (deskey '())) (dolist (destruct destructs) (multiple-value-bind (man opt res key) (parameters-by-category destruct) (setf desman (nconc desman man) desopt (nconc desopt opt) desres (nconc desres res) deskey (nconc deskey key)))) (values (append (remove-if (function destructp) mandatories) desman) (append (lambda-list-optional-parameters self) desopt) (append (when (lambda-list-rest-p self) (list (lambda-list-rest-parameter self))) desres) (append (when (lambda-list-key-p self) (lambda-list-keyword-parameters self)) deskey)))))) (defmethod make-flat-argument-list ((self lambda-list)) " RETURN: A list of arguments taken from the parameters usable with apply to call a function with the same lambda-list. NOTE: If no there is no &rest parameter in the lambda-list, then a NIL is put at the end of the result, for APPLY. NOTE: If the lambda-list is a macro-lambda-list or a destructuring-lambda-list, some of the mandatory parameters may be sub- destructuring-lambda-lists (and recursively). The arguments collected from those sub- lambda lists are appended after each sublist (mandatories, optionals, keywords, and rests). " (multiple-value-bind (man opt res key) (parameters-by-category self) (append (mapcar (function parameter-name) man) (mapcar (function parameter-name) opt) (mapcan (lambda (par) (list (ensure-parameter-keyword par) (parameter-name par))) key) (mapcar (function parameter-name) res)))) ;;;; MAKE-ARGUMENT-LIST-FORM ;; +------+--------+-----+---------+ ;; | rest | k-wo-i | aok | all-opt | ;; +------+--------+-----+---------+ ;; | no | no | no | <=> there is some keyword ;; | no | no | yes | <=> there is some keyword ; we can't know the other keywords! ;; | no | yes | no | yes ;; | no | yes | yes | yes ; we can't know the other keywords! ;; | yes | no | no | <=> there is some keyword <=> (not (null rest)) ;; | yes | no | yes | <=> there is some keyword <=> (not (null rest)) ;; | yes | yes | no | yes ;; | yes | yes | yes | yes ;; +------+--------+-----+---------+ (defmethod make-argument-list-form ((self lambda-list)) " RETURN: A form that will build a list of arguments passing the same arguments given to lambda-list, to be passed to APPLY. NOTE: If optional or key arguments have an indicator, then they're not passed unless necessary or the indicator is true. BUG: We don't handle MACRO-LAMBDA-LISTs nor DESTRUCTURING-LAMBDA-LISTs, etc. " (flet ((genopt () (loop :with result = '() :with pars = (reverse (lambda-list-optional-parameters self)) :for par = (pop pars) :while (and par (parameter-indicator-p par)) :do (push `(when ,(parameter-indicator par) (list ,(parameter-name par))) result) :finally (return `(,@(when (or par pars) `((list ,@(nreverse (mapcar (function parameter-name) (if par (cons par pars) pars)))))) ,@result))))) (let* ((rest (cond ((lambda-list-rest-parameter-p self) (lambda-list-rest-parameter self)) ((lambda-list-body-parameter-p self) (lambda-list-body-parameter self)))) (form `(append ,@(if (not (every (function parameter-indicator-p) (lambda-list-keyword-parameters self))) ;; If some keyword parameter has no indicator, ;; we will be forced to pass it again as argument, ;; therefore we must pass all optional argumentst too. `( (list ,@(mapcar (function parameter-name) (lambda-list-mandatory-parameters self)) ,@(mapcar (function parameter-name) (lambda-list-optional-parameters self)))) `( (list ,@(mapcar (function parameter-name) (lambda-list-mandatory-parameters self))) ,@(if (not (or rest (lambda-list-keyword-parameters self))) (genopt) `((if ,(if rest (parameter-name rest) `(or ,@(mapcar (function parameter-indicator) (lambda-list-keyword-parameters self)))) (list ,@(mapcar (function parameter-name) (lambda-list-optional-parameters self))) ,(let ((subforms (genopt))) (cond ((null subforms) '()) ((cdr subforms) `(append ,@subforms)) (t (car subforms))))))))) ,@(if rest ;; When we have a rest (or body) parameter, we don't need ;; to generate the keyword parameters, since they're ;; covered by the rest. We just append the rest to the ;; list of arguments. `(,(parameter-name rest)) ;; Without a rest (or body) parameter, we need to pass ;; the keyword arguments. (mapcar (lambda (parameter) (if (parameter-indicator-p parameter) ;; If we have an indicator parameter, ;; we pass the keyword argument ;; only when we got it. `(when ,(parameter-indicator parameter) (list ,(ensure-parameter-keyword parameter) ,(parameter-name parameter))) ;; otherwise we pass the keyword argument ;; unconditionnaly: `(list ,(ensure-parameter-keyword parameter) ,(parameter-name parameter)))) (lambda-list-keyword-parameters self)))))) (if (= 2 (length form)) (second form) form)))) (defmethod parameter-specifier ((parameter destructuring-lambda-list)) " NOTE: DESTRUCTURING-LAMBDA-LIST instances may appear in parameter lists. Therefore we need to build the parameter-specifier sexp for them. " (make-lambda-list parameter)) (defmethod make-lambda-list ((self lambda-list)) " RETURN: A newly rebuilt lambda-list s-expr. " (append (when (lambda-list-whole-parameter-p self) (list '&whole (parameter-specifier (lambda-list-whole-parameter self)))) (when (lambda-list-environment-parameter-p self) (list '&environment (parameter-specifier (lambda-list-environment-parameter self)))) (mapcar (function parameter-specifier) (lambda-list-mandatory-parameters self)) (when (lambda-list-optional-parameters self) (cons '&optional (mapcar (function parameter-specifier) (lambda-list-optional-parameters self)))) (when (lambda-list-body-parameter-p self) (list '&body (parameter-specifier (lambda-list-body-parameter self)))) (when (lambda-list-rest-parameter-p self) (list '&rest (parameter-specifier (lambda-list-rest-parameter self)))) (when (lambda-list-key-p self) '(&key)) (when (lambda-list-keyword-parameters self) (mapcar (function parameter-specifier) (lambda-list-keyword-parameters self))) (when (lambda-list-allow-other-keys-p self) '(&allow-other-keys)) (when (lambda-list-auxiliary-parameters self) (cons '&aux (mapcar (function parameter-specifier) (lambda-list-auxiliary-parameters self)))))) (defmethod lambda-list-parameters ((self lambda-list)) "RETURN: a list of all the parameters in the lambda-list." (append (when (lambda-list-whole-parameter-p self) (list (lambda-list-whole-parameter self))) (when (lambda-list-environment-parameter-p self) (list (lambda-list-environment-parameter self))) (lambda-list-mandatory-parameters self) (when (lambda-list-optional-parameters self) (lambda-list-optional-parameters self)) (when (lambda-list-body-parameter-p self) (list (lambda-list-body-parameter self))) (when (lambda-list-rest-parameter-p self) (list (lambda-list-rest-parameter self))) (when (lambda-list-keyword-parameters self) (lambda-list-keyword-parameters self)) (when (lambda-list-auxiliary-parameters self) (lambda-list-auxiliary-parameters self)))) (defmethod make-parameter-list ((self lambda-list)) (loop :for parameter :in (lambda-list-parameters self) :nconc (parameter-parameter-list parameter))) (defmethod parameter-parameter-list ((parameter destructuring-lambda-list)) (make-parameter-list parameter)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; (defmacro m (&environment env &whole whole ;; ((a b) (c (d e)) &optional (o t op)) ;; e f &body g &key k1 k2) ;; (print (list env whole a b c d e o op e f g k1 k2)) nil) ;; ;; (m ((1 2) (3 (4 5))) 6 7 :k1 (print c) :k2 (print d)) ;; ;; (#(NIL NIL) ;; (M ((1 2) (3 (4 5))) 6 7 :K1 (PRINT C) :K2 (PRINT D)) ;; 1 2 3 4 6 T NIL 6 7 ;; (:K1 (PRINT C) :K2 (PRINT D)) ;; (PRINT C) ;; (PRINT D)) ;; (make-help-from-split-lambda-list ;; (split-lambda-list-on-keywords ;; '(m1 m2 m3 &optional o1 o2 o3 &rest r1 &key k1 k2 k3 &aux a1 a2 a3 ;; &allow-other-keys) ;; :ordinary)) ;;'(m1 m2 m3 &optional o1 o2 o3 &rest r1 &key k1 k2 k3 &aux a1 a2 a3 &allow-other-keys) (eval-when (:compile-toplevel :load-toplevel :execute) (defun declarationp (form) (and (consp form) (eq 'declare (first form)))) (define-condition simple-program-error (program-error simple-error) ()) (defun parse-body (where body) " WHERE: (member :lambda :locally :progn) specifies where the body is found, that is whether it may contains docstrings and declarations, or just declarations, or none. BODY: A list of forms. RETURN: Three values: a list containing one docstring or nil, a list of declarations, a list of forms. " (flet ((progn-body (body) (if (some (lambda (form) (and (consp form) (eq 'declare (first form)))) body) (error 'simple-program-error :format-control "Found a declaration in the a progn body: ~S" :format-arguments (list body)) body))) (ecase where ((:lambda) ;; {declaration} [docstring declaration {declaration}] {form} ;; {declaration} [docstring] form {form} (loop :with docstring = nil :with declarations = '() :with actual-body = '() :with state = :opt-decl :for form :in body :do (ecase state (:opt-decl (cond ((declarationp form) (push form declarations)) ((stringp form) (setf docstring form state :seen-string)) (t (push form actual-body) (setf state :body)))) ((:seen-string :after-decl) (if (declarationp form) (progn (push form declarations) (setf state :after-decl)) (progn (push form actual-body) (setf state :body)))) (:body (if (declarationp form) (error 'simple-program-error :format-control "Found a declaration ~S in the body: ~S" :format-arguments (list form body)) (push form actual-body)))) :finally (flet ((ensure-list (object) (if (listp object) object (list object)))) (return (ecase state (:opt-decl (values (ensure-list docstring) declarations (nreverse actual-body))) (:seen-string (if actual-body (values (ensure-list docstring) declarations (nreverse actual-body)) (values nil declarations (list docstring)))) ((:after-decl :body) (values (ensure-list docstring) declarations (nreverse actual-body)))))))) ((:locally) ;; {declaration} {form} (loop :for current :on body :for form = (car current) :while (declarationp form) :collect form :into declarations :finally (return (values nil declarations (progn-body current))))) ((:progn) ;; {form} (values nil nil (progn-body body)))))) (defun extract-documentation (body) " RETURN: The documentation string found in BODY, or NIL if none is present. CLHS: 3.4.11 Syntactic Interaction of Documentation Strings and Declarations In a number of situations, a documentation string can appear amidst a series of declare expressions prior to a series of forms. In that case, if a string S appears where a documentation string is permissible and is not followed by either a declare expression or a form then S is taken to be a form; otherwise, S is taken as a documentation string. The consequences are unspecified if more than one such documentation string is present. NOTE: This parses the body as a lambda body. It's better to use PARSE-BODY directly. " (values (first (parse-body :lambda body)))) (defun extract-declarations (body &optional (allow-docstring t)) " RETURN: The list of declaration forms. NOTE: This parses the body as a lambda body. It's better to use PARSE-BODY directly. " (nth-value 1 (parse-body (if allow-docstring :lambda :locally) body))) (defun extract-body (body) " RETURN: The list of body forms. NOTE: This parses the body as a lambda body. It's better to use PARSE-BODY directly. " (nth-value 2 (parse-body :lambda body))) (defun declarations-hash-table (declarations) ;; Todo: add some knowledge on how declarations merge. (loop :with table = (make-hash-table) :for decl :in declarations :do (loop :for (key . value) :in (rest decl) :do (push value (gethash key table '()))) :finally (return table)))) (defun extract-method-qualifiers (method-stuff) (loop :for item :in method-stuff :until (listp item) :collect item)) (defun extract-method-lambda-list (method-stuff) (loop :for item :in method-stuff :until (listp item) :finally (return item))) (defun extract-method-ddl (method-stuff) (loop :for (item . body) :in method-stuff :until (listp item) :finally (return body))) (defun extract-method-documentation (method-stuff) (extract-documentation (extract-method-ddl method-stuff))) (defun extract-method-declarations (method-stuff) (extract-declarations (extract-method-ddl method-stuff))) (defun extract-method-body (method-stuff) (extract-body (extract-method-ddl method-stuff))) ;; (eval-when (:compile-toplevel :load-toplevel :execute) ;; (shadow '(DEFUN DEFGENERIC DEFMETHOD))) ;; ;; ;; (defparameter *call-stack* '()) ;; ;; ;; (cl:defmacro defun (name args &body body) ;; (let ((lambda-list (parse-lambda-list args :ordinary)) ;; (docu (extract-documentation body)) ;; (decl (extract-declarations body)) ;; (body (extract-body body))) ;; `(cl:defun ,name ,args ;; ,@(when docu (list docu)) ;; ,@decl ;; (push (list ',name ,@(make-argument-list lambda-list)) *call-stack*) ;; (multiple-value-prog1 (progn ,@body) ;; (pop *call-stack*))))) ;; ;; ;; (cl:defmacro defmethod (name &rest stuff) ;; (let* ((qualifiers (extract-method-qualifiers stuff)) ;; (args (extract-method-lambda-list stuff)) ;; (lambda-list (parse-lambda-list args :specialized)) ;; (docu (extract-method-documentation stuff)) ;; (decl (extract-method-declarations stuff)) ;; (body (extract-method-body stuff))) ;; `(cl:defmethod ;; ,name ,@qualifiers ,args ;; ,@(when docu (list docu)) ;; ,@decl ;; (push (list ',name ,@(make-argument-list lambda-list)) *call-stack*) ;; (multiple-value-prog1 (progn ,@body) ;; (pop *call-stack*))))) ;; ;; (cl:defmacro defgeneric (name args &rest options-and-methods) ;; `(cl:defgeneric ,name ,args ;; ,@(mapcar ;; (lambda (item) ;; (if (and (consp item) (eq :method (car item))) ;; (let* ((stuff (rest item)) ;; (qualifiers (extract-method-qualifiers stuff)) ;; (args (extract-method-lambda-list stuff)) ;; (lambda-list (parse-lambda-list args :specialized)) ;; (docu (extract-method-documentation stuff)) ;; (decl (extract-method-declarations stuff)) ;; (body (extract-method-body stuff))) ;; `(:method ,@qualifiers ,args ;; ,@(when docu (list docu)) ;; ,@decl ;; (push (list ',name ,@(make-argument-list lambda-list)) ;; *call-stack*) ;; (multiple-value-prog1 (progn ,@body) ;; (pop *call-stack*)))) ;; item)) ;; options-and-methods))) ;;;; THE END ;;;;
59,782
Common Lisp
.lisp
1,246
40
116
0.608147
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
9d71bdb01a2097cbf58db108506e2e96fcf57a25378d5805a0f1ba823b611690
5,030
[ -1 ]
5,031
com.informatimago.common-lisp.lisp-sexp.asd
informatimago_lisp/common-lisp/lisp-sexp/com.informatimago.common-lisp.lisp-sexp.asd
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: com.informatimago.common-lisp.lisp-sexp.asd ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; ASD file to load the com.informatimago.common-lisp.lisp-sexp library. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2010-10-31 <PJB> Created this .asd file. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2010 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see http://www.gnu.org/licenses/ ;;;;************************************************************************** (asdf:defsystem "com.informatimago.common-lisp.lisp-sexp" ;; system attributes: :description "Informatimago Common Lisp S-expressions Tools" :author "Pascal J. Bourguignon <[email protected]>" :maintainer "Pascal J. Bourguignon <[email protected]>" :licence "AGPL3" ;; component attributes: :version "1.4.0" :properties ((#:author-email . "[email protected]") (#:date . "Autumn 2010") ((#:albert #:output-dir) . "/tmp/documentation/com.informatimago.common-lisp.lisp-sexp/") ((#:albert #:formats) . ("docbook")) ((#:albert #:docbook #:template) . "book") ((#:albert #:docbook #:bgcolor) . "white") ((#:albert #:docbook #:textcolor) . "black")) #+asdf-unicode :encoding #+asdf-unicode :utf-8 :depends-on () :components ((:file "source-form" :depends-on ())) #+adsf3 :in-order-to #+adsf3 ((asdf:test-op (asdf:test-op "com.informatimago.common-lisp.lisp-sexp.test")))) ;;;; THE END ;;;;
2,504
Common Lisp
.lisp
53
44.056604
113
0.587995
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
b4cd06f25b2ed7803b621398688873bdb3304cd832d5507f20e34b4719e70b17
5,031
[ -1 ]
5,032
com.informatimago.common-lisp.lisp-sexp.test.asd
informatimago_lisp/common-lisp/lisp-sexp/com.informatimago.common-lisp.lisp-sexp.test.asd
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;*************************************************************************** ;;;;FILE: com.informatimago.common-lisp.lisp-sexp.test.asd ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: None ;;;;USER-INTERFACE: None ;;;;DESCRIPTION: ;;;; ;;;; This file defines the com.informatimago.common-lisp.lisp-sexp.test system. ;;;; Tests the com.informatimago.common-lisp.lisp-sexp system. ;;;; ;;;;USAGE: ;;;; ;;;;AUTHORS: ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS: ;;;; 2015-02-23 <PJB> Created. ;;;;BUGS: ;;;; ;;;;LEGAL: ;;;; ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;; ;;;;*************************************************************************** (asdf:defsystem "com.informatimago.common-lisp.lisp-sexp.test" ;; system attributes: :description "Tests the com.informatimago.common-lisp.lisp-sexp system." :author "Pascal J. Bourguignon <[email protected]>" :maintainer "Pascal J. Bourguignon <[email protected]>" :licence "AGPL3" ;; component attributes: :version "1.2.0" :properties ((#:author-email . "[email protected]") (#:date . "Winter 2015") ((#:albert #:output-dir) . "/tmp/documentation/com.informatimago.common-lisp.lisp-sexp.test/") ((#:albert #:formats) "docbook") ((#:albert #:docbook #:template) . "book") ((#:albert #:docbook #:bgcolor) . "white") ((#:albert #:docbook #:textcolor) . "black")) #+asdf-unicode :encoding #+asdf-unicode :utf-8 :depends-on ("com.informatimago.common-lisp.cesarum" "com.informatimago.common-lisp.lisp-sexp") :components ((:file "source-form-test" :depends-on nil)) #+asdf3 :perform #+asdf3 (asdf:test-op (operation system) (declare (ignore operation system)) (let ((*package* (find-package "COM.INFORMATIMAGO.COMMON-LISP.LISP-SEXP.SOURCE-FORM.TEST"))) (uiop:symbol-call "COM.INFORMATIMAGO.COMMON-LISP.LISP-SEXP.SOURCE-FORM.TEST" "TEST/ALL")))) ;;;; THE END ;;;;
3,078
Common Lisp
.lisp
66
40.348485
120
0.566777
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
5b0e875741b5284923dfe77ab1f44107bb3b66cc977b78711ff67f35d756fbfb
5,032
[ -1 ]
5,033
source-form-test.lisp
informatimago_lisp/common-lisp/lisp-sexp/source-form-test.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: source-form-test.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Tests source-form.lisp ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2015-02-25 <PJB> Extracted from source-form.lisp ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.LISP-SEXP.SOURCE-FORM.TEST" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SIMPLE-TEST" "COM.INFORMATIMAGO.COMMON-LISP.LISP-SEXP.SOURCE-FORM") (:export "TEST/ALL")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.LISP-SEXP.SOURCE-FORM.TEST") (define-test test/parse-body () (flet ((test/lambda (body expect-error-p docstring declarations forms) (handler-case (multiple-value-bind (doc dec for) (parse-body :lambda body) (assert-true (not expect-error-p)) (assert-true (equalp (first doc) docstring)) (assert-true (equalp dec declarations)) (assert-true (equalp for forms))) (program-error () (assert-true expect-error-p)))) (test/locally (body expect-error-p declarations forms) (handler-case (multiple-value-bind (doc dec for) (parse-body :locally body) (assert-true (not expect-error-p)) (assert-true (null doc)) (assert-true (equalp dec declarations)) (assert-true (equalp for forms)) (assert-true (equalp (append dec for) body))) (program-error () (assert-true expect-error-p)))) (test/progn (body expect-error-p forms) (handler-case (multiple-value-bind (doc dec for) (parse-body :progn body) (assert-true (not expect-error-p)) (assert-true (null doc)) (assert-true (null dec)) (assert-true (equalp for forms)) (assert-true (equalp for body))) (program-error () (assert-true expect-error-p)))) (test/extract (body rlambda rlocally) (destructuring-bind (expect-error-p docstring declarations forms) rlambda (handler-case (let ((doc (extract-documentation body)) (dec (extract-declarations body t)) (for (extract-body body))) (assert-true (not expect-error-p)) (assert-true (equalp doc docstring)) (assert-true (equalp dec declarations)) (assert-true (equalp for forms))) (program-error () (assert-true expect-error-p)))) (destructuring-bind (expect-error-p declarations forms) rlocally (declare (ignore forms)) (handler-case (let ((dec (extract-declarations body nil))) (assert-true (not expect-error-p)) (assert-true (equalp dec declarations))) (program-error () (assert-true expect-error-p)))))) (let ((test-cases '((() (nil nil () ()) (nil () ()) (nil ())) (("Result") (nil nil () ("Result")) (nil () ("Result")) (nil ("Result"))) (("Doc" "Result") (nil "Doc" () ("Result")) (nil () ("Doc" "Result")) (nil ("Doc" "Result"))) (((declare (ignore it))) (nil nil ((declare (ignore it))) ()) (nil ((declare (ignore it))) ()) (t nil)) (((declare (ignore it)) "Result") (nil nil ((declare (ignore it))) ("Result")) (nil ((declare (ignore it))) ("Result")) (t nil)) (((declare (ignore it)) "Doc" "Result") (nil "Doc" ((declare (ignore it))) ("Result")) (nil ((declare (ignore it))) ("Doc" "Result")) (t nil)) (((declare (ignore it)) (declare (ignore it))) (nil nil ((declare (ignore it)) (declare (ignore it))) ()) (nil ((declare (ignore it)) (declare (ignore it))) ()) (t nil)) (((declare (ignore it)) (declare (ignore it)) "Result") (nil nil ((declare (ignore it)) (declare (ignore it))) ("Result")) (nil ((declare (ignore it)) (declare (ignore it))) ("Result")) (t nil)) (((declare (ignore it)) "Doc" (declare (ignore it))) (nil "Doc" ((declare (ignore it)) (declare (ignore it))) ()) (t nil nil) (t nil)) (((declare (ignore it)) (declare (ignore it)) "Doc" "Result") (nil "Doc" ((declare (ignore it)) (declare (ignore it))) ("Result")) (nil ((declare (ignore it)) (declare (ignore it))) ("Doc" "Result")) (t nil)) (((declare (ignore it)) "Doc" (declare (ignore it)) "Result") (nil "Doc" ((declare (ignore it)) (declare (ignore it))) ("Result")) (t nil nil) (t nil)) (((declare (ignore it)) "Doc" "Illegal" (declare (ignore it)) "Result") (t nil nil nil) (t nil nil) (t nil)) (("Doc" (declare (ignore it)) "Result") (nil "Doc" ((declare (ignore it))) ("Result")) (t nil nil) (t nil)) (("Doc" (declare (ignore it)) (declare (ignore it))) (nil "Doc" ((declare (ignore it)) (declare (ignore it))) ()) (t nil nil) (t nil)) (("Doc" (declare (ignore it)) (declare (ignore it)) "Result") (nil "Doc" ((declare (ignore it)) (declare (ignore it))) ("Result")) (t nil nil) (t nil)) (("Doc" (declare (ignore it)) "Illegal" (declare (ignore it)) "Result") (t nil nil nil) (t nil nil) (t nil))))) (loop :for (test rlambda rlocally rprogn) :in test-cases :do (apply (function test/lambda) test rlambda) (apply (function test/locally) test rlocally) (apply (function test/progn) test rprogn) (test/extract test rlambda rlocally))))) (define-test test/all () (test/parse-body)) ;;;; THE END ;;;;
8,325
Common Lisp
.lisp
159
41.188679
88
0.464592
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
1f598ff10612454fadaeda852de61207222d4a954122e87283db3699b4aa41f3
5,033
[ -1 ]
5,034
algebra.lisp
informatimago_lisp/common-lisp/arithmetic/algebra.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: algebra.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; This packages exports some simple algebra functions. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2021-06-16 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2021 - 2021 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.ARITHMETIC.ALGEBRA" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY" "COM.INFORMATIMAGO.COMMON-LISP.ARITHMETIC.PRIMES") (:export ;; Some arithmetic: "SQUARE" "SQUARE-ROOT" "CUBE" "CUBE-ROOT" "DIVIDES" ;; Some Algebra: "EQUA2" "CARDANO" "SOLVE-POLYNOMIAL-EQUATION") (:documentation "Some simple algebra functions. ;; 4x+1=0 (solve-polynomial-equation #(1 4)) --> (-1/4) ;; 2x²+4x+1=0 (solve-polynomial-equation #(1 4 2)) --> (-0.29289323 -1.7071068) ; ((/ (+ -4 (* 2 (sqrt 2))) 4) (/ (- -4 (* 2 (sqrt 2))) 4)) ;; 3x³+2x²+4x+1=0 (solve-polynomial-equation #(1 4 2 3)) --> (#C(0.70890605 0.56626135) #C(-0.19738963 -0.043011278) #C(-1.1781831 -0.5232501)) ;; x³-10x²+31x-30=0 (solve-polynomial-equation #(-30 31 -10 1)) --> (#C(5.0 0.0) #C(2.0 0.0) #C(3.0 -0.0)) ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.ARITHMETIC.ALGEBRA") (defun ratiop (x) (typep x 'ratio)) (defun square (x) (* x x)) (defun cube (x) (* x x x)) (defun divides (d n) (zerop (mod n d))) (defun square-root (n) (if (zerop n) 0 (typecase n (ratio `(/ ,(square-root (numerator n)) ,(square-root (denominator n)))) (integer (let* ((factors (factorize (abs n))) (root (loop with primes = 1 with squares = 1 for term in (rest factors) do (cond ((atom term) (setf primes (* primes term))) ((evenp (third term)) (setf squares (* squares (expt (second term) (/ (third term) 2))))) (t (setf primes (* primes (second term)) squares (* squares (expt (second term) (/ (- (third term) 1) 2)))))) finally (return (if (= 1 squares) (if (= 1 primes) 1 `(sqrt ,primes)) (if (= 1 primes) squares `(* ,squares (sqrt ,primes)))))))) (if (minusp n) (if (eql 1 root) 'i `(* i ,root)) root))) (number (sqrt n)) (t `(sqrt n))))) (defun cube-root (n) (typecase n (integer (let* ((factors (factorize (abs n))) (root (loop with primes = 1 with cubes = 1 for term in (rest factors) do (cond ((atom term) (setf primes (* primes term))) ((divides 3 (third term)) (setf cubes (* cubes (expt (second term) (/ (third term) 3))))) (t (multiple-value-bind (q r) (truncate (third term) 3) (setf primes (* primes (expt (second term) r)) cubes (* cubes (expt (second term) q)))))) finally (return (if (= 1 cubes) (if (minusp n) `(expt ,(- primes) 1/3) `(expt ,primes 1/3)) `(* ,(if (minusp n) (- cubes) cubes) (expt ,primes 1/3))))))) root)) (number (expt n 1/3)) (t `(expt ,n 1/3)))) (defun equa2 (a b c) (let* ((delta (- (* b b) (* 4 a c))) (symbolic-sqrt-delta (square-root delta))) (values (list (/ (+ (- b) (sqrt delta)) 2 a ) (/ (- (- b) (sqrt delta)) 2 a )) (list `(/ (+ ,(- b) ,symbolic-sqrt-delta) ,(* 2 a)) `(/ (- ,(- b) ,symbolic-sqrt-delta) ,(* 2 a)))))) (defun cardano (a b c d) "Solve a 3rd degree equation." (let* ((Q (/ (- (* 3 a c) (* b b)) 9 a a)) (R (/ (- (* 9 a b c) (* 27 a a d) (* 2 b b b)) 54 a a a)) (vqr (sqrt (+ (* q q q) (* r r)))) (S (expt (+ r vqr) 1/3)) (U (expt (- r vqr) 1/3)) (x1 (- (+ s u) (/ b 3 a))) (x2 (+ (/ (+ s u) -2) (/ b -3 a) (* #C(0 1) (/ (sqrt 3) 2) (- s u)))) (x3 (+ (/ (+ s u) -2) (/ b -3 a) (* #C(0 1) (/ (sqrt 3) -2) (- s u))))) (list x1 x2 x3))) (defun symbolic-cardano (a b c d) "Solve a 3rd degree equation." (let* ((Q (/ (- (* 3 a c) (* b b)) 9 a a)) (R (/ (- (* 9 a b c) (* 27 a a d) (* 2 b b b)) 54 a a a)) (vqr (sqrt (+ (* q q q) (* r r)))) (s-vqr (if (ratiop vqr) vqr (square-root (+ (* q q q) (* r r))))) (S (expt (+ r vqr) 1/3)) (U (expt (- r vqr) 1/3)) (s-S (if (ratiop S) S (if (and (ratiop r) (ratiop s-vqr)) (cube-root (+ r S)) `(expt (+ ,r ,s-vqr) 1/3)))) (s-U (if (ratiop U) U (if (and (ratiop r) (ratiop s-vqr)) (cube-root (- r U)) `(expt (- ,r ,s-vqr) 1/3)))) (x1 (- (+ s u) (/ b 3 a))) (x2 (+ (/ (+ s u) -2) (/ b -3 a) (* #C(0 1) (/ (sqrt 3) 2) (- s u)))) (x3 (+ (/ (+ s u) -2) (/ b -3 a) (* #C(0 1) (/ (sqrt 3) -2) (- s u)))) (s-x1 (if (and (ratiop s) (ratiop u)) x1 `(- (+ ,s-s ,s-u) ,(/ b 3 a)))) (s-x2 (if (and (ratiop s) (ratiop u)) x2 `(+ (/ (+ ,s-s ,s-u) -2) ,(/ b -3 a) (* i (/ (sqrt 3) 2) (- ,s-s ,s-u))))) (s-x3 (if (and (ratiop s) (ratiop u)) x3 `(+ (/ (+ ,s-s ,s-u) -2) ,(/ b -3 a) (* i (/ (sqrt 3) -2) (- ,s-s ,s-u)))))) (values (list x1 x2 x3) (list s-x1 s-x2 s-x3)))) (defun solve-polynomial-equation (coefficients) " Solve a polynomial equation with the given coefficients. p 0 = Σ C_i x^i i=0 Currently supported only orders from 0 to 3. " (let ((p (position 0 coefficients :from-end t :test-not '=))) (case p ((nil) ; 0 = 0 'number) ((0) ; 0 = C₀ with C₀≠0 '()) ((1) ; 0 = C₁ x + C₀ (list (- (/ (elt coefficients 0) (elt coefficients 1))))) ((2) ; 0 = C₂ x² + C₁ x + C₀ (equa2 (elt coefficients 2) (elt coefficients 1) (elt coefficients 0))) ((3) ; 0 = C₃ x³ + C₂ x² + C₁ x + C₀ (cardano (elt coefficients 3) (elt coefficients 2) (elt coefficients 1) (elt coefficients 0))) (otherwise (error "Equations of degree greater than 3 are not supported (yet)."))))) ;;;; THE END ;;;;
9,458
Common Lisp
.lisp
225
27.977778
107
0.38547
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
bb4dddc911f3aa3f96a1c5ff1d13d6780bf19de59c104ba092f81d1cedc36969
5,034
[ -1 ]
5,035
com.informatimago.common-lisp.arithmetic.asd
informatimago_lisp/common-lisp/arithmetic/com.informatimago.common-lisp.arithmetic.asd
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: com.informatimago.common-lisp.arithmetic.asd ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; ASD file to load the com.informatimago.common-lisp.arithmetic library. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2012-02-05 <PJB> Added p127n2. ;;;; 2010-10-31 <PJB> Created this .asd file. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2010 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see http://www.gnu.org/licenses/ ;;;;************************************************************************** (asdf:defsystem "com.informatimago.common-lisp.arithmetic" ;; system attributes: :description "Informatimago Common Lisp Arithmetic" :long-description "Arithmetic tools, primes, factorization." :author "Pascal J. Bourguignon <[email protected]>" :maintainer "Pascal J. Bourguignon <[email protected]>" :licence "AGPL3" ;; component attributes: :version "1.5.0" :properties ((#:author-email . "[email protected]") (#:date . "Autumn 2010") ((#:albert #:output-dir) . "/tmp/documentation/com.informatimago.common-lisp.arithmetic/") ((#:albert #:formats) . ("docbook")) ((#:albert #:docbook #:template) . "book") ((#:albert #:docbook #:bgcolor) . "white") ((#:albert #:docbook #:textcolor) . "black")) #+asdf-unicode :encoding #+asdf-unicode :utf-8 :depends-on ("com.informatimago.common-lisp.cesarum") :components ((:file "primes" :depends-on ()) (:file "p127n2" :depends-on ()) (:file "algebra" :depends-on ())) #+adsf3 :in-order-to #+adsf3 ((asdf:test-op (asdf:test-op "com.informatimago.common-lisp.arithmetic.test")))) ;;;; THE END ;;;;
2,740
Common Lisp
.lisp
57
44.473684
114
0.590078
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
bfc68e766decf83ef31c42a56663f14b4e8fda0eb0cdae4bfa3251e3cd606d80
5,035
[ -1 ]
5,036
p127n2.lisp
informatimago_lisp/common-lisp/arithmetic/p127n2.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: p127n2.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; See defpackage documentation string. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2012-02-04 <PJB> Converted from C++ code. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 1994 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.ARITHMETIC.P127N2" (:use "COMMON-LISP") (:export "POLY" "POLY-PRIN1-TO-STRING" "POLY-FROM-BYTES" "POLY-TO-BYTES" "REMOVE-BIT7" "INSERT-BIT7" "ADD32" "MULTIPLY32" "DIVIDE32" "REMAINDER32" "EVEN-PARITY" "ODD-PARITY") (:documentation " This module implements routines to compute modulo-2 polynomials in P127[N/2]. (Ensemble de polynômes de degré inférieur ou égal à 127 dans l'ensemble quotient N/2 (ensemble des classes d'équivalences modulo 2 dans ℕ)). License: AGPL3 Copyright Pascal J. Bourguignon 1994 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.ARITHMETIC.P127N2") (deftype poly () "A polynom of order 127. We represent them as vectors of four 32-bit words." '(vector (unsigned-byte 32) 4)) ;; CARD32* bb parameters are pointers to an array of 4 CARD32: ;; ;; CARD32 b[4]; ;; ;; b[0] contains the most significant coefficients of the polynomial, ;; b[0]&(1<<31) gives the most significant coefficient of the polynomial. ;; b[3] contains the least significant coefficients of the polynomial. ;; b[3]&1 gives the least significant coefficient of the polynomial. ;; With a big-endian architecture, this layout allow a direct ;; interpretation of the 16-byte ECP blocks. Bytes would be re-ordered ;; in a little-endian architecture. (defun poly-from-bytes (bytes) " BYTES: A vector of at least 16 octets, in big endian order. Only the 16 first octets are used. RETURN: The poly stored in the bytes. " (check-type bytes vector) (loop :for i :below 16 :do (check-type (aref bytes i) (unsigned-byte 8))) (let ((poly (make-array 4 :element-type '(unsigned-byte 32) :initial-element 0)) (j -1)) (dotimes (i 4 poly) (setf (aref poly i) (dpb (aref bytes (incf j)) (byte 8 24) (dpb (aref bytes (incf j)) (byte 8 16) (dpb (aref bytes (incf j)) (byte 8 8) (dpb (aref bytes (incf j)) (byte 8 0) 0)))))))) (assert (equalp (poly-from-bytes #(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16)) #(#x01020304 #x05060708 #x090a0b0c #x0d0e0f10))) (defun poly-to-bytes (poly) " POLY: A polynom of degree 127 modulo N/2 (type POLY). RETURN: A vector of 16 octets in big endian order encoding the polynom. " (check-type poly poly) (let ((bytes (make-array 16 :element-type '(unsigned-byte 8) :initial-element 0)) (i -1)) (dotimes (j 4 bytes) (setf (aref bytes (incf i)) (ldb (byte 8 24) (aref poly j)) (aref bytes (incf i)) (ldb (byte 8 16) (aref poly j)) (aref bytes (incf i)) (ldb (byte 8 8) (aref poly j)) (aref bytes (incf i)) (ldb (byte 8 0) (aref poly j)))))) (assert (equalp (poly-to-bytes (poly-from-bytes #(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16))) #(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16))) (defun poly-prin1-to-string (poly) " POLY: A polynom of degree 127 modulo N/2 (type POLY). RETURN: A string containing a human readable representation of the polynom POLY. (it is of the form \"x^M + … + x^m\"). " (with-output-to-string (*standard-output*) (let ((e (1- (* 4 32))) (first t)) (loop :for i :below 4 :do (let ((bit (ash 1 31)) (b (aref poly i))) (if (zerop b) (decf e 32) (loop :while (plusp bit) :do (when (plusp (logand bit b)) (format t "~:[ + ~;~]x^~A" first e) (setf first nil)) (setf bit (ash bit -1)) (decf e)))))))) (assert (equalp (poly-prin1-to-string (poly-from-bytes #(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16))) "x^120 + x^113 + x^105 + x^104 + x^98 + x^90 + x^88 + x^82 + x^81 + x^74 + x^73 + x^72 + x^67 + x^59 + x^56 + x^51 + x^49 + x^43 + x^41 + x^40 + x^35 + x^34 + x^27 + x^26 + x^24 + x^19 + x^18 + x^17 + x^11 + x^10 + x^9 + x^8 + x^4")) (eval-when (:compile-toplevel :load-toplevel :execute) (defun parity (byte predicate) (let* ((byte (logand #x7f byte)) (sum (loop :for i :below 7 :sum (ldb (byte 1 i) byte)))) (+ byte (if (funcall predicate sum) #x00 #x80)))) (defun parity-vector (predicate) (loop :with bytes := (make-array 128 :element-type '(unsigned-byte 8)) :for b :below 128 :for p := (parity b predicate) :do (setf (aref bytes b) p) :finally (return bytes)))) (defparameter *even-parity* (parity-vector (function evenp)) "A vector with all legal even-parity bytes, in 7-bit order.") (defparameter *odd-parity* (parity-vector (function oddp)) "A vector with all legal odd-parity bytes, in 7-bit order.") (declaim (inline even-parity odd-parity)) (defun even-parity (byte) " RETURN: The BYTE with the parity bit set to even parity. " (aref *even-parity* (logand byte #x7f))) (defun odd-parity (byte) " RETURN: The BYTE with the parity bit set to odd parity. " (aref *odd-parity* (logand byte #x7f))) (defun remove-bit7 (poly) " POLY: A polynom of degree 127 modulo N/2 (type POLY). DO: Modifies POLY, removing the 7th bit. RETURN: POLY " (check-type poly poly) (let (bit0 bit1 bit2 bit3) (setf bit0 (aref poly 0) (aref poly 0) (logand (ash (aref poly 0) -1) #xffffffff) bit1 (aref poly 1) (aref poly 1) (logand (logior (ash bit1 -1) (ash (logand bit0 1) 31)) #xffffffff) bit2 (aref poly 2) (aref poly 2) (logand (logior (ash bit2 -1) (ash (logand bit1 1) 31)) #xffffffff) bit3 (aref poly 3) (aref poly 3) (logior (logand (logior (ash bit3 -1) (ash bit2 31)) #xffffff80) (logand bit3 #x7f))) poly)) (defun insert-bit7 (poly) " POLY: A polynom of degree 127 modulo N/2 (type POLY). DO: Inserts into the POLY a 7th bit that is the even parity of the lowest 7 bits. RETURN: POLY " (check-type poly poly) (let (bit1 bit2 bit3) (setf bit3 (aref poly 3) (aref poly 3) (logand (logior (logand (ash bit3 1) #xffffff00) (even-parity bit3)) #xffffffff) bit2 (aref poly 2) (aref poly 2) (logand (logior (ash bit2 1) (ash bit3 -31)) #xffffffff) bit1 (aref poly 1) (aref poly 1) (logand (logior (ash bit1 1) (ash bit2 -31)) #xffffffff) (aref poly 0) (logand (logior (ash (aref poly 0) 1) (ash bit1 -31)) #xffffffff)) poly)) (defun add32 (poly gg) " POLY: A polynom of degree 127 modulo N/2 (type POLY). GG: A polynom of degree 32 modulo N/2 (type (unsigned-byte 32)). DO: Adds the polynom GG to POLY. RETURN: The modified POLY. " (check-type poly poly) (check-type gg (unsigned-byte 32)) (setf (aref poly 3) (logxor (aref poly 3) gg)) poly) (defun multiply32 (poly gg) " POLY: A polynom of degree 127 modulo N/2 (type POLY). GG: A polynom of degree 32 modulo N/2 (type (unsigned-byte 32)). DO: Multiplies the polynom POLY by GG. RETURN: The modified POLY. " (check-type poly poly) (check-type gg (unsigned-byte 32)) (let ((tt0 (aref poly 0)) (tt1 (aref poly 1)) (tt2 (aref poly 2)) (tt3 (aref poly 3)) (p0 0) (p1 0) (p2 0) (p3 0)) (loop :while (plusp gg) :do (when (plusp (logand gg 1)) (setf p0 (logxor p0 tt0) p1 (logxor p1 tt1) p2 (logxor p2 tt2) p3 (logxor p3 tt3)) (setf gg (ash gg -1) tt0 (logand (logior (ash tt0 1) (ash tt1 -31)) #xffffffff) tt1 (logand (logior (ash tt1 1) (ash tt2 -31)) #xffffffff) tt2 (logand (logior (ash tt2 1) (ash tt3 -31)) #xffffffff) tt3 (logand (ash tt3 1) #xffffffff)))) (setf (aref poly 0) p0 (aref poly 1) p1 (aref poly 2) p2 (aref poly 3) p3) poly)) (defun %division (poly gg) (check-type poly poly) (check-type gg (unsigned-byte 32)) (check-type gg (integer 1)) (let ((tt0 (aref poly 0)) (tt1 (aref poly 1)) (tt2 (aref poly 2)) (tt3 (aref poly 3)) (p0 0) (p1 0) (p2 0) (p3 0) (n 0) (hh1 #x80000000)) (loop :while (zerop (logand hh1 gg)) :do (setf hh1 (ash hh1 -1)) (incf n)) (setf gg (logand (ash gg n) #xffffffff)) (let ((gg0 gg) (gg1 0) (hh0 #x80000000)) (loop :while (plusp gg0) :do (when (plusp (logand hh0 tt0)) (setf tt0 (logxor tt0 gg0) tt1 (logxor tt1 gg1) p0 (logxor p0 hh0))) (setf gg1 (logand (logior (ash gg1 -1) (ash gg0 31)) #xffffffff) gg0 (ash gg0 -1) hh0 (ash hh0 -1)))) (let ((gg0 gg) (gg1 0) (hh0 #x80000000)) (loop :while (plusp gg0) :do (when (plusp (logand hh0 tt1)) (setf tt1 (logxor tt1 gg0) tt2 (logxor tt2 gg1) p1 (logxor p1 hh0))) (setf gg1 (logand (logior (ash gg1 -1) (ash gg0 31)) #xffffffff) gg0 (ash gg0 -1) hh0 (ash hh0 -1)))) (let ((gg0 gg) (gg1 0) (hh0 #x80000000)) (loop :while (plusp gg0) :do (when (plusp (logand hh0 tt2)) (setf tt2 (logxor tt2 gg0) tt3 (logxor tt3 gg1) p2 (logxor p2 hh0))) (setf gg1 (logand (logior (ash gg1 -1) (ash gg0 31)) #xffffffff) gg0 (ash gg0 -1) hh0 (ash hh0 -1)))) (let ((gg0 gg) (hh0 #x80000000)) (loop :while (<= hh1 hh0) :do (when (plusp (logand hh0 tt3)) (setf tt3 (logxor tt3 gg0) p3 (logxor p3 hh0))) (setf gg0 (ash gg0 -1) hh0 (ash hh0 -1)))) (values tt3 (1+ n) p0 p1 p2 p3))) (defun divide32 (poly gg) " POLY: A polynom of degree 127 modulo N/2 (type POLY). GG: A polynom of degree 32 modulo N/2 (type (unsigned-byte 32)). DO: Divides the polynom POLY by GG. RETURN: POLY; the remainder (unsigned-byte 32).. " (multiple-value-bind (tt3 n p0 p1 p2 p3) (%division poly gg) ;; Renormalize the quotient (setf (aref poly 3) (logand (logior (ash p3 (- n 32)) (ash p2 n)) #xffffffff) (aref poly 2) (logand (logior (ash p2 (- n 32)) (ash p1 n)) #xffffffff) (aref poly 1) (logand (logior (ash p1 (- n 32)) (ash p0 n)) #xffffffff) (aref poly 0) (logand (ash p0 (- n 32)) #xffffffff)) (values poly tt3))) (defun remainder32 (poly gg) " POLY: A polynom of degree 127 modulo N/2 (type POLY). GG: A polynom of degree 32 modulo N/2 (type (unsigned-byte 32)). RETURN: the remainder (unsigned-byte 32) of POLY divided by GG. NOTE: Doesn't modify POLY. " (values (%division poly gg))) ;;;; THE END ;;;;
13,320
Common Lisp
.lisp
328
33.768293
249
0.578199
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
d444aad05ea991d7a2154dbdf6d683684e1d03954320ee338dd3c2e186c3a0fc
5,036
[ -1 ]
5,037
primes.lisp
informatimago_lisp/common-lisp/arithmetic/primes.lisp
;;;; -*- coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: primes.lisp ;;;;LANGUAGE: common-lisp ;;;;SYSTEM: common-lisp ;;;;USER-INTERFACE: common-lisp ;;;;DESCRIPTION ;;;; ;;;; See defpackage documentation string. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2006-10-18 <PJB> Corrected the limit on COMPUTE-PRIMES-TO. ;;;; 2003-12-04 <PJB> Added a FACTORIZE function that returns a SEXP. ;;;; 2003-12-03 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2003 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.ARITHMETIC.PRIMES" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY") (:export "STR-DECODE" "STR-ENCODE" "PRINT-FACTORIZATION" "FACTORIZE" "DIVISORS" "COMPUTE-PRIMES-TO") (:import-from "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY" "WHILE") (:documentation " Compute primes and factorize numbers. License: AGPL3 Copyright Pascal J. Bourguignon 2003 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.ARITHMETIC.PRIMES") ;;; Sundaram Sieve: ;; In 1934, an Indian math student, S. P. Sundaram, invented a new method ;; of sieving primes: ;; ;; From a list of integers from 1 to n, remove all integers of the ;; form i + j + 2ij where integers i and j range from 1 ≤ i ≤ j and ;; i + j + 2ij ≤ n. For each remaining integer k, the integer 2k+1 is ;; prime, and the list gives all the odd primes (thus excluding the ;; prime 2). ;;; Eratostene Sieve: (defun compute-primes-to (n) " DO: Compute an Eratostene sieve to find all prime numbers up to N. RETURN: An array of prime numbers. " (cond ((< n 2) #()) ((= n 2) #(2)) ((= n 3) #(2 3)) (t (let (bits-max bits bit (prime-count 2) (cur-prime 3) primes) ;; (SETQ N (+ N (IF (ODDP N) 3 2))) (setq n (- n (if (oddp n) 3 2))) ; base of bits array is 3. (setq bits-max (/ n 2)) ;; set the bitset to full bits; (setq bits (make-array (list bits-max) :initial-element 1 :element-type 'bit)) (while (< cur-prime n) (setq bit (+ cur-prime (/ (- cur-prime 3) 2))) (while (< bit bits-max) (setf (aref bits bit) 0) (incf bit cur-prime)) (setq bit (1+ (/ (- cur-prime 3) 2))) ;; search next prime (setq bit (position 1 bits :start bit)) (if bit (setq cur-prime (+ bit bit 3) prime-count (1+ prime-count)) (setq cur-prime n))) ;; gather the primes. (setq primes (make-array (list prime-count) :element-type 'integer)) (let ((curnum 0)) (setf (aref primes curnum) 2) (incf curnum) (setf (aref primes curnum) 3) (incf curnum) (setq cur-prime 3) (setq bit 0) (setq bit (position 1 bits :start (1+ bit))) (while bit (setq cur-prime (+ bit bit 3)) (setf (aref primes curnum) cur-prime) (incf curnum) (setq bit (position 1 bits :start (1+ bit))))) primes)))) (defun factorize (n &optional (primes nil)) " N: an INTEGER PRIMES: a VECTOR of prime factors sorted in increasing order. RETURN: a SEXP of the form: (* uncomensurate-factor [ prime | (EXPT prime exponent) ]… [ -1 ] ) " (setf primes (or primes (compute-primes-to (1+ (isqrt n))))) (let ((factors '()) (prime-idx 0) ) (unless (integerp n) (error "I can only decompose integer values.")) (when (< n 0) (push -1 factors) (setq n (- n))) (while (and (< prime-idx (length primes)) (< 1 n)) (let ((prime (elt primes prime-idx)) (expo 0)) (multiple-value-bind (q r) (truncate n prime) (while (= 0 r) (incf expo) (setq n q) (multiple-value-setq (q r) (truncate n prime)))) (when (< 0 expo) (push (if (= 1 expo) prime (list 'expt prime expo)) factors) )) (incf prime-idx)) (when (< 1 n) (push n factors)) (cons '* factors))) (defun factorize-vector (n primes) " N: an INTEGER PRIMES: a VECTOR of prime factors sorted in increasing order. RETURN: a VECTOR of length (1+ (LENGTH PRIMES)), with the uncommensurate factor in the slot 0, and the exponents of the primes in the following slots. (PRIMES could have a 1 in the first slot!) " (let ((last-prime (1- (length primes))) (exponents (make-array (list (1+ (length primes))) :initial-element 0 :element-type 'integer)) (cur-exponent 0) (cur-prime -1) prime) (if (< n 0) (setf (aref exponents 0) -1 n (- n)) (setf (aref exponents 0) 1)) (setq prime (aref primes (incf cur-prime))) (while (and (< cur-prime last-prime) (< 1 n)) (let ((expo 0)) (multiple-value-bind (q r) (truncate n prime) (while (= 0 r) (incf expo) (setq n q) (multiple-value-setq (q r) (truncate n prime)))) (setf (aref exponents (incf cur-exponent)) expo) (setq prime (aref primes (incf cur-prime))))) (setf (aref exponents 0) (* (aref exponents 0) n)) exponents)) ;; (defparameter *primes* (compute-primes-to 1000)) ;; (factorize -4004 *primes*) (defun print-factorization (exponents primes) " EXPONENTS: A sequence: ( uncommensurate-factor exponents… ) PRIMES: A sequence: ( prime-factors… ) PRE: (= (LENGTH EXPONENTS) (1+ (LENGTH PRIMES))) DO: Prints on *STANDARD-OUTPUT* an expression of the number. " (map nil (lambda (p e) (unless (zerop e) (format t "~12D ^ ~D *~%" p e))) primes (subseq exponents 1)) (format t "~12A ~D~%" "" (elt exponents 0))) (defun str-encode (str primes) " RETURN: An integer encoding the string STR factorized with the PRIMES. " (apply (function *) (map 'list (lambda (ch prime) (expt prime (char-code ch))) str primes))) (defun str-decode (num primes) " RETURN: A string decoding the integer NUM factorized with the PRIMES. " (with-output-to-string (*standard-output*) (map nil (lambda (p e) (declare (ignore p)) (unless (zerop e) (format t "~C" (code-char e)))) primes (subseq (factorize-vector num primes) 1)))) (defun exponent-combinations (exponents) (if (null exponents) '(()) (let ((e (first exponents)) (c (exponent-combinations (rest exponents)))) (loop :for i :to e :append (mapcar (lambda (r) (cons i r)) c))))) (defun divisors (n) " RETURN: a list of divisors of N from 1 to N. " (let* ((prime-factors (rest (factorize n))) (exponents (mapcar (lambda (term) (if (atom term) 1 (third term))) prime-factors)) (primes (mapcar (lambda (term) (if (atom term) term (second term))) prime-factors))) (mapcar (lambda (exponents) (reduce (function *) (mapcar (function expt) primes exponents) :initial-value 1)) (exponent-combinations exponents)))) ;;;; THE END ;;;;
9,176
Common Lisp
.lisp
231
32.935065
83
0.582566
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
05a7e81d7c4441936884b54b7f73ea5de223b72c5c3a2f08e3f35bfd38856912
5,037
[ -1 ]
5,038
com.informatimago.common-lisp.arithmetic.test.asd
informatimago_lisp/common-lisp/arithmetic/com.informatimago.common-lisp.arithmetic.test.asd
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;*************************************************************************** ;;;;FILE: com.informatimago.common-lisp.arithmetic.test.asd ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: None ;;;;USER-INTERFACE: None ;;;;DESCRIPTION: ;;;; ;;;; This file defines the com.informatimago.common-lisp.arithmetic.test system. ;;;; Tests the com.informatimago.common-lisp.arithmetic system. ;;;; ;;;;USAGE: ;;;; ;;;;AUTHORS: ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS: ;;;; 2015-02-23 <PJB> Created. ;;;;BUGS: ;;;; ;;;;LEGAL: ;;;; ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;; ;;;;*************************************************************************** (asdf:defsystem "com.informatimago.common-lisp.arithmetic.test" ;; system attributes: :description "Tests the com.informatimago.common-lisp.arithmetic system." :author "Pascal J. Bourguignon <[email protected]>" :maintainer "Pascal J. Bourguignon <[email protected]>" :licence "AGPL3" ;; component attributes: :version "1.2.0" :properties ((#:author-email . "[email protected]") (#:date . "Winter 2015") ((#:albert #:output-dir) . "/tmp/documentation/com.informatimago.common-lisp.arithmetic.test/") ((#:albert #:formats) "docbook") ((#:albert #:docbook #:template) . "book") ((#:albert #:docbook #:bgcolor) . "white") ((#:albert #:docbook #:textcolor) . "black")) #+asdf-unicode :encoding #+asdf-unicode :utf-8 :depends-on ("com.informatimago.common-lisp.cesarum" "com.informatimago.common-lisp.arithmetic") :components () #+asdf3 :perform #+asdf3 (asdf:test-op (operation system) (declare (ignore operation system)) ;; (let ((*package* (find-package "TESTED-PACKAGE"))) ;; (uiop:symbol-call "TESTED-PACKAGE" ;; "TEST/ALL")) )) ;;;; THE END ;;;;
2,997
Common Lisp
.lisp
67
38.552239
90
0.553279
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
b5e85595de63a506f93dd3ae05faf48e68116a59ced31feecf9ee7016cbc39e5
5,038
[ -1 ]
5,039
html-generators-in-lisp.txt
informatimago_lisp/common-lisp/html-generator/html-generators-in-lisp.txt
============ HTML IN LISP ============ The various Lisp Markup Languages are designed more from a static point of view than a dynamic (generation) point of view. The main consequence is that there are still two modes, HTML data and Lisp code, and that some shift operator is needed to go from HTML to Lisp or from Lisp to HTML (eg. net.html.generator:html & :princ). Another difficulty is that the notation is optimized for static attributes. Usually, tags are macros, because they have bodies that must execute between the generation of the open balise and the close balise. In most cases, the HTML is generated on the run, which means that when an error occurs, invalid HTML is issued if no buffering is explicitely done. The main problem with all these schemes is that the attributes must be literal symbols or keywords and not expressions to be evaluated, so we cannot pass a variable list of attributes. Another problem with these schemes where a root macro walks its body to transform the keyword HTML tags into lisp is that it needs to be used again and again in each lexical scope in function or macro. Functions have the downside that we cannot pass more than CALL-ARGUMENTS-LIMIT arguments. So while it would be nice to use functions for tags, it is not prudent to use &REST to do so. In anycase care should be taken to avoid O(n²) space as in Le Sursis. ---------------- FUNCTIONAL LAYER ---------------- The main objective of this Lisp Markup is to generate dynamic HTML: usually we don't have long spans of HTML markup, but on the contrary, we call a bunch of Lisp functions each generating a few tags or higher level constructs. The functions could either return an object representing the tag, or modify the state of an object representing the document. Returning an object representing the tag will allow us to write: (<:tag* '() (f (<:tag-1*) (<:tag-2*))) and have f select either TAG-1 or TAG-2 to use in the list returned for TAG. This is more expressive so our functions will return tag objects and be thus more functional. (<:tag* &optional plist-of-attributes list-of-body-html) --> tag object (<:tag* (list :attrib value ...) (list (<:tag* ...) "pcdata" ...)) The attribute value strings are processed and any character invalid for the corresponding attribute is escaped (in general CDATA). The strings in the list-of-body-html are processed and any character invalid in PCDATA is escaped. In general, attributes names are string designators. When given a symbol or keyword, the symbol-name is used. Qualified XML attributes may be written as string designator containing a colon: (<:html* (list "xmlns" "http://www.w3.org/1999/xhtml" :xml\:lang "en" lang "en") ...) When given as string, case is not changed. When given as a symbol or keyword, if the name is all uppercase, then it's downcased, otherwise it's preserved. Each function can check the attributes and attribute values, as well as its contents, and signal an error condition, depending on the DTD selected. XHTML rules - Elements must be correctly terminated: <p></p> - Empty elements must be terminated too: <img /> - All attribute values must be quoted: <td rowspan="3"></td> - Boolean attributes cannot be minimized: <dl compact="compact"></dl> - Tags and attributes must be written in low case. - Predefined attribute values must be written in low case: <input type="text" /> - Hex entities must be written in low case: &x99; - name attributes -> id attributes ??? - use both lang and xml:lang attributes. HTML-STRING (string) Function Returns a tag-object that would generate the contents of the STRING as HTML. Example: (HTML-STRING "<P>Some paragraph</P>") --> #<element> WRITE-HTML (tag-object &optional (stream *html-output*) Function Writes the HTML encoded in the tag-object to the output STREAM. (write-html (<:html* '() (list (<:head* '() (list (<:title '() '("Some title")))) (<:body* (list :style (js:css-inline* :background-color color) "red") (list (<:h1 '() '("Title")) (<:p '() '("Some paragraph text" "and some more"))))))) ------------ MARKUP LAYER ------------ Another layer will consist of macros which will accept a more lax syntax for attributes, and build the list of body-html from a body of lisp code. (<:tag plist-of-attributes &body body) plist-of-attributes ::= () | - | (:attrib value-expr ...) | lisp-expression . If all keys are keywords, then (list ,@plist-of-attributes) else plist-of-attributes (:att (some 'value) (if test :a1 :a2) "value") ; invalid (list :att (some 'value) (if test :a1 :a2) "value") ; valid (defmacro tag (attributes &body body) `(let ((results)) (push (tag* ,(if (and (evenp (length attributes)) (loop :for (k v) :on attributes :always (keywordp k))) `(list ,@attributes) attributes) (let ((*html-tags* '())) (setf results (multiple-value-list (progn ,@body))) (nreverse *html-tags*))) *html-tags*) (apply (function values) results))) (table (attributes-for-table) (loop for r in rows do (tr (loop for c in r do (td c))))) ;; we don't want to use collect here because we want to be able to ;; call TR inside functions called here. Expands to: (table (attributes-for-table) (loop for r in rows do (tr () (loop for c in r do (td () (pcdata c))))) (push (<:table* '() (let ((*html-tags* '())) (loop for r in rows do (push (<:tr '() (let ((*html-tags* '())) (loop for c in r do (push (<:td '() (let ((*html-tags* '())) (push (pcdata c)) (nreverse *html-tags*))) *html-tags*)) (nreverse *html-tags*))) *html-tags*)) (nreverse *html-tags*))) *html-tags*) (with-html-output (stream) (doctype :loose (html () (head () (title () (pcdata "title"))) (body () (p () (pcdata "para") (pcdata var)))))) (with-html-output (stream) (doctype :loose (html - (head - (title - (pcdata "title"))) (body - (p - (pcdata "para") (pcdata var)))))) WITH-HTML-OUTPUT ((&optional stream &key kind encoding) &body body) Macro Execute body (collecting *HTML-TAGS*), and finally writes to the STREAM the HTML collected. KIND indicates which kind of is used: :HTML, :XHTML or :XML. (tags may be generated differently in HTML 4.01 than in XHTML 1.0 or XML). ENCODING indicates which character encoding is used to write the document. CDATA and PCDATA may be escaped differently depending on the encoding. (defmacro with-html-output ((stream) &body body) `(let ((*html-tags* '())) (multiple-value-prog1 (progn ,@body) (dolist (tag (nreverse *html-tags*)) (write-html tag stream))))) Both functions and macros accumulate the generated html bits into the lists of ELEMENT objects, and don't concatenate any string internally, until the tree is written to the output stream with WRITE-HTML. This means that structure sharing of parts of a document doesn't use any memory (but a few references). ======================================================================== EXAMPLES: With macros, issuing static html; the pcdata must be tagged with the PCDATA macro: (with-html-output () (doctype :loose (html - (head - (title - (pcdata "title"))) (body (:color "#123456" "background-color" "red") (p - (pcdata "para") (pcdata "var"))))) (values)) prints: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>title </title></head> <body color="#123456" background-color="red"> <p>para var </p></body></html> With functions the lists of attributes and body elements can be built dynamically. The strings are automatically converted to pcdata: (progn (write-html (doctype* :loose)) (write-html (html* '() (list (head* '() (list (title* '() (list (pcdata* "title"))))) (body* (list :color "#123456" "background-color" "red") (list (p* '() (list "para" (pcdata "variable")))))))) (values)) prints: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>title </title></head> <body color="#123456" background-color="red"> <p>para variable </p></body></html> ======================================================================== ======================================================================== ======================================================================== ------------------------------------------------------------------------ YACLML: HTML tags are macros (Leaf tags (without bodies) can be functions: deftag vs. deftag-macro.) (<:tag :attrib value :atrib value ... body ...) Output to *yaclml-stream*; with-yaclml-stream, with-yaclml-output-to-string NET.HTML.GENERATOR: (HTMLGEN, ALLEGROSERVE). HTML tags are keywords, in the context of the NET.HTML.GENERATOR:HTML macro: (html (:tag body...) ((:tag :attrib value ...) body ....)) :newline -> inserts a new line in the generated html. :princ :princ-safely etc -> to have a run-time value inserted in the html. Output to *html-stream*; html-stream Attribute names are not evaluated, attribute values are evaluated. CL-WHO: Similar to NET.HTML.GENERATOR (WITH-HTML-OUTPUT (htm (:tag :attrib value ... body (str pc-data) body ...))) HTOUT: Similar to NET.HTML.GENERATOR cl-durian: https://github.com/GordianNaught/cl-durian cl-durian creates human legible, indented HTML from simple list structures. (cl-durian:html `(html ((cl-durian:script ((type "text/javascript")) "var x = 1;") (h1 "This is the title") (b ((p "line1") (p "line2")))))) "<html> <script TYPE=\"text/javascript\">var x = 1;</script> <h1>This&nbsp;is&nbsp;the&nbsp;title</h1> <b> <p>line1</p> <p>line2</p> </b> </html> " Dynamism is accomplished with list interpolation (`,' and `,@'). Internally uses with-output-to-string for linear-time string construction. LML: HTML tags are keywords. There is a reader macro to insert the PCDATA. (p [,(a :href "http://lml.b9.com" "LML") is a Common Lisp package for generating HTML and XHTML documents. LML is authored by ,(a :href "mailto:[email protected]" "Kevin Rosenberg"). The home page for LML is ,(a :href "http://lml.b9.com/" "http://lml.b9.com/").]) Output to *html-output*. XHTML: #+example-of-use ;; (defun redirect-example (ofile title url) ;; (with-xhtml (ostream ofile) ;; (head (title title) ;; (meta :http-equiv "Refresh" ;; :content (format nil "0; URL=~a" url))) ;; (redirect-example-body ostream title url))) ;; ;; #+example-of-use ;; (defun redirect-example-body (ostream title url) ;; (let ((format-string "This page should automatically redirect you to ~a. ~ If it does not, please click on ")) ;; (with-xhtml (ostream) ;; (body (h1 title) ;; (p (format-to-xhtml ostream format-string ;; title) ;; (a :href url "this") ;; " link."))))) ;; XML-EMITER: There are macros to emit any tag: (with-xml-output (*standard-output*) (with-tag ("person" '(("age" "19"))) (with-simple-tag ("firstName") (xml-out "Peter")) (simple-tag "lastName" "Scott") (emit-simple-tags :age 17 :school "Iowa State Univeristy" "mixedCaseTag" "Check out the mixed case!" "notShown" nil))) Le Sursis: (format t (http-response (html (head (title "Thank You!")) (body (h1 "Thank You!") (img '(("src" . "le-sursis.png") ("alt" . "The Le Sursis banner"))) "Thank you for your response.")))) Tags are functions that return a string containing the generated HTML. (O(n²) in space).
14,026
Common Lisp
.lisp
296
38.942568
106
0.558035
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
f84aace72ab79cd612a6768f59acc5ed7ec041a04e507f62833b736aaac83ded
5,039
[ -1 ]
5,040
com.informatimago.common-lisp.html-generator.asd
informatimago_lisp/common-lisp/html-generator/com.informatimago.common-lisp.html-generator.asd
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: com.informatimago.common-lisp.html-generator.asd ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; ASD file to load the com.informatimago.common-lisp.html-generator library. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2010-10-31 <PJB> Created this .asd file. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2010 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see http://www.gnu.org/licenses/ ;;;;************************************************************************** (asdf:defsystem "com.informatimago.common-lisp.html-generator" ;; system attributes: :description "Informatimago Common Lisp HTML 4.01 Generator" :long-description " Generation of HTML pages. " :author "Pascal J. Bourguignon <[email protected]>" :maintainer "Pascal J. Bourguignon <[email protected]>" :licence "AGPL3" ;; component attributes: :version "1.4.0" :properties ((#:author-email . "[email protected]") (#:date . "Autumn 2010") ((#:albert #:output-dir) . "/tmp/documentation/com.informatimago.common-lisp.html-generator/") ((#:albert #:formats) . ("docbook")) ((#:albert #:docbook #:template) . "book") ((#:albert #:docbook #:bgcolor) . "white") ((#:albert #:docbook #:textcolor) . "black")) #+asdf-unicode :encoding #+asdf-unicode :utf-8 :depends-on ("com.informatimago.common-lisp.cesarum") :components ((:file "html" :depends-on ())) #+adsf3 :in-order-to #+adsf3 ((asdf:test-op (asdf:test-op "com.informatimago.common-lisp.html-generator.test")))) ;;;; THE END ;;;;
2,613
Common Lisp
.lisp
56
43.517857
118
0.59812
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
4bb0f8cb13bbac425efcdf0f300b33ba30a4958a8aa8b2e416df7f322b15907b
5,040
[ -1 ]
5,041
html.lisp
informatimago_lisp/common-lisp/html-generator/html.lisp
;;;; -*- coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: html.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Generating HTML pages. ;;;; ;;;; See also: ;;;; cliki HTML from sexpr ;;;; http://www.cliki.net/HTML-from-sexpr ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2007-05-17 <PJB> New implementation. ;;;; 2004-08-23 <PJB> Added BUILD-QUERY. ;;;; 2003-05-16 <PJB> Extracted from vacation.lisp. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2003 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.HTML-GENERATOR.HTML" #+mocl (:nicknames "HTML" "<") (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.LIST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STRING" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.QUEUE" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.CHARACTER-SETS") (:import-from "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STRING" "SPLIT-STRING" "STRING-REPLACE") (:shadow "MAP") (:export "*HTML-OUTPUT-STREAM*" "*HTML-CHARACTER-SET*" "*DOCTYPE*" "*HTML-VERSION*" "DOCTYPE*" "DOCTYPE" ;; ELEMENT objects: "HTML-STRING*" "COMMENT*" "CDATA*" "PCDATA*" "HTML-STRING" "COMMENT" "CDATA" "PCDATA" "ELEMENT" "ELEMENT-WITH-TAG" "ELEMENT-WITH-BODY" "ELEMENT-WITHOUT-END" "ELEMENT-TAG" "ELEMENT-ATRIBUTES" "ELEMENT-BODY" "WRITE-ELEMENT" "HTML-STRING-TEXT" "CDATA-DATA" "PCDATA-DATA" "WRITE-HTML" "WITH-HTML-OUTPUT" "COLLECT-ELEMENT" "COLLECT-ELEMENTS" ;; Low level stuff: "*HTML-XHTML-MODE-P*" "WRITE-ESCAPING" "NORMALIZE-ATTRIBUTE-NAME" ;; HTML 4.01 tags functions: "A*" "ABBR*" "ACRONYM*" "ADDRESS*" "APPLET*" "AREA*" "B*" "BASE*" "BASEFONT*" "BDO*" "BIG*" "BLOCKQUOTE*" "BODY*" "BR*" "BUTTON*" "CAPTION*" "CENTER*" "CITE*" "CODE*" "COL*" "COLGROUP*" "DD*" "DEL*" "DFN*" "DIR*" "DIV*" "DL*" "DT*" "EM*" "FIELDSET*" "FONT*" "FORM*" "FRAME*" "FRAMESET*" "H1*" "H2*" "H3*" "H4*" "H5*" "H6*" "HEAD*" "HR*" "HTML*" "I*" "IFRAME*" "IMG*" "INPUT*" "INS*" "ISINDEX*" "KBD*" "LABEL*" "LEGEND*" "LI*" "LINK*" "MAP*" "MENU*" "META*" "NOFRAMES*" "NOSCRIPT*" "OBJECT*" "OL*" "OPTGROUP*" "OPTION*" "P*" "PARAM*" "PRE*" "Q*" "S*" "SAMP*" "SCRIPT*" "SELECT*" "SMALL*" "SPAN*" "STRIKE*" "STRONG*" "STYLE*" "SUB*" "SUP*" "TABLE*" "TBODY*" "TD*" "TEXTAREA*" "TFOOT*" "TH*" "THEAD*" "TITLE*" "TR*" "TT*" "U*" "UL*" "VAR*" ;; HTML 4.01 tags macros: "A" "ABBR" "ACRONYM" "ADDRESS" "APPLET" "AREA" "B" "BASE" "BASEFONT" "BDO" "BIG" "BLOCKQUOTE" "BODY" "BR" "BUTTON" "CAPTION" "CENTER" "CITE" "CODE" "COL" "COLGROUP" "DD" "DEL" "DFN" "DIR" "DIV" "DL" "DT" "EM" "FIELDSET" "FONT" "FORM" "FRAME" "FRAMESET" "H1" "H2" "H3" "H4" "H5" "H6" "HEAD" "HR" "HTML" "I" "IFRAME" "IMG" "INPUT" "INS" "ISINDEX" "KBD" "LABEL" "LEGEND" "LI" "LINK" "MAP" "MENU" "META" "NOFRAMES" "NOSCRIPT" "OBJECT" "OL" "OPTGROUP" "OPTION" "P" "PARAM" "PRE" "Q" "S" "SAMP" "SCRIPT" "SELECT" "SMALL" "SPAN" "STRIKE" "STRONG" "STYLE" "SUB" "SUP" "TABLE" "TBODY" "TD" "TEXTAREA" "TFOOT" "TH" "THEAD" "TITLE" "TR" "TT" "U" "UL" "VAR") (:documentation " This package exports macros and functions to generate HTML pages. See also: <http://www.cliki.net/HTML-from-sexpr> html-generators-in-lisp.txt EXAMPLES: With macros, issuing static html; the pcdata must be tagged with the PCDATA macro: (with-html-output () (doctype :loose (html - (head - (title - (pcdata \"title\"))) (body (:color \"#123456\" \"background-color\" \"red\") (p - (pcdata \"para\") (pcdata \"var\"))))) (values)) prints: <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"> <html> <head> <title>title </title></head> <body color=\"#123456\" background-color=\"red\"> <p>para var </p></body></html> With functions the lists of attributes and body elements can be built dynamically. The strings are automatically converted to pcdata: (progn (write-html (doctype* :loose)) (write-html (html* '() (list (head* '() (list (title* '() (list (pcdata* \"title\"))))) (body* (list :color \"#123456\" \"background-color\" \"red\") (list (p* '() (list \"para\" (pcdata \"variable\")))))))) (values)) prints: <!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"> <html> <head> <title>title </title></head> <body color=\"#123456\" background-color=\"red\"> <p>para variable </p></body></html> License: AGPL3 Copyright Pascal J. Bourguignon 2003 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.HTML-GENERATOR.HTML") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; ;;; #+mocl (eval-when (:compile-toplevel :load-toplevel :execute) (defun mocl/make-hash-table (&key (test (function eql))) (list 'mocl/hash-table test '())) (defun mocl/gethash (key table &optional default) (assert (eq 'mocl/hash-table (first table))) (let ((entry (assoc key (third table) :test (second table)))) (if entry (cdr entry) default))) (defun (setf mocl/gethash) (new-value key table &optional default) (declare (ignore default)) (assert (eq 'mocl/hash-table (first table))) (let ((entry (assoc key (third table) :test (second table)))) (if entry (setf (cdr entry) new-value) (push (cons key new-value) (third table))))) (defun mocl/maphash (fun table) (assert (eq 'mocl/hash-table (first table))) (mapc (lambda (entry) (funcall fun (car entry) (cdr entry))) (third table)) (values))) (eval-when (:compile-toplevel :load-toplevel :execute) (defvar *html-output-stream* *standard-output* "The stream used by WITH-HTML-OUTPUT and WRITE-HTML by default.") (defvar *html-output-elements* (make-queue) "The HTML macros collect issued elements into this queue.") (defvar *doctype* :strict "The DOCTYPE of HTML document being generated. May be a token: :STRICT, :TRANSITIONAL, :LOOSE or :FRAMESET.") (defvar *html-version* "4.01" "The HTML version of the document being generated.") (defvar *html-xhtml-mode-p* nil "Set to true when the elements must be written in XHTML 1.0 variant.") (defvar *html-character-set* (find-character-set "US-ASCII") "The encoding used to write the HTML code. By default it's ASCII, even if ISO-8859-1 is the default for HTML, since ASCII is the intersection with the Common Lisp standard character set and HTML default character set.") (defun collect-element (element) " DO: Collect the ELEMENT into the current *HTML-OUTPUT-ELEMENTS*. RETURN: ELEMENT. " (queue-enqueue *html-output-elements* element) element) (defun collect-elements (elements) " DO: Collect the ELEMENTS into the current *HTML-OUTPUT-ELEMENTS*. RETURN: ELEMENTS. " (queue-append *html-output-elements* elements) elements) (defun doctype* (kind) " KIND: one of :STRICT, :TRANSITIONAL, :LOOSE or :FRAMESET. RETURN: The DOCTYPE tag. " (unless (member kind '(:strict :transitional :loose :frameset)) (error "Unexpected DOCTYPE kind. Please choose :STRICT, ~ :TRANSITIONAL, :LOOSE or :FRAMESET.")) (html-string (ecase kind ((:strict) "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" ~ \"http://www.w3.org/TR/html4/strict.dtd\">~%") ((:transitional :loose) "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" ~ \"http://www.w3.org/TR/html4/loose.dtd\">~%") ((:frameset) "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\" ~ \"http://www.w3.org/TR/html4/frameset.dtd\">~%")))) (defmacro doctype (kind &body body) " KIND: one of :STRICT, :TRANSITIONAL, :LOOSE or :FRAMESET. RETURN: The DOCTYPE tag. " (let ((vkind (gensym))) `(let* ((,vkind ,kind) (*doctype* ,vkind) (*html-version* "4.01")) (doctype* ,vkind) ,@body))) ;; We consider only two kinds of elements: ;; <a>x</a> elements with contents who get always an end tag ;; <br> or <br /> elements without contents, who never get an end tag. ;; We don't write <br></br>: either we generate HTML 4.01 as: <br> ;; or we generate XHTML 1.0 as: <br /> (defgeneric element-tag (element) (:documentation "RETURN: The tag of the ELEMENT.")) (defgeneric element-attributes (element) (:documentation "RETURN: The attributes of the ELEMENT.")) (defgeneric element-body (element) (:documentation "RETURN: The body of the ELEMENT.")) (defgeneric write-element (element stream) (:documentation "DO: Write the ELEMENT to the STREAM.")) (defclass element () () (:documentation "Represents an HTML element.")) (defmethod write-element ((self element) stream) (declare (ignore stream)) self) (defun write-escaping (escapes string stream) " DO: Write the STRING to the STREAM, escaping characters found in ESCAPES, or not found in the ranges of the *HTML-CHARACTER-SET* as &amp;#nn; escapes. ESCAPES: An a-list mapping characters to escape strings. STRING: A text string. STREAM: An output stream. " (if (cs-ranges *html-character-set*) (loop :for ch :across string :for as = (assoc ch escapes) :do (cond (as (princ (cdr as) stream)) ((character-in-character-set-p ch *html-character-set*) (princ ch stream)) (t (format stream "&#~D;" (char-code ch))))) (loop :for ch :across string :for as = (assoc ch escapes) :do (cond (as (princ (cdr as) stream)) ((<= (char-code ch) 127) (princ ch stream)) (t (format stream "&#~D;" (char-code ch))))))) (defgeneric html-string-text (element) (:documentation "RETURN: The string text of the element." )) (defclass html-string (element) ((text :initarg :text :reader html-string-text :type string)) (:documentation "Represents HTML text.")) (defmethod print-object ((self html-string) stream) (print-unreadable-object (self stream :type t :identity t) (format stream ":text ~S" (html-string-text self))) self) (defmethod write-element ((self html-string) stream) (write-string (html-string-text self) stream) self) (defun html-string* (control &rest arguments) " RETURN: An element storing the result of formating the CONTROL string with the ARGUMENTS containing HTML code. EXAMPLE: (HTML-STRING \"<P>Some paragraph</P>\") --> #<element> " (make-instance 'html-string :text (apply (function format) nil control arguments))) (defun html-string (control &rest arguments) (collect-element (apply (function html-string*) control arguments))) (defun comment* (control &rest arguments) " RETURN: An element storing the result of formating the CONTROL string with the ARGUMENTS as a HTML comment. " (html-string "~&<!-- ~A -->~%" (string-replace (apply (function format) nil control arguments) "--" "=="))) (defun comment (control &rest arguments) " RETURN: An element storing the result of formating the CONTROL string with the ARGUMENTS as a HTML comment. " (apply (function comment*) control arguments)) (defgeneric cdata-data (element) (:documentation "The CDATA text.")) (defclass cdata (element) ((data :initarg :data :reader cdata-data :type string)) (:documentation "Represents CDATA text.")) (defmethod initialize-instance :after ((self cdata) &rest args) (declare (ignore args)) (setf (slot-value self 'data) (string-trim " " (slot-value self 'data))) self) (defmethod print-object ((self cdata) stream) (print-unreadable-object (self stream :type t :identity t) (format stream ":data ~S" (cdata-data self))) self) (defmethod write-element ((self cdata) stream) (write-escaping '((#\& . "&amp;") (#\" . "&quot;")) (cdata-data self) stream) self) (defun cdata* (control &rest arguments) " RETURN: An element storing the result of formating the CONTROL string with the ARGUMENTS as CDATA (ie. post-processed to quote special HTML characters (&,\"). " (make-instance 'cdata :data (apply (function format) nil control arguments))) (defun cdata (control &rest arguments) (collect-element (apply (function cdata*) control arguments))) (defgeneric pcdata-data (element) (:documentation "The PCDATA text.")) (defclass pcdata (element) ((data :initarg :data :reader pcdata-data :type string)) (:documentation "Represents PCDATA text.")) (defmethod print-object ((self pcdata) stream) (print-unreadable-object (self stream :type t :identity t) (format stream ":data ~S" (pcdata-data self))) self) (defmethod write-element ((self pcdata) stream) (write-escaping '((#\& . "&amp;") (#\< . "&lt;") (#\> . "&gt;")) (pcdata-data self) stream) self) (defun pcdata* (control &rest arguments) " RETURN: An element storing the result of formating the CONTROL string with the ARGUMENTS as CDATA (ie. post-processed to quote special HTML characters (<,>,&,\"). " (make-instance 'pcdata :data (apply (function format) nil control arguments))) (defun pcdata (control &rest arguments) (collect-element (apply (function pcdata*) control arguments))) (defparameter *newline-elements* '(p h1 h2 h3 h4 h5 h6 ul ol pre dl div noscript blockquote hr form table fieldset address br dt dd li textarea thead tbody tfoot tr td html head title meta link style script noscript body)) (defclass element-with-tag (element) ((tag :initarg :tag :reader element-tag :type (or string nil)) (attributes :initarg :attributes :reader element-attributes :type list :initform '())) (:documentation "Represents an HTML tagged element.")) (defmethod print-object ((self element-with-tag) stream) (print-unreadable-object (self stream :identity t :type t) (format stream ":tag ~A :attributes ~S" (element-tag self) (element-attributes self))) self) (defmethod write-element ((self element-with-tag) stream) (loop :for (k v) :on (element-attributes self) :by (function cddr) :initially (format stream "~:[~;~%~]<~A" (member (element-tag self) *newline-elements* :test (function string-equal)) (element-tag self)) :do (format stream " ~A=\"" k) :do (write-element v stream) :do (princ "\"" stream) :finally (princ ">" stream))) (defclass element-without-end (element-with-tag) () (:documentation "Represents an HTML tagged element, without a closing tag.")) (defclass element-with-body (element-with-tag) ((body :initarg :body :reader element-body :type list)) (:documentation "Represents an HTML tagged element, with a body.")) (defmethod print-object ((self element-with-body) stream) (print-unreadable-object (self stream :identity t :type t) (format stream ":tag ~A :attributes ~S :body ~S" (element-tag self) (element-attributes self) (element-body self))) self) (defmethod write-element ((self element-with-body) stream) (call-next-method) (unwind-protect (dolist (element (element-body self)) (write-element element stream)) (format stream "</~A>" (element-tag self))) self) (defparameter *letters* "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" "Only ASCII letters.") (defparameter *digits* "0123456789" "Only ASCII digits.") (defun token-id-p (token) (and (<= 1 (length token)) (position (aref token 0) *letters*) (every (lambda (ch) (or (position ch *letters*) (position ch *digits*) (position ch "-_:."))) token))) (defun token-idrefs-p (token) (and (<= 1 (length token)) (every (function token-id-p) (split-string token)))) (defun token-number-p (token) (and (<= 1 (length token)) (every (lambda (ch) (position ch *digits*)) token))) (defun write-html (element &optional (stream *html-output-stream*)) " DO: Write the HTML encoded in the ELEMENT to the output STREAM. " (write-element element stream)) (defmacro with-html-output ((&optional (stream *html-output-stream*) &key (kind :html kindp) (encoding "US-ASCII" encodingp)) &body body) " DO: Execute body (collecting *HTML-TAGS*), and finally writes to the STREAM the HTML collected. KIND: indicates which kind of is used: :HTML, :XHTML or :XML. (tags may be generated differently in HTML 4.01 than in XHTML 1.0 or XML). ENCODING: indicates which character encoding is used to write the document. CDATA and PCDATA may be escaped differently depending on the encoding. (The default is ASCII because it's the intersection between the lisp standard character set and the default HTML character set (ISO-8859-1). " (let ((vstream (gensym))) `(let ((,vstream ,stream) (*html-output-elements* (make-queue)) (*html-xhtml-mode-p* ,(if kindp `(not (eq ,kind :html)) `*html-xhtml-mode-p*)) (*html-character-set* ,(if encodingp (let ((venc (gensym))) `(let ((,venc ,encoding)) (if (typep ,venc 'character-set) ,venc (find-character-set (string ,venc))))) `*html-character-set*))) (multiple-value-prog1 (progn ,@body) (dolist (tag (queue-elements *html-output-elements*)) (write-html tag ,vstream)))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Loading the DTD. ;;; ;;; Eventually, we should parse and load the DTD sources. ;;; For now, we have in HTML401.lisp the DTD in lisp form, and we ;;; can interpret it with the defelement and defattribute macros. ;;; ;;; To generate the functions and macros to build the document elements ;;; we need both the element and attribute loaded, so we generate them ;;; afterwards. ;;; ;; (eval-when (:compile-toplevel :load-toplevel :execute) (defstruct (dtd-element (:conc-name el-)) name options documentation attributes) (defstruct (dtd-attribute (:conc-name at-)) name elements type default options documentation) (defparameter *elements* (#+mocl mocl/make-hash-table #-mocl make-hash-table :test (function equal)) "Maps element names to elements.") (defparameter *attributes* (#+mocl mocl/make-hash-table #-mocl make-hash-table :test (function equal)) "Maps attribute names to attributes.") (defmacro defelement (name options &optional (documentation "A HTML element.")) " DO: Defines an HTML element macro. NAME: A symbol that will be used to define a macro. OPTIONS: A list of keywords: :START-OPTIONAL :END-FORBIDDEN :EMPTY :DEPRECATED :LOOSE-DTD or :FRAMESET-DTD. :END-FORBIDDEN -> the close tag is not generated. :DEPRECATED -> warning when the macro is used. :EMPTY -> the macro won't take a BODY. :START-OPTIONAL -> ignored. :LOOSE-DTD -> error when *DOCTYPE* isn't :LOOSE. :FRAMESET-DTD -> error when *DOCTYPE* isn't :FRAMESET. NOTE: All HTML 4.01 elements have EMPTY <=> END-FORBIDDEN. DOCUMENTATION: A string used as documentation string for the macro NAME. " (let ((elem (make-dtd-element :name (string-downcase name) :options options :documentation documentation))) (setf (#+mocl mocl/gethash #-mocl gethash (el-name elem) *elements*) elem)) `',name) (defmacro defattribute (attr-name elements type default options documentation) " DO: Defines an HTML attribute. " (let ((attr (make-dtd-attribute :name (normalize-attribute-name attr-name) :elements elements :type type :default default :options options :documentation documentation))) (setf (#+mocl mocl/gethash #-mocl gethash (at-name attr) *attributes*) attr) (if (eq (car elements) :all-elements-but) (#+mocl mocl/maphash #-mocl maphash (lambda (name element) (unless (member name (cdr elements) :test (function string-equal)) (pushnew (normalize-attribute-name attr-name) (el-attributes element) :test (function string=)))) *elements*) (mapc (lambda (name) (unless (#+mocl mocl/gethash #-mocl gethash (string-downcase name) *elements*) (error "~A doesn't name an element (please use ~ DEFELEMENT before DEFATTRIBUTE)" name)) (pushnew (normalize-attribute-name attr-name) (el-attributes (#+mocl mocl/gethash #-mocl gethash (string-downcase name) *elements*)) :test (function string=))) elements))) (list 'quote attr-name)) (defun check-loose (name) (unless (eq :loose *doctype*) (error "The element ~A can be used only with loose DTD." name))) (defun check-frameset (name) (unless (eq :frameset *doctype*) (error "The element ~A can be used only with frameset DTD." name))) (defun normalize-attribute-name (name) " NAME: A string or a symbol. RETURN: A string containing the normalized attribute name, ie: downcased. " (etypecase name (string name) (symbol (let ((name (string name))) (if (every (function upper-case-p) name) (string-downcase name) name))))) (defun generate-element-macro-body (fname vattr vbody) (let ((vresults (gensym))) `(let ((,vresults)) (collect-element (,fname ,(cond ((or (null vattr) (eq '- vattr)) '()) ((or (keywordp (first vattr)) (not (symbolp (first vattr))) (and (evenp (length vattr)) (loop :for (k) :on vattr :by (function cddr) :always (keywordp k)))) `(list ,@vattr)) (t vattr)) (let ((*html-output-elements* (make-queue))) (setf ,vresults (multiple-value-list (progn ,@vbody))) (queue-elements *html-output-elements*)))) (apply (function values) ,vresults)))) (defun generate-elements (elements) (let ((forms '())) (#+mocl mocl/maphash #-mocl maphash (lambda (name element) (let ((vattr (make-symbol "ATTRIBUTES")) (vbody (make-symbol "BODY")) (mname (intern (string-upcase name))) (fname (intern (with-standard-io-syntax (format nil "~:@(~A*~)" name))))) (push `(defmacro ,mname (&optional ,vattr &body ,vbody) ,(format nil " DO: ~? ATTRIBUTES: A P-list of attributes. Attribute names are keywords, attribute values are strings. BODY: Lisp forms, evaluated between the opening tag of the element and the closing tag of the element. RETURN: The generated HTML. " "Generate a &lt;~A&gt; HTML element~:[: ~A~;~]." (list (el-name element) (string= (el-documentation element) "A HTML element.") (el-documentation element))) (generate-element-macro-body ',fname ,vattr ,vbody)) forms) (push `(defun ,fname (&optional ,vattr ,vbody) ,(format nil " DO: ~? ATTRIBUTES: A P-list of attributes. Attribute names are keywords, attribute values are strings. BODY: Lisp forms, evaluated between the opening tag of the element and the closing tag of the element. RETURN: The generated HTML. " "Generate a &lt;~A&gt; HTML element~:[: ~A~;~]." (list (el-name element) (string= (el-documentation element) "A HTML element.") (el-documentation element))) ,@(when (member :deprecated (el-options element)) `((warn ,(format nil "HTML element ~A is deprecated." name)))) ,@(cond ((member :loose-dtd (el-options element)) `((check-loose ',name))) ((member :frameset-dtd (el-options element)) `((check-frameset ',name)))) ,@(when (member :empty (el-options element)) `((when ,vbody (error "HTML element ~A doesn't take ~ any content; ~S was given" ',name ,vbody)))) ;; html-string :text ;; cdata :data ;; pcdata :data ;; element-without-end :tag :attributes ;; element-with-body :tag :attributes :body ,(if (member :empty (el-options element)) `(make-instance 'element-without-end :tag ',(el-name element) :attributes (loop :for (k v) :on ,vattr :by (function cddr) :nconc (list (normalize-attribute-name k) (if (typep v 'cdata) v (make-instance 'cdata :data (format nil "~A" v)))))) `(make-instance 'element-with-body :tag ',(el-name element) :attributes (loop :for (k v) :on ,vattr :by (function cddr) :nconc (list (normalize-attribute-name k) (if (typep v 'cdata) v (make-instance 'cdata :data (format nil "~A" v))))) :body (mapcar (lambda (item) (if (stringp item) (make-instance 'pcdata :data item) item)) ,vbody)))) forms))) elements) (cons 'progn (nreverse forms)))) );;eval-when (defmacro generate () (append (generate-elements *elements*) '('done))) ;; (eval-when (:compile-toplevel :load-toplevel) ;; ;; #+(or allegro ccl ecl) (LOAD #P"PACKAGES:com;informatimago;common-lisp;html401.lisp") ;; #-(or allegro ccl ecl) (LOAD (merge-pathnames ;; (make-pathname :case :common ;; :directory '(:relative :up "HTML-BASE") ;; :name "HTML401" ;; :type "LISP" ;; :defaults (or *compile-file-pathname* ;; *load-pathname*)) ;; (print (or *compile-file-pathname* ;; *load-pathname*)) ;; nil)) ;; ;; (generate)) ;;;;--------------------------------------------------------------------------- ;;;; -*- coding:utf-8 -*- ;;;;*************************************************************************** ;;;;FILE: html401.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; HTML 4.01 DTD ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2003-11-12 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; GPL ;;;; ;;;; Copyright Pascal J. Bourguignon 2003 - 2016 ;;;; ;;;; This program is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU General Public License ;;;; as published by the Free Software Foundation; either version ;;;; 2 of the License, or (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be ;;;; useful, but WITHOUT ANY WARRANTY; without even the implied ;;;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ;;;; PURPOSE. See the GNU General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU General Public ;;;; License along with this program; if not, write to the Free ;;;; Software Foundation, Inc., 59 Temple Place, Suite 330, ;;;; Boston, MA 02111-1307 USA ;;;;*************************************************************************** ;; ;; (defelement name options [documentation-string]) ;; options: ([:start-optional] [:end-forbidden] [:empty] [:deprecated] ;; [:loose-dtd] [:frameset-dtd]) ;; (defelement a () "anchor") (defelement abbr () "abbreviated form (e.g., WWW, HTTP, etc.)") (defelement acronym ()) (defelement address () "information on author") (defelement applet (:deprecated :loose-dtd) "Java applet") (defelement area (:end-forbidden :empty) "client-side image map area") (defelement b () "bold text style") (defelement base (:end-forbidden :empty) "document base URI") (defelement basefont (:end-forbidden :empty :deprecated :loose-dtd) "base font size") (defelement bdo () "I18N BiDi over-ride") (defelement big () "large text style") (defelement blockquote () "long quotation") (defelement body (:start-optional :end-optional) "document body") (defelement br (:end-forbidden :empty) "forced line break") (defelement button () "push button") (defelement caption () "table caption") (defelement center (:deprecated :loose-dtd) "shorthand for DIV align=center") (defelement cite () "citation") (defelement code () "computer code fragment") (defelement col (:end-forbidden :empty) "table column") (defelement colgroup (:end-optional) "table column group") (defelement dd (:end-optional) "defelementinition description") (defelement del () "deleted text") (defelement dfn () "instance defelementinition") (defelement dir (:deprecated :loose-dtd) "directory list") (defelement div () "generic language/style container") (defelement dl () "defelementinition list") (defelement dt (:end-optional) "defelementinition term") (defelement em () "emphasis") (defelement fieldset () "form control group") (defelement font (:deprecated :loose-dtd) "local change to font") (defelement form () "interactive form") (defelement frame (:end-forbidden :empty :frameset-dtd) "subwindow") (defelement frameset (:frameset-dtd) "window subdivision") (defelement h1 () "Heading") (defelement h2 () "Heading") (defelement h3 () "Heading") (defelement h4 () "Heading") (defelement h5 () "Heading") (defelement h6 () "Heading") (defelement head (:start-optional :end-optional) "document head") (defelement hr (:end-forbidden :empty) "horizontal rule") (defelement html (:start-optional :end-optional) "document root element") (defelement i () "italic text style") (defelement iframe (:loose-dtd) "inline subwindow") (defelement img (:end-forbidden :empty) "embedded image") (defelement input (:end-forbidden :empty) "form control") (defelement ins () "inserted text") (defelement isindex (:end-forbidden :empty :deprecated :loose-dtd) "single line prompt") (defelement kbd () "text to be entered by the user") (defelement label () "form field label text") (defelement legend () "fieldset legend") (defelement li (:end-optional) "list item") (defelement link (:end-forbidden :empty) "a media-independent link") (defelement map () "client-side image map") (defelement menu (:deprecated :loose-dtd) "menu list") (defelement meta (:end-forbidden :empty) "generic metainformation") (defelement noframes (:frameset-dtd) "alternate content container for non frame-based rendering") (defelement noscript () "alternate content container for non script-based rendering") (defelement object () "generic embedded object") (defelement ol () "ordered list") (defelement optgroup () "option group") (defelement option (:end-optional) "selectable choice") (defelement p (:end-optional) "paragraph") (defelement param (:end-forbidden :empty) "named property value") (defelement pre () "preformatted text") (defelement q () "short inline quotation") (defelement s (:deprecated :loose-dtd) "strike-through text style") (defelement samp () "sample program output, scripts, etc.") (defelement script () "script statements") (defelement select () "option selector") (defelement small () "small text style") (defelement span () "generic language/style container") (defelement strike (:deprecated :loose-dtd) "strike-through text") (defelement strong () "strong emphasis") (defelement style () "style info") (defelement sub () "subscript") (defelement sup () "superscript") (defelement table ()) (defelement tbody (:start-optional :end-optional) "table body") (defelement td (:end-optional) "table data cell") (defelement textarea () "multi-line text field") (defelement tfoot (:end-optional) "table footer") (defelement th (:end-optional) "table header cell") (defelement thead (:end-optional) "table header") (defelement title () "document title") (defelement tr (:end-optional) "table row") (defelement tt () "teletype or monospaced text style") (defelement u (:deprecated :loose-dtd) "underlined text style") (defelement ul () "unordered list") (defelement var () "instance of a variable or program argument") (defattribute abbr (td th) (%text) :implied () "abbreviation for header cell") (defattribute accept-charset (form) (%charsets) :implied () "list of supported charsets") (defattribute accept (form input) (%contenttypes) :implied () "list of MIME types for file upload") (defattribute accesskey (a area button input label legend textarea) (%character) :implied () "accessibility key character") (defattribute action (form) (%uri) :required () "server-side form handler") ;; ;; (DEFATTRIBUTE ATTR-NAME ELEMENTS TYPE DEFAULT OPTIONS DOCUMENTATION) ;; (defattribute align (caption) (%calign) :implied (:deprecated :loose-dtd) "relative to table") (defattribute align (applet iframe img input object) (%ialign) :implied (:deprecated :loose-dtd) "vertical or horizontal alignment") (defattribute align (legend) (%lalign) :implied (:deprecated :loose-dtd) "relative to fieldset") (defattribute align (table) (%talign) :implied (:deprecated :loose-dtd) "table position relative to window") (defattribute align (hr) (or "LEFT" "CENTER" "RIGHT") :implied (:deprecated :loose-dtd) "") (defattribute align (div h1 h2 h3 h4 h5 h6 p) (or "LEFT" "CENTER" "RIGHT" "JUSTIFY") :implied (:deprecated :loose-dtd) "align, text alignment") (defattribute align (col colgroup tbody td tfoot th thead tr) (or "LEFT" "CENTER" "RIGHT" "JUSTIFY" "CHAR") :implied () "") (defattribute alink (body) (%color) :implied (:deprecated :loose-dtd) "color of selected links") (defattribute alt (applet) (%text) :implied (:deprecated :loose-dtd) "short description") (defattribute alt (area img) (%text) :required () "short description") (defattribute alt (input) (cdata) :implied () "short description") (defattribute archive (applet) (cdata) :implied (:deprecated :loose-dtd) "comma-separated archive list") (defattribute archive (object) (cdata) :implied () "space-separated list of URIs") (defattribute axis (td th) (cdata) :implied () "comma-separated list of related headers") (defattribute background (body) (%uri) :implied (:deprecated :loose-dtd) "texture tile for document background") (defattribute bgcolor (table) (%color) :implied (:deprecated :loose-dtd) "background color for cells") (defattribute bgcolor (tr) (%color) :implied (:deprecated :loose-dtd) "background color for row") (defattribute bgcolor (td th) (%color) :implied (:deprecated :loose-dtd) "cell background color") (defattribute bgcolor (body) (%color) :implied (:deprecated :loose-dtd) "document background color") (defattribute border (table) (%pixels) :implied () "controls frame width around table") (defattribute border (img object) (%pixels) :implied (:deprecated :loose-dtd) "link border width") (defattribute cellpadding (table) (%length) :implied () "spacing within cells") (defattribute cellspacing (table) (%length) :implied () "spacing between cells") (defattribute char (col colgroup tbody td tfoot th thead tr) (%character) :implied () "alignment char, e.g. char=':'") (defattribute charoff (col colgroup tbody td tfoot th thead tr) (%length) :implied () "offset for alignment char") (defattribute charset (a link script) (%charset) :implied () "char encoding of linked resource") (defattribute checked (input) (checked) :implied () "for radio buttons and check boxes") (defattribute cite (blockquote q) (%uri) :implied () "URI for source document or msg") (defattribute cite (del ins) (%uri) :implied () "info on reason for change") (defattribute class (:all-elements-but base basefont head html meta param script style title) (cdata) :implied () "space-separated list of classes") (defattribute classid (object) (%uri) :implied () "identifies an implementation") (defattribute clear (br) (or "LEFT" "ALL" "RIGHT" "NONE") "NONE" (:deprecated :loose-dtd) "control of text flow") (defattribute code (applet) (cdata) :implied (:deprecated :loose-dtd) "applet class file") (defattribute codebase (object) (%uri) :implied () "base URI for classid, data, archive") (defattribute codebase (applet) (%uri) :implied (:deprecated :loose-dtd) "optional base URI for applet") (defattribute codetype (object) (%contenttype) :implied () "content type for code") (defattribute color (basefont font) (%color) :implied (:deprecated :loose-dtd) "text color") (defattribute cols (frameset) (%multilengths) :implied (:frameset-dtd) "list of lengths, default: 100% (1 col)") (defattribute cols (textarea) (number) :required () "") (defattribute colspan (td th) (number) "1" () "number of cols spanned by cell") (defattribute compact (dir dl menu ol ul) (compact) :implied (:deprecated :loose-dtd) "reduced interitem spacing") (defattribute content (meta) (cdata) :required () "associated information") (defattribute coords (area) (%coords) :implied () "comma-separated list of lengths") (defattribute coords (a) (%coords) :implied () "for use with client-side image maps") (defattribute data (object) (%uri) :implied () "reference to object's data") (defattribute datetime (del ins) (%datetime) :implied () "date and time of change") (defattribute declare (object) (declare) :implied () "declare but don't instantiate flag") (defattribute defer (script) (defer) :implied () "UA may defer execution of script") (defattribute dir (:all-elements-but applet base basefont bdo br frame frameset iframe param script) (or "LTR" "RTL") :implied () "direction for weak/neutral text") (defattribute dir (bdo) (or "LTR" "RTL") :required () "directionality") (defattribute disabled (button input optgroup option select textarea) (disabled) :implied () "unavailable in this context") (defattribute enctype (form) (%contenttype) "application/x-www-form-urlencoded" () "") (defattribute face (basefont font) (cdata) :implied (:deprecated :loose-dtd) "comma-separated list of font names") (defattribute for (label) (idref) :implied () "matches field ID value") (defattribute frame (table) (%tframe) :implied () "which parts of frame to render") (defattribute frameborder (frame iframe) (or "1" "0") "1" :frameset-dtd "request frame borders?") (defattribute headers (td th) (idrefs) :implied () "list of id's for header cells") (defattribute height (iframe) (%length) :implied (:loose-dtd) "frame height") (defattribute height (td th) (%length) :implied (:deprecated :loose-dtd) "height for cell") (defattribute height (img object) (%length) :implied () "override height") (defattribute height (applet) (%length) :required (:deprecated :loose-dtd) "initial height") (defattribute href (a area link) (%uri) :implied () "URI for linked resource") (defattribute href (base) (%uri) :implied () "URI that acts as base URI") (defattribute hreflang (a link) (%languagecode) :implied () "language code") (defattribute hspace (applet img object) (%pixels) :implied (:deprecated :loose-dtd) "horizontal gutter") (defattribute http-equiv (meta) (name) :implied () "HTTP response header name") (defattribute id (:all-elements-but base head html meta script style title) (id) :implied () "document-wide unique id") (defattribute ismap (img input) (ismap) :implied () "use server-side image map") (defattribute label (option) (%text) :implied () "for use in hierarchical menus") (defattribute label (optgroup) (%text) :required () "for use in hierarchical menus") (defattribute lang (:all-elements-but applet base basefont br frame frameset iframe param script) (%languagecode) :implied () "language code") (defattribute language (script) (cdata) :implied (:deprecated :loose-dtd) "predefined script language name") (defattribute link (body) (%color) :implied (:deprecated :loose-dtd) "color of links") (defattribute longdesc (img) (%uri) :implied () "link to long description (complements alt)") (defattribute longdesc (frame iframe) (%uri) :implied (:frameset-dtd) "link to long description (complements title)") (defattribute marginheight (frame iframe) (%pixels) :implied (:frameset-dtd) "margin height in pixels") (defattribute marginwidth (frame iframe) (%pixels) :implied (:frameset-dtd) "margin widths in pixels") (defattribute maxlength (input) (number) :implied () "max chars for text fields") (defattribute media (style) (%mediadesc) :implied () "designed for use with these media") (defattribute media (link) (%mediadesc) :implied () "for rendering on these media") (defattribute method (form) (or "GET" "POST") "GET" () "HTTP method used to submit the form") (defattribute multiple (select) (multiple) :implied () "default is single selection") (defattribute name (button textarea) (cdata) :implied () "") (defattribute name (applet) (cdata) :implied (:deprecated :loose-dtd) "allows applets to find each other") (defattribute name (select) (cdata) :implied () "field name") (defattribute name (form) (cdata) :implied () "name of form for scripting") (defattribute name (frame iframe) (cdata) :implied (:frameset-dtd) "name of frame for targetting") (defattribute name (img) (cdata) :implied () "name of image for scripting") (defattribute name (a) (cdata) :implied () "named link end") (defattribute name (input object) (cdata) :implied () "submit as part of form") (defattribute name (map) (cdata) :required () "for reference by usemap") (defattribute name (param) (cdata) :required () "property name") (defattribute name (meta) (name) :implied () "metainformation name") (defattribute nohref (area) (nohref) :implied () "this region has no action") (defattribute noresize (frame) (noresize) :implied (:frameset-dtd) "allow users to resize frames?") (defattribute noshade (hr) (noshade) :implied (:deprecated :loose-dtd) "") (defattribute nowrap (td th) (nowrap) :implied (:deprecated :loose-dtd) "suppress word wrap") (defattribute object (applet) (cdata) :implied (:deprecated :loose-dtd) "serialized applet file") (defattribute onblur (a area button input label select textarea) (%script) :implied () "the element lost the focus") (defattribute onchange (input select textarea) (%script) :implied () "the element value was changed") (defattribute onclick (:all-elements-but applet base basefont bdo br font frame frameset head html iframe isindex meta param script style title) (%script) :implied () "a pointer button was clicked") (defattribute ondblclick (:all-elements-but applet base basefont bdo br font frame frameset head html iframe isindex meta param script style title) (%script) :implied () "a pointer button was double clicked") (defattribute onfocus (a area button input label select textarea) (%script) :implied () "the element got the focus") (defattribute onkeydown (:all-elements-but applet base basefont bdo br font frame frameset head html iframe isindex meta param script style title) (%script) :implied () "a key was pressed down") (defattribute onkeypress (:all-elements-but applet base basefont bdo br font frame frameset head html iframe isindex meta param script style title) (%script) :implied () "a key was pressed and released") (defattribute onkeyup (:all-elements-but applet base basefont bdo br font frame frameset head html iframe isindex meta param script style title) (%script) :implied () "a key was released") (defattribute onload (frameset) (%script) :implied (:frameset-dtd) "all the frames have been loaded") (defattribute onload (body) (%script) :implied () "the document has been loaded") (defattribute onmousedown (:all-elements-but applet base basefont bdo br font frame frameset head html iframe isindex meta param script style title) (%script) :implied () "a pointer button was pressed down") (defattribute onmousemove (:all-elements-but applet base basefont bdo br font frame frameset head html iframe isindex meta param script style title) (%script) :implied () "a pointer was moved within") (defattribute onmouseout (:all-elements-but applet base basefont bdo br font frame frameset head html iframe isindex meta param script style title) (%script) :implied () "a pointer was moved away") (defattribute onmouseover (:all-elements-but applet base basefont bdo br font frame frameset head html iframe isindex meta param script style title) (%script) :implied () "a pointer was moved onto") (defattribute onmouseup (:all-elements-but applet base basefont bdo br font frame frameset head html iframe isindex meta param script style title) (%script) :implied () "a pointer button was released") (defattribute onreset (form) (%script) :implied () "the form was reset") (defattribute onselect (input textarea) (%script) :implied () "some text was selected") (defattribute onsubmit (form) (%script) :implied () "the form was submitted") (defattribute onunload (frameset) (%script) :implied (:frameset-dtd) "all the frames have been removed") (defattribute onunload (body) (%script) :implied () "the document has been removed") (defattribute profile (head) (%uri) :implied () "named dictionary of meta info") (defattribute prompt (isindex) (%text) :implied (:deprecated :loose-dtd) "prompt message") (defattribute readonly (textarea) (readonly) :implied () "") (defattribute readonly (input) (readonly) :implied () "for text and passwd") (defattribute rel (a link) (%linktypes) :implied () "forward link types") (defattribute rev (a link) (%linktypes) :implied () "reverse link types") (defattribute rows (frameset) (%multilengths) :implied (:frameset-dtd) "list of lengths, default: 100% (1 row)") (defattribute rows (textarea) (number) :required () "") (defattribute rowspan (td th) (number) "1" () "number of rows spanned by cell") (defattribute rules (table) (%trules) :implied () "rulings between rows and cols") (defattribute scheme (meta) (cdata) :implied () "select form of content") (defattribute scope (td th) (%scope) :implied () "scope covered by header cells") (defattribute scrolling (frame iframe) (or "YES" "NO" "AUTO") "AUTO" (:frameset-dtd) "scrollbar or none") (defattribute selected (option) (selected) :implied () "") (defattribute shape (area) (%shape) "rect" () "controls interpretation of coords") (defattribute shape (a) (%shape) "RECT" () "for use with client-side image maps") (defattribute size (hr) (%pixels) :implied (:deprecated :loose-dtd) "") (defattribute size (font) (cdata) :implied (:deprecated :loose-dtd) "[+ -]nn e.g. size=\"+1\", size=\"4\"") (defattribute size (input) (cdata) :implied () "specific to each type of field") (defattribute size (basefont) (cdata) :required (:deprecated :loose-dtd) "base font size for FONT elements") (defattribute size (select) (number) :implied () "rows visible") (defattribute span (col) (number) "1" () "COL attributes affect N columns") (defattribute span (colgroup) (number) "1" () "default number of columns in group") (defattribute src (script) (%uri) :implied () "URI for an external script") (defattribute src (input) (%uri) :implied () "for fields with images") (defattribute src (frame iframe) (%uri) :implied (:frameset-dtd) "source of frame content") (defattribute src (img) (%uri) :required () "URI of image to embed") (defattribute standby (object) (%text) :implied () "message to show while loading") (defattribute start (ol) (number) :implied (:deprecated :loose-dtd) "starting sequence number") (defattribute style (:all-elements-but base basefont head html meta param script style title) (%stylesheet) :implied () "associated style info") (defattribute summary (table) (%text) :implied () "purpose/structure for speech output") (defattribute tabindex (a area button input object select textarea) (number) :implied () "position in tabbing order") (defattribute target (a area base form link) (%frametarget) :implied (:loose-dtd) "render in this frame") (defattribute text (body) (%color) :implied (:deprecated :loose-dtd) "document text color") (defattribute title (:all-elements-but base basefont head html meta param script title) (%text) :implied () "advisory title") (defattribute type (a link) (%contenttype) :implied () "advisory content type") (defattribute type (object) (%contenttype) :implied () "content type for data") (defattribute type (param) (%contenttype) :implied () "content type for value when valuetype=ref") (defattribute type (script) (%contenttype) :required () "content type of script language") (defattribute type (style) (%contenttype) :required () "content type of style language") (defattribute type (input) (%inputtype) "TEXT" () "what kind of widget is needed") (defattribute type (li) (%listyle) :implied (:deprecated :loose-dtd) "list item style") (defattribute type (ol) (%olstyle) :implied (:deprecated :loose-dtd) "numbering style") (defattribute type (ul) (%ulstyle) :implied (:deprecated :loose-dtd) "bullet style") (defattribute type (button) (or "BUTTON" "SUBMIT" "RESET") "SUBMIT" () "for use as form button") (defattribute usemap (img input object) (%uri) :implied () "use client-side image map") (defattribute valign (col colgroup tbody td tfoot th thead tr) (or "TOP" "MIDDLE" "BOTTOM" "BASELINE") :implied () "vertical alignment in cells") (defattribute value (input) (cdata) :implied () "Specify for radio buttons and checkboxes") (defattribute value (option) (cdata) :implied () "defaults to element content") (defattribute value (param) (cdata) :implied () "property value") (defattribute value (button) (cdata) :implied () "sent to server when submitted") (defattribute value (li) (number) :implied (:deprecated :loose-dtd) "reset sequence number") (defattribute valuetype (param) (or "DATA" "REF" "OBJECT") "DATA" () "How to interpret value") (defattribute version (html) (cdata) :%html.version (:deprecated :loose-dtd) "Constant") (defattribute vlink (body) (%color) :implied (:deprecated :loose-dtd) "color of visited links") (defattribute vspace (applet img object) (%pixels) :implied (:deprecated :loose-dtd) "vertical gutter") (defattribute width (hr) (%length) :implied (:deprecated :loose-dtd) "") (defattribute width (iframe) (%length) :implied (:loose-dtd) "frame width") (defattribute width (img object) (%length) :implied () "override width") (defattribute width (table) (%length) :implied () "table width") (defattribute width (td th) (%length) :implied (:deprecated :loose-dtd) "width for cell") (defattribute width (applet) (%length) :required (:deprecated :loose-dtd) "initial width") (defattribute width (col) (%multilength) :implied () "column width specification") (defattribute width (colgroup) (%multilength) :implied () "default width for enclosed COLs") (defattribute width (pre) (number) :implied (:deprecated :loose-dtd) "") ;;;; THE END ;;;; ;;;;--------------------------------------------------------------------------- (generate) ;; (DEFUN ATTRIBUTES-TO-STRING (ELEMENT ATTRIBUTES) ;; " ;; ELEMENT: The element into which the attributes will be inserted. ;; (To check if the required attributes are effectively present). ;; NOTE: Not implemente yet the fine processing of defined attributes ;; with DEFATTRIBUTE... ;; NOTE: The attribute names and the attribute values are quoted with ;; CDATA-QUOTE-STRING (\" and &). ;; RETURN: A string containing the attributes formated for inclusion in ;; a HTML tag. ;; " ;; (DECLARE (IGNORE ELEMENT)) ;; CHECKING NOT IMPLEMENTED YET. ;; (DO* ((ATTRIBUTES ATTRIBUTES (CDDR ATTRIBUTES)) ;; (KEY (CAR ATTRIBUTES) (CAR ATTRIBUTES)) ;; (VALUE (CADR ATTRIBUTES) (CADR ATTRIBUTES)) ;; (STRING ())) ;; ((NULL ATTRIBUTES) ;; (APPLY (FUNCTION CONCATENATE) 'STRING (NREVERSE STRING))) ;; ;; CHECK IF ATTRIBUTE BELONGS TO ELEMENT ;; ;; CHECK ATTRIBUTE BELONG TO THIS *DOCTYPE* ;; ;; CHECK TYPE OF ATTRIBUTE VALUE ;; (IF (NULL VALUE) ;; is this a boolean ATTRIBUTE? ;; (WHEN KEY (PUSH (FORMAT NIL " ~A" ;; (CDATA-QUOTE-STRING (STRING KEY))) STRING)) ;; (PUSH (FORMAT NIL " ~A=\"~A\"" ;; (CDATA-QUOTE-STRING (STRING KEY)) ;; (CDATA-QUOTE-STRING (FORMAT NIL "~A" VALUE))) STRING))) ;; ;; CHECK IF ALL REQUIRED ATTRIBUTES OF ELEMENT ARE PRESENT. ;; ) ;; (defun obfuscate (address) " DO: Generate an email address as an HTML string with the characters written as entities. " (do ((i (1- (length address)) (1- i)) (res '())) ((< i 0) (apply (function concatenate) 'string res)) (push (format nil "&#~D;" (char-code (aref address i))) res))) ;;;; THE END ;;;;
62,751
Common Lisp
.lisp
1,623
31.938386
127
0.588737
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
6a37247aa7c00fa1664ec12d02ee9feea44301d20a752dbedec6f7d2e0fc154f
5,041
[ -1 ]
5,042
com.informatimago.common-lisp.html-generator.test.asd
informatimago_lisp/common-lisp/html-generator/com.informatimago.common-lisp.html-generator.test.asd
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;*************************************************************************** ;;;;FILE: com.informatimago.common-lisp.html-generator.test.asd ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: None ;;;;USER-INTERFACE: None ;;;;DESCRIPTION: ;;;; ;;;; This file defines the com.informatimago.common-lisp.html-generator.test system. ;;;; Tests the com.informatimago.common-lisp.html-generator system. ;;;; ;;;;USAGE: ;;;; ;;;;AUTHORS: ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS: ;;;; 2015-02-23 <PJB> Created. ;;;;BUGS: ;;;; ;;;;LEGAL: ;;;; ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;; ;;;;*************************************************************************** (asdf:defsystem "com.informatimago.common-lisp.html-generator.test" ;; system attributes: :description "Tests the com.informatimago.common-lisp.html-generator system." :author "Pascal J. Bourguignon <[email protected]>" :maintainer "Pascal J. Bourguignon <[email protected]>" :licence "AGPL3" ;; component attributes: :version "1.2.0" :properties ((#:author-email . "[email protected]") (#:date . "Winter 2015") ((#:albert #:output-dir) . "/tmp/documentation/com.informatimago.common-lisp.html-generator.test/") ((#:albert #:formats) "docbook") ((#:albert #:docbook #:template) . "book") ((#:albert #:docbook #:bgcolor) . "white") ((#:albert #:docbook #:textcolor) . "black")) #+asdf-unicode :encoding #+asdf-unicode :utf-8 :depends-on ("com.informatimago.common-lisp.cesarum" "com.informatimago.common-lisp.html-generator") :components () #+asdf3 :perform #+asdf3 (asdf:test-op (operation system) (declare (ignore operation system)) ;; (let ((*package* (find-package "TESTED-PACKAGE"))) ;; (uiop:symbol-call "TESTED-PACKAGE" ;; "TEST/ALL")) )) ;;;; THE END ;;;;
3,025
Common Lisp
.lisp
67
38.970149
94
0.555142
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
23915f9551c64e3ac861c8bf0c38f40079e51c72026863ab6c0f5a6103ceade0
5,042
[ -1 ]
5,043
hquery.lisp
informatimago_lisp/common-lisp/http/hquery.lisp
;;;;************************************************************************** ;;;;FILE: hquery.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; This packages exports utility routines for web applications. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2007-05-30 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2007 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.HTTP.HQUERY" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STRING") (:export "QUERY-ESCAPE" "QUERY-UNESCAPE" "QUERY-PARSE" "QUERY-ARGUMENT" "BUILD-QUERY") (:documentation " This packages exports utility routines for web applications. License: AGPL3 Copyright Pascal J. Bourguignon 2007 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.HTTP.HQUERY") (defun query-escape (string) " RETURN: A string where the spaces are replaced by '+' and other unsavory characters are replaced by %HL sequences. " (do ((result (make-string (* 3 (length string)))) (i 0) (j 0)) ((<= (length string) i) (subseq result 0 j)) (cond ((char= (character " ") (char string i)) (setf (char result j) (character "+")) (incf j) (incf i)) ((position (char string i) "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") (setf (char result j) (char string i)) (incf j) (incf i)) (t (let ((escape (format nil "%~16,2R" (char-code (char string i))))) (setf (char result j) (char escape 0)) (incf j) (setf (char result j) (char escape 1)) (incf j) (setf (char result j) (char escape 2)) (incf j) (incf i)))))) (defun query-unescape (qpart) " RETURN: A string where the + are replaced by spaces and the %HL are replaced by the caracter whose code is HL in hexadecimal. " (do ((result (make-string (length qpart))) (i 0) (j 0)) ((<= (length qpart) i) (subseq result 0 j)) (cond ((char= (character "+") (char qpart i)) (setf (char result j) (character " ")) (incf j) (incf i)) ((and (char= (character "%") (char qpart i)) (< (+ i 2) (length qpart))) (let ((code (parse-integer qpart :start (+ i 1) :end (+ i 3) :radix 16))) (cond ((null code) (setf (char result j) (char qpart i)) (incf j) (incf i)) ((= 13 code) (incf i 3)) (t (setf (char result j) (code-char code)) (incf j) (incf i 3))) )) (t (setf (char result j) (char qpart i)) (incf j) (incf i))))) (defun query-parse (query-string) " RETURN: the QUERY-ARGUMENTS, a list of lists (variable . value) found in the HTML CGI QUERY-STRING. " (mapcar (lambda (ass) (let* ((posep (position (character "=") ass)) (var (if posep (subseq ass 0 posep) ass)) (val (if posep (subseq ass (1+ posep)) ""))) (cons (query-unescape var) (query-unescape val)))) (split-string query-string "&"))) (defun query-argument (name query-arguments) " RETURN: The value of the QUERY-STRING argument named NAME. " (cdr (assoc name query-arguments :test (function string-equal)))) (defun build-query (&rest field-value) " RETURN: A formated string containing the field=value&field=value… EXAMPLE: (build-query :first-name \"john\" :surname \"doe\") --> \"first%2Dname=john&surname=doe\" " (format nil "~{~A=~A~^&~}" (mapcar (lambda (item) (query-escape (if (stringp item) item (format nil "~A" item)))) field-value))) ;;;; THE END ;;;;
5,498
Common Lisp
.lisp
135
35.096296
83
0.603406
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
76ba53d25529bad9fa22afedafc58a2e6f75e402940b83fe3f5aaa287c87901c
5,043
[ -1 ]
5,044
com.informatimago.common-lisp.http.test.asd
informatimago_lisp/common-lisp/http/com.informatimago.common-lisp.http.test.asd
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;*************************************************************************** ;;;;FILE: com.informatimago.common-lisp.http.test.asd ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: None ;;;;USER-INTERFACE: None ;;;;DESCRIPTION: ;;;; ;;;; This file defines the com.informatimago.common-lisp.http.test system. ;;;; Tests the com.informatimago.common-lisp.http system. ;;;; ;;;;USAGE: ;;;; ;;;;AUTHORS: ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS: ;;;; 2015-02-23 <PJB> Created. ;;;;BUGS: ;;;; ;;;;LEGAL: ;;;; ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;; ;;;;*************************************************************************** (asdf:defsystem "com.informatimago.common-lisp.http.test" ;; system attributes: :description "Tests the com.informatimago.common-lisp.http system." :author "Pascal J. Bourguignon <[email protected]>" :maintainer "Pascal J. Bourguignon <[email protected]>" :licence "AGPL3" ;; component attributes: :version "1.2.0" :properties ((#:author-email . "[email protected]") (#:date . "Winter 2015") ((#:albert #:output-dir) . "/tmp/documentation/com.informatimago.common-lisp.http.test/") ((#:albert #:formats) "docbook") ((#:albert #:docbook #:template) . "book") ((#:albert #:docbook #:bgcolor) . "white") ((#:albert #:docbook #:textcolor) . "black")) #+asdf-unicode :encoding #+asdf-unicode :utf-8 :depends-on ("com.informatimago.common-lisp.cesarum" "com.informatimago.common-lisp.http") :components () #+asdf3 :perform #+asdf3 (asdf:test-op (operation system) (declare (ignore operation system)) ;; (let ((*package* (find-package "TESTED-PACKAGE"))) ;; (uiop:symbol-call "TESTED-PACKAGE" ;; "TEST/ALL")) )) ;;;; THE END ;;;;
2,955
Common Lisp
.lisp
67
37.925373
84
0.546778
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
ef7429d7d7bc997785a135fbae3f5a7c774a829a0a617d0eadc73f122850439e
5,044
[ -1 ]
5,045
com.informatimago.common-lisp.http.asd
informatimago_lisp/common-lisp/http/com.informatimago.common-lisp.http.asd
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: com.informatimago.common-lisp.http.asd ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; ASD file to load the com.informatimago.common-lisp.http library. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2010-10-31 <PJB> Created this .asd file. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2010 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see http://www.gnu.org/licenses/ ;;;;************************************************************************** (asdf:defsystem "com.informatimago.common-lisp.http" ;; system attributes: :description "Informatimago Common Lisp HTML Utilities" :long-description " Utilities to encode and decode HTTP queries. A transaction manager for HTTP CGI. " :author "Pascal J. Bourguignon <[email protected]>" :maintainer "Pascal J. Bourguignon <[email protected]>" :licence "AGPL3" ;; component attributes :version "1.4.0" :properties ((#:author-email . "[email protected]") (#:date . "Autumn 2010") ((#:albert #:output-dir) . "/tmp/documentation/com.informatimago.common-lisp.http/") ((#:albert #:formats) . ("docbook")) ((#:albert #:docbook #:template) . "book") ((#:albert #:docbook #:bgcolor) . "white") ((#:albert #:docbook #:textcolor) . "black")) #+asdf-unicode :encoding #+asdf-unicode :utf-8 :depends-on ("com.informatimago.common-lisp.cesarum" "com.informatimago.common-lisp.html-generator") :components ((:file "hquery" :depends-on ()) (:file "htrans" :depends-on ("hquery"))) #+adsf3 :in-order-to #+adsf3 ((asdf:test-op (asdf:test-op "com.informatimago.common-lisp.http.test")))) ;;;; THE END ;;;;
2,730
Common Lisp
.lisp
59
42.745763
108
0.595952
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
b1970cfa2b277e4d37760a4e194c67a8665928f1757e939181de0a5daeb1c3f9
5,045
[ -1 ]
5,046
htrans.lisp
informatimago_lisp/common-lisp/http/htrans.lisp
;;;; -*- coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: htrans.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;NOWEB: t ;;;;DESCRIPTION ;;;; ;;;; See defpackage documentation string. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2005-08-10 <PJB> Removed depdency on de.pmsf.md5. ;;;; 2003-09-05 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2003 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (in-package "COMMON-LISP-USER") (declaim (declaration also-use-packages)) (declaim (also-use-packages "COM.INFORMATIMAGO.COMMON-LISP.HTML-GENERATOR.HTML" "COM.INFORMATIMAGO.COMMON-LISP.HTTP.HQUERY")) #-mocl (eval-when (:compile-toplevel :load-toplevel :execute) (com.informatimago.common-lisp.cesarum.package:add-nickname "COM.INFORMATIMAGO.COMMON-LISP.HTML-GENERATOR.HTML" "HTML")) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.HTTP.HTRANS" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STRING") (:export "GETCMDS" "GETARG" "SEND-TABLE" "SEND-REPLY" "PROCESS-TRANSACTION" "GENERATE-HTML-FOOTER" "GENERATE-HTML-HEADER" "REFUSE-SESSION" "REFUSE-REMOTE" "PROCESS-REQUEST" "BODY-ATTRIBUTES" "TITLE" "ACTION" "REFUSED-NETS" "ALLOWED-NETS" "ENVIRONMENT" "ARGUMENTS" "HPROGRAM") (:import-from "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STRING" "PREFIXP" "SPLIT-STRING") (:documentation " A simple \"transaction\" manager for CGI. html-client transac-manager cgi | | | | | / |--------(initial-request)------->| / | |-----initialrequest(sessid)----->| | | | | |<------reply(sessid,trid)--------| |<-------(html-form)--------------| / | / | | / |----------(action.get)---------->| / | |----request(sesid,trid,data)---->| | | | | |<------reply(sessid,trid+1)------| |<-------(html-form)--------------| / | / | | | | V V V In this implementation transac-manager and cgi are linked together in the CGI process and this CGI process lives from the HTML request to the response. License: AGPL3 Copyright Pascal J. Bourguignon 2003 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.HTTP.HTRANS") (defvar +crlf+ (format nil "~C~C" (code-char 13) (code-char 10))) (defgeneric process-transaction (htp) (:documentation " DO: Parses the CGI request and calls the REQUEST function passing it the session-id, transaction-id and request data. For the initial request, transaction-id and request data will be NIL. NOTE: Begins by outputing the HTML header and ends with the HTML footer. ")) (defgeneric send-reply (htp session-id transac-id title data commands) (:documentation "DO: Sends a reply page.")) (defgeneric send-table (htp session-id transac-id title row-desc data commands) (:documentation "DO: Sends a table.")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; HTML Transaction Program Interface ;;; (defgeneric action (program) (:documentation "A string naming the action used in the HTML forms.")) (defgeneric allowed-nets (program) (:documentation "A list of (ip-address ip-mask).")) (defgeneric arguments (program) (:documentation "A list of command-line arguments.")) (defgeneric body-attributes (program) (:documentation "A list containing the HTML:BODY attributes.")) (defgeneric environment (program) (:documentation "An a-list of unix environment variables: (var . value)*")) (defgeneric refused-nets (program) (:documentation "A list of (ip-address ip-mask).")) (defgeneric title (program) (:documentation "A string used as page title.")) (defclass hprogram () ((arguments :initform nil :initarg :arguments :accessor arguments :type list :documentation "A list of command-line arguments.") (environment :initform nil :initarg :environment :accessor environment :type list :documentation "An a-list of unix environment variables: (var . value)*") (allowed-nets :initform nil :initarg :allowed-nets :accessor allowed-nets :type list :documentation "A list of (ip-address ip-mask).") (refused-nets :initform nil :initarg :refused-nets :accessor refused-nets :type list :documentation "A list of (ip-address ip-mask).") (action :initform "action" :initarg :action :accessor action :type string :documentation "A string naming the action used in the HTML forms.") (title :initform "Untitled" :initarg :title :accessor title :type string :documentation "A string used as page title.") (body-attributes :initform nil :initarg :body-attributes :accessor body-attributes :type list :documentation "A list containing the HTML:BODY attributes.")) (:documentation "An abstract class of a HTML Transaction Program. This is the interface used by the HTRANS package to communicate with it.")) (defgeneric process-request (self session-id trans-id trans-data) (:documentation "A call-back function (hprogram session-id trans-id data) that will be called with the decoded request.")) (defgeneric refuse-remote (self session-id remote-ip) (:documentation "A call-back function called to display a message indicating that the remote was refused access for it's IP address.")) (defgeneric refuse-session (self session-id) (:documentation "A call-back function called to display a message indicating that the session-id is bad.")) (defgeneric generate-html-header (self session-id) (:documentation "A hook allowing the hprogram to display a header. It should not generate a form with the same action!")) (defgeneric generate-html-footer (self session-id) (:documentation "A hook allowing the hprogram to display a footer. It should not generate a form with the same action!")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; unix environment ;;; (defun unix-environment-get (environment name) " RETURN: The value of the unix environment variable named NAME. " (cdr (assoc name environment :test (function string=)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; IP ADDRESS MANIPULATION ;;; (defun bytep (thing) (and (integerp thing) (<= 0 thing) (<= thing 255))) (defun ip-string-to-address (ip-address) (let ((bytes (split-string ip-address "."))) ;; NOTE: This SPLIT-STRING takes only a literal pattern! (if (= 4 (length bytes)) (let* ((a (read-from-string (pop bytes))) (b (read-from-string (pop bytes))) (c (read-from-string (pop bytes))) (d (read-from-string (pop bytes)))) (if (and (bytep a) (bytep b) (bytep c) (bytep d)) (+ (* (+ (* (+ (* a 256) b) 256) c) 256) d) nil)) nil))) (defun address-in-lan-p (ip-string lan-address lan-mask) (let ((address (ip-string-to-address ip-string))) (setq lan-address (ip-string-to-address lan-address) lan-mask (ip-string-to-address lan-mask)) (and address (= (logand address lan-mask) (logand lan-address lan-mask))))) (defun address-in-subnets-p (address subnets) " ADDRESS: A string containing an IP address. SUBNETS: A list of (''address'' ''mask'') identifying the subnets. RETURN: Whether ADDRESS is on some of the SUBNETS. " (some (lambda (subnet) (address-in-lan-p address (first subnet) (second subnet))) subnets)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Session-ID ;;; (defvar *session-counter* 0) (defgeneric make-session-id (program ip-string)) (defgeneric check-session-id (program session-id ip-string)) (defmethod make-session-id ((htp hprogram) ip-string) (let ((stamp (+ (incf *session-counter* (* 1000000 (get-universal-time))))) (address (ip-string-to-address ip-string))) (format nil "~16R-~D" stamp address))) (defmethod check-session-id ((htp hprogram) session-id ip-string) (let* ((fields (split-string session-id "-")) (stamp (let ((*read-base* 16)) (read-from-string (first fields)))) (address (ip-string-to-address ip-string)) (check-id (format nil "~16R-~D" stamp address))) (string-equal check-id session-id))) (defvar +command-prefix+ "COMMAND-" "A prefix used for the INPUT names.") (defun getcmds (trans-data) " RETURN: A list of commands appearing in TRANS-DATA. NOTE: Normaly, only one command is present. But if the GET url is hacked, zero or multiple commands may be present. " (mapcan (lambda (var-val) (let ((var (first var-val))) (if (prefixp +command-prefix+ var) (list (subseq var (length +command-prefix+))) nil))) trans-data)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; HTRANS ;;; ;; html-client transac-manager cgi ;; | | | ;; | ;; | / ;; |--------(initial-request)------->| / ;; | |-----initialrequest(sessid)----->| ;; | | | ;; | |<------reply(sessid,trid)--------| ;; |<-------(html-form)--------------| / ;; | / ;; | ;; | / ;; |----------(action.get)---------->| / ;; | |----request(sesid,trid,data)---->| ;; | | | ;; | |<------reply(sessid,trid+1)------| ;; |<-------(html-form)--------------| / ;; | / ;; | ;; | | | ;; V V V ;; ;; (cgi:run args) ;; +--> (htrans:process-transaction hprog) ;; +--> (request hprog sess-id trans-id data) ;; +--> (htrans:reply hprog sess-id trans-id' title data cmds) ;; +--> (html:form...) (defmethod process-transaction ((htp hprogram)) " DO: Parses the CGI request and calls the REQUEST function passing it the session-id, transaction-id and request data. For the initial request, transaction-id and request data will be NIL. NOTE: Begins with outputing the HTML header and ends with the HTML footer. " (format t "Content-type: text/html; charset=iso-8859-1~A~A" +crlf+ +crlf+) (html:with-html-output (*standard-output*) (html:doctype :strict (html:html () (html:head () (html:title () (html:pcdata "~A" (title htp))) (html:meta (:http-equiv "Content-Type" :content "text/html; charset=iso-8859-1")) (html:meta (:name "generator" :content "COM.INFORMATIMAGO.COMMON-LISP.HTTP.HTRANS"))) (html:collect-element (html:body* (body-attributes htp) (let* ((environment (environment htp)) (remote-address (unix-environment-get environment "REMOTE_ADDR")) (query-string (unix-environment-get environment "QUERY_STRING")) (query-args (com.informatimago.common-lisp.http.hquery:query-parse query-string)) (session-id (or (com.informatimago.common-lisp.http.hquery:query-argument "SESSION-ID" query-args) (make-session-id htp remote-address)))) (list (generate-html-header htp session-id) (cond ((not (check-session-id htp session-id remote-address)) (refuse-session htp session-id)) ((and (or (not (allowed-nets htp)) (address-in-subnets-p remote-address (allowed-nets htp))) (or (not (refused-nets htp)) (not (address-in-subnets-p remote-address (refused-nets htp))))) (process-request htp session-id (com.informatimago.common-lisp.http.hquery:query-argument "TRANSAC-ID" query-args) query-args)) (t (refuse-remote htp session-id remote-address))) (generate-html-footer htp session-id))))))))) ;; transactions ;; ;; <-- command id command (name value)* ;; --> display id (title name ktype value comment)* command* ;; ;; label ::= NIL | STRING . ;; ktype ::= :LABEL ;; | :TEXTAREA | (:TEXTAREA [:COLS NUM] [:ROWS NUM]) ;; | :TEXT | (:TEXT [:MAXLENGTH NUMBER] [:SIZE NUMBER]) ;; | :PASSWORD | (:PASSWORD [:MAXLENGTH NUMBER] [:SIZE NUMBER]) ;; | :HIDDEN ;; | (:CHECKBOX (STRING [:CHECKED])) ;; | (:RADIO [:VERTICAL|:HORIZONTAL] (STRING [:CHECKED])*) ;; | (:MENU (NAME LABEL [:CHECKED]) ;; | (:GROUP LABEL (NAME LABEL [:CHECKED])*) * ) ;; | :FILE ;; ? ;; command ::= (:SUBMIT command label [:SIZE NUMBER]) ;; | (:RESET command label [:SIZE NUMBER]) ;; | (:IMAGE command image-url [:SIZE NUMBER]) (defun ktype (type) (if (listp type) (first type) type)) (defun ksize (type) (if (listp type) (cadr (member :size (cdr type))) nil)) (defun kmaxlength (type) (if (listp type) (cadr (member :maxlength (cdr type))) nil)) ;; | FIELD-TITLE | FIELD-NAME [ FIELD-VALUE ] | FIELD-COMMENT | ;; FIELD-TYPE (defun generate-menu-items (items) (mapcan (lambda (item) (cond ((symbolp item) '()) ((eq :group (first item)) (list (html:optgroup* (list :label (second item)) (generate-menu-items (cddr item))))) (t (list (html:option* (list :value (first item) (and (member :selected item) :selected)) (list (html:pcdata* "~A" (second item)))))))) items)) (defun generate-menu (name items) (html:select* (list :name name (when (member :multiple items) :multiple)) (generate-menu-items items))) (defun generate-command-buttons (commands) (mapcar (lambda (button) (let ((command (second button)) (label (third button)) (size (cadr (assoc :size button)))) (case (ktype button) (:submit (html:input* (list :name (format nil "~A~A" +command-prefix+ command) :type "SUBMIT" :value label (and size :size) size))) (:reset (html:input* (list :name (format nil "~A~A" +command-prefix+ command) :type "RESET" :value label (and size :size) size))) (:image (html:input* (list :name (format nil "~A~A" +command-prefix+ command) :type "IMAGE" :src label (and size :size))))))) commands)) (defmethod send-reply ((htp hprogram) session-id transac-id title data commands) (html:comment "SEND-REPLY") (html:comment "DATA=~S" data) (html:comment "COMMANDS=~S" commands) (html:h2 () (html:pcdata "~A" title)) (html:form (:method "GET" :action (action htp)) (let ((has-comments (some (lambda (field) (and (fifth field) (not (eq :hidden (ktype (third field)))))) data)) (hidden-fields '()) (visible-fields '())) (html:div () (html:input (:name "SESSION-ID" :type "HIDDEN" :value session-id)) (html:input (:name "TRANSAC-ID" :type "HIDDEN" :value transac-id)) (dolist (field data) (if (eq :hidden (ktype (third field))) (push field hidden-fields) (push field visible-fields))) (setq hidden-fields (nreverse hidden-fields) visible-fields (nreverse visible-fields)) (dolist (field hidden-fields) (let ((name (second field)) (value (fourth field))) (html:input (:name name :type 'hidden (when value :value) value))))) (html:table (:summary (format nil "SESSION ~A, TRANSACTION ~A" session-id transac-id) :width "95%") (dolist (field visible-fields) (let ((title (first field)) (name (second field)) (type (third field)) (value (fourth field)) (comment (fifth field))) (html:tr (:valign "TOP") (html:td () (if title (html:pcdata "~A" title) (format t "&nbsp;"))) ;; don't escape &nbsp;! ;; TODO: We need an HTML:PRINTQ or something... (html:td () (case (ktype type) (:label (html:pcdata "~A" value)) ((:text :password) (let ((ml (kmaxlength type)) (sz (ksize type))) (html:input (list :name name :type (if (eq (ktype type) :text) "TEXT" "PASSWORD") (when ml :maxlength) ml (when sz :size) sz (when value :value) value)))) (:textarea (error ":TEXTAREA NOT IMPLEMENTED IN DISPLAY.")) (:file (error ":FILE NOT IMPLEMENTED IN DISPLAY.")) (:checkbox (html:input (list :name name :type "CHECKBOX" :value (or value "ON") (and (eq :checked (third type)) :checked))) (html:pcdata "~A" (second type))) (:radio (let ((vertical (member :vertical type)) (titles (cdr type))) (when (symbolp (car titles)) (pop titles)) (if vertical (html:table (:summary "radio buttons") (dolist (title titles) (html:tr () (html:td () (html:input (list :name name :type "RADIO" :value (or (first title) "ON") (and (member :checked title) :checked))) (html:pcdata "~A" (second title)))))) (dolist (title titles) (html:input (list :name name :type "RADIO" :value (or (first title) "ON") (and (member :checked title) :checked))) (html:pcdata "~A " (second title)))))) (:menu (html:collect-element (generate-menu name type))))) (when has-comments (html:td () (if comment (html:pcdata "~A" comment) (html:html-string "&nbsp;"))))))) (html:tr () (html:td (:colspan (if has-comments 3 2)) (html:p () (html:collect-element (generate-command-buttons commands))))))))) (defmethod send-table ((htp hprogram) session-id transac-id title row-desc data commands) " DO: Sends a table. " (html:comment "SEND-TABLE") (html:comment "ROW-DESC=~S" row-desc) (html:comment "DATA=~S" data) (html:comment "COMMANDS=~S" commands) (html:h2 () (html:pcdata "~A" title)) (html:table (:summary title :width "95%") (mapc (lambda (row-data) ;; interpret a row (html:tr (:valign "TOP") (mapc (lambda (col-desc) (case (pop col-desc) (:label (html:td () (html:pcdata "~A" (nth (pop col-desc) row-data)))) (:submit (let ((command (pop col-desc)) (label (pop col-desc)) (size (when (eq :size (car col-desc)) (pop col-desc) (pop col-desc))) (hfields col-desc)) (html:td () (html:form (:method "GET" :action (action htp)) (html:div () (html:input (list :name "SESSION-ID" :type "HIDDEN" :value session-id)) (html:input (list :name "TRANSAC-ID" :type "HIDDEN" :value transac-id)) (html:input (list :name (format nil "~A~A" +command-prefix+ command) :type "SUBMIT" :value label (and size :size) size)) (mapc (lambda (hfield) (html:input (list :name (first hfield) :type "HIDDEN" :value (nth (second hfield) row-data)))) hfields)))))))) row-desc))) data)) (html:form (:method "GET" :action (action htp)) (html:p () (html:input (list :name "SESSION-ID" :type "HIDDEN" :value session-id)) (html:input (list :name "TRANSAC-ID" :type "HIDDEN" :value transac-id)) (html:collect-element (generate-command-buttons commands))))) ;;;; THE END ;;;;
25,388
Common Lisp
.lisp
564
35.074468
117
0.498949
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
fad45fa980bca1c129fcd83b57044a505692474b7f69ad33e291056e63d5d403
5,046
[ -1 ]
5,047
com.informatimago.common-lisp.data-encoding.test.asd
informatimago_lisp/common-lisp/data-encoding/com.informatimago.common-lisp.data-encoding.test.asd
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;*************************************************************************** ;;;;FILE: com.informatimago.common-lisp.data-encoding.test.asd ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: None ;;;;USER-INTERFACE: None ;;;;DESCRIPTION: ;;;; ;;;; This file defines the com.informatimago.common-lisp.data-encoding.test system. ;;;; Tests the com.informatimago.common-lisp.data-encoding system. ;;;; ;;;;USAGE: ;;;; ;;;;AUTHORS: ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS: ;;;; 2015-02-23 <PJB> Created. ;;;;BUGS: ;;;; ;;;;LEGAL: ;;;; ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;; ;;;;*************************************************************************** (asdf:defsystem "com.informatimago.common-lisp.data-encoding.test" ;; system attributes: :description "Tests the com.informatimago.common-lisp.data-encoding system." :author "Pascal J. Bourguignon <[email protected]>" :maintainer "Pascal J. Bourguignon <[email protected]>" :licence "AGPL3" ;; component attributes: :version "1.2.0" :properties ((#:author-email . "[email protected]") (#:date . "Winter 2015") ((#:albert #:output-dir) . "/tmp/documentation/com.informatimago.common-lisp.data-encoding.test/") ((#:albert #:formats) "docbook") ((#:albert #:docbook #:template) . "book") ((#:albert #:docbook #:bgcolor) . "white") ((#:albert #:docbook #:textcolor) . "black")) #+asdf-unicode :encoding #+asdf-unicode :utf-8 :depends-on ("com.informatimago.common-lisp.cesarum" "com.informatimago.common-lisp.data-encoding") :components ((:file "bencode-test" :depends-on ()) (:file "data-encoding-test" :depends-on ()) (:file "ieee-754-test" :depends-on ())) #+asdf3 :perform #+asdf3 (asdf:test-op (operation system) (declare (ignore operation system)) (dolist (p '("COM.INFORMATIMAGO.COMMON-LISP.DATA-ENCODING.BENCODE.TEST" "COM.INFORMATIMAGO.COMMON-LISP.DATA-ENCODING.DATA-ENCODING.TEST" "COM.INFORMATIMAGO.COMMON-LISP.DATA-ENCODING.IEEE-754.TEST")) (let ((*package* (find-package p))) (uiop:symbol-call p "TEST/ALL"))))) ;;;; THE END ;;;;
3,377
Common Lisp
.lisp
70
40.885714
105
0.558548
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
dd8dcbf94c6493c9c4e9090ea11c8d176d67d63d8382a3b97cd94e771d02d8d9
5,047
[ -1 ]
5,048
bencode.lisp
informatimago_lisp/common-lisp/data-encoding/bencode.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: bencode.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; See defpackage documentation string. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2010-12-08 <PJB> Created, inspired from Alex Schroeder's emacs lisp 'bencode.el'. ;;;;BUGS ;;;; We don't deal with encodings, relying on CHAR-CODE and CODE-CHAR. ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2010 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.DATA-ENCODING.BENCODE" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.LIST") (:export "BENCODE-TO-STRING" "BDECODE-FROM-STRING" "BENCODE-TO-CHARACTER-STREAM" "BDECODE-FROM-CHARACTER-STREAM" "BENCODE-TO-BINARY-STREAM" "BDECODE-FROM-BINARY-STREAM" "*KEY-MAP-EXCEPTIONS*" "*TORRENT-KEY-MAP-EXCEPTIONS*") (:documentation " Bencoding is a way to encode integers, strings, lists, and hash-tables as strings (serialization), and bdecoding does the reverse operation. It is part of the torrent metafile specification at http://bittorrent.org/beps/bep_0003.html Notice that torrent files are binary files, since they contain strings with octets instead of characters. Data encoded and decoded ------------------------ +----------------------+----------------------+----------------------+ | Lisp type | BEncoded type | Lisp type | +----------------------+----------------------+----------------------+ | integer | integer (i) | integer | +----------------------+----------------------+----------------------+ | octets | string (:) | string or octets¹ | +----------------------+----------------------+----------------------+ | string | string (:) | string or octets¹ | +----------------------+----------------------+----------------------+ | symbol | string (:) | string² | +----------------------+----------------------+----------------------+ | character | string (:) | string | +----------------------+----------------------+----------------------+ | hash-table³ | dict (d) | hash-table | +----------------------+----------------------+----------------------+ | list | list (l) | list | +----------------------+----------------------+----------------------+ ¹: OCTETS are a vector of (unsigned-byte 8), if a string contains only the standard characters, then it's read as a string, otherwise as an OCTETS. ²: in a dict, key strings can be converted into symbols. ³: all keys must be string designators. Key map ------- Encoded dictionaries use strings as key. Sometimes, the string contains spaces, sometimes it contains dashes. It could contain any characters. By default, we map keywords to strings by merely downcasing them (and vice-versa, by interning the upcased string in the KEYWORD package). To map keywords to a different string, we use key-map-exceptions. Since dictionaries may contain other dictionaries as values, an entry in the key-map-exceptions may specify another key-map-exceptions to be used when reading the value of the dictionary entry. A key-map-exceptions is an a-list mapping keywords to either: - a string, or - a p-list containing the keys :string and/or :key-map. The string substitutes the keyword in the serialized dictionary; the key-map is another key-map exceptions a-list to be used when reading the value of that dictionary entry. *TORRENT-KEY-MAP-EXCEPTIONS* is the key-map-exceptions that can be used to read and write torrent files, binding it to *KEY-MAP-EXCEPTIONS*. Decoding BEncoded strings or streams ------------------------------------ :: (with-open-stream (torrent \"example.torrent\" :element-type '(unsigned-byte 8)) ;; torrent files contain binary 'strings'... (let ((*key-map-exceptions* *torrent-key-map-exceptions*)) (bdecode-from-binary-stream torrent))) (with-open-stream (stream \"file.bencoded\") (bdecode-from-character-stream torrent)) (bdecode-from-string \"li43e4:spaml4:spam4:eggsed3:cow3:moo4:spam4:eggsed4:spaml1:a1:beee\") Encoding BEncoded strings or streams ------------------------------------ :: (with-open-stream (torrent \"example.torrent\" :element-type '(unsigned-byte 8) :direction :output :if-does-not-exist :create :if-exists :supersede) ;; torrent files contain binary 'strings'... (let ((*key-map-exceptions* *torrent-key-map-exceptions*)) (bencode-to-binary-stream object torrent))) (with-open-stream (stream \"file.bencoded\" :direction :output :if-does-not-exist :create :if-exists :supersede) (bencode-to-character-stream object stream)) (bencode-to-string (list 42 '(\"aa\" bb #\\c :dd) (hashtable :elements '((one 1) (\"two\" \"2\") (:three-and-one-third (x x x)))) (hashtable :elements '((:one 1) (:two \"2\") (:three-and-one-third (x x x)))))) --> \"li42el2:aa2:BB1:c2:DDed3:onei1e19:three-and-one-thirdl1:X1:X1:Xe3:two1:2ed3:onei1e19:three-and-one-thirdl1:X1:X1:Xe3:two1:2ee\" License: AGPL3 Copyright Pascal J. Bourguignon 2010 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.DATA-ENCODING.BENCODE") (defvar *key-map-exceptions* nil "Current key-map exceptions. A key-map-exceptions is an a-list mapping keywords to either: - a string, or - a p-list containing the keys :string and/or :key-map. The string substitutes the keyword in the serialized dictionary; the key-map is another key-map exceptions a-list to be used when reading the value of that dictionary entry. ") (defparameter *torrent-key-map-exceptions* '((:created-by . "created by") (:creation-date . "creation date") (:info . (:string "info" :key-map ((:piece-length . "piece length"))))) "Key-map exceptions for torrent files.") (defun key-map-entry-for-key (keyword) (assoc keyword *key-map-exceptions*)) (defun key-map-entry-with-string (key-string) (find-if (lambda (entry) (string= key-string (if (stringp (cdr entry)) (cdr entry) (getf (cdr entry) :string)))) *key-map-exceptions*)) (defun key-map-entry-keyword (entry) (car entry)) (defun key-map-entry-string (entry) (if (stringp (cdr entry)) (cdr entry) (getf (cdr entry) :string))) (defun key-map-entry-key-map (entry) (if (stringp (cdr entry)) nil (getf (cdr entry) :key-map))) (defun key-map-exception (keyword) (key-map-entry-key-map (key-map-entry-for-key keyword))) (defun encode-key-map-exception (keyword) "Searches in *KEY-MAP-EXCEPTIONS* an exceptional mapping of the keyword KEYWORD." (key-map-entry-string (key-map-entry-for-key keyword))) (defun decode-key-map-exception (key-string) "Searches in *KEY-MAP-EXCEPTIONS* an exceptional mapping of the string KEY-STRING." (key-map-entry-keyword (key-map-entry-with-string key-string))) (defun encode-key (keyword) (or (encode-key-map-exception keyword) (string-downcase keyword))) (defun decode-key (key-string) (or (decode-key-map-exception key-string) (intern (string-upcase key-string) "KEYWORD"))) ;;;------------------------------------------------------------------------ ;;; ;;; STREAM-WRAPPER ;;; (defclass stream-wrapper () ((stream :initarg :stream :reader get-stream))) (defmethod print-object ((self stream-wrapper) stream) (let ((*print-readably* nil)) (print-unreadable-object (self stream :identity t :type t) (format stream ":stream ~S" (if (slot-boundp self 'stream) (slot-value self 'stream) "#<UNBOUND>")))) self) (defgeneric stream-write-string (string stream-wrapper)) (defgeneric stream-write-octets (octets stream-wrapper)) (defgeneric stream-peek-char (stream-wrapper &optional eof-error-p eof-value)) (defgeneric stream-read-char (stream-wrapper &optional eof-error-p eof-value)) (defgeneric stream-read-string (string stream-wrapper)) (defgeneric stream-read-octets (octets stream-wrapper)) ;;;------------------------------------------------------------------------ ;;; ;;; BINARY-STREAM ;;; ;; NOTE: for BINARY-STREAM we encode and decode the characters with ;; CODE-CHAR annd CHAR-CODE. Instead we should use encoding ;; functions including utf-8 and other coding systems. (defclass binary-stream (stream-wrapper) ((peeked-bytes :initform nil :documentation "When stream-peek-char is used the bytes read are stored here. They'll be read or peeked again before further reading of the stream."))) (defmethod stream-write-string (string (stream binary-stream)) (write-sequence (map 'vector (function char-code) string) (get-stream stream)) string) (defmethod stream-write-octets (octets (stream binary-stream)) (write-sequence octets (get-stream stream)) octets) (defmethod stream-peek-char ((stream binary-stream) &optional (eof-error-p t) eof-value) (with-slots (peeked-bytes) stream (unless peeked-bytes (let ((byte (read-byte (get-stream stream) nil nil))) (cond (byte (push byte peeked-bytes)) (eof-error-p (error 'end-of-file :stream (get-stream stream))) (t (return-from stream-peek-char eof-value))))) (code-char (elt peeked-bytes 0)))) (defmethod stream-read-char ((stream binary-stream) &optional (eof-error-p t) eof-value) (with-slots (peeked-bytes) stream (code-char (if peeked-bytes (pop peeked-bytes) (read-byte (get-stream stream) eof-error-p eof-value))))) (defmethod stream-read-string (string (stream binary-stream)) (let ((octets (make-array (length string) :element-type '(unsigned-byte 8) :initial-element 0))) (stream-read-octets octets stream) (map-into string (function code-char) octets) string)) (defmethod stream-read-octets (octets (stream binary-stream)) (with-slots (peeked-bytes) stream (let ((start 0)) (when peeked-bytes (replace octets (reverse peeked-bytes)) (setf start (length peeked-bytes) peeked-bytes nil)) (let ((read-size (read-sequence octets (get-stream stream) :start start)) (size (- (length octets) start))) (assert (= size read-size) () "Could not read the ~D bytes of the string." size) octets)))) ;;;------------------------------------------------------------------------ ;;; ;;; CHARACTER-STREAM ;;; (defclass character-stream (stream-wrapper) ()) (defmethod stream-write-string (string (stream character-stream)) (write-string string (get-stream stream)) string) (defmethod stream-write-octets (octets (stream character-stream)) (write-sequence (map 'vector (function code-char) octets) (get-stream stream)) octets) (defmethod stream-peek-char ((stream character-stream) &optional (eof-error-p t) eof-value) (peek-char nil (get-stream stream) eof-error-p eof-value)) (defmethod stream-read-char ((stream character-stream) &optional (eof-error-p t) eof-value) (read-char (get-stream stream) eof-error-p eof-value)) (defmethod stream-read-string (string (stream character-stream)) (let ((read-size (read-sequence string (get-stream stream)))) (assert (= (length string) read-size) () "Could not read the ~D bytes of the string." (length string)) string)) (defmethod stream-read-octets (octets (stream character-stream)) (let* ((size (length octets)) (string (make-string size)) (read-size (read-sequence string (get-stream stream)))) (assert (= size read-size) () "Could not read the ~D bytes of the string." size) (map-into octets (function char-code) string))) ;;;------------------------------------------------------------------------ ;;; ;;; Serializer ;;; (defgeneric encode-object (value stream)) (defmethod encode-object ((value integer) stream) (stream-write-string (format nil "i~Ae" value) stream) value) (defmethod encode-object ((value string) stream) (stream-write-string (format nil "~A:" (length value)) stream) (stream-write-string value stream) value) (defmethod encode-object ((value vector) stream) (assert (every (lambda (byte) (typep byte '(integer 0 255))) value)) (stream-write-string (format nil "~A:" (length value)) stream) (stream-write-octets value stream) value) (defmethod encode-object ((value symbol) stream) (encode-object (string value) stream) value) (defmethod encode-object ((value character) stream) (encode-object (string value) stream) value) (defmethod encode-object ((value list) stream) (stream-write-string "l" stream) (dolist (item value) (encode-object item stream)) (stream-write-string "e" stream) value) (defmethod encode-object ((value hash-table) stream) (stream-write-string "d" stream) (loop :for (key-string key . val) :in (sort (mapcar (lambda (entry) (cons (encode-key (car entry)) entry)) (hash-table-entries value)) ;; http://bittorrent.org/beps/bep_0003.html ;; "Keys must be strings and appear in sorted order ;; (sorted as raw strings, not alphanumerics)." ;; http://en.wikipedia.org/wiki/Bencode ;; "All keys must be byte strings and must appear in lexicographical order." ;; What does this mean? The encoding is not specified! ;; This probably mean that string< is wrong anyways... (function string<) :key (function car)) :do (progn (encode-object key-string stream) (let ((*key-map-exceptions* (key-map-exception key))) (encode-object val stream)))) (stream-write-string "e" stream) value) (defun encode-octets (octets binary-stream) (stream-write-string (format nil "~A:" (length octets)) binary-stream) (write-sequence octets binary-stream)) ;;;------------------------------------------------------------------------ ;;; ;;; Deserializer ;;; (defun decode-raw-cardinal (stream) "Read a sequence of digits, converting them into a positive integer. There must be at least one digit." (if (digit-char-p (stream-peek-char stream nil nil)) (loop :with n = 0 :while (digit-char-p (stream-peek-char stream nil nil)) :do (setf n (+ (* 10 n) (digit-char-p (stream-read-char stream)))) :finally (return n)) (error "Expected an integer in stream, but got ~A instead." (stream-read-char stream nil nil)))) (defun decode-raw-integer (stream) "Reads a integer composed of an optional minus sign, and a sequence of at least one digit." (if (char= #\- (stream-peek-char stream)) (progn (stream-read-char stream) (- (decode-raw-cardinal stream))) (decode-raw-cardinal stream))) (defun eat-end (stream context &rest arguments) (let ((end (stream-read-char stream t))) (unless (char-equal #\e end) (error "Expected #\\e instead of ~S after ~?" end context arguments)))) (defun looking-at-end (stream) (char-equal #\e (stream-peek-char stream nil #\return))) (defun decode-integer (stream) (assert (char-equal #\i (stream-read-char stream))) (let ((value (decode-raw-integer stream))) (check-type value integer) (eat-end stream "the integer ~A" value) value)) (defun decode-octets (stream) (let* ((len (decode-raw-cardinal stream))) (check-type len integer) (let ((separator (stream-read-char stream))) (assert (char= #\: separator) () "Expected a colon after the length of the string, not ~C" separator)) (stream-read-octets (make-array len :element-type '(unsigned-byte 8) :initial-element 0) stream))) (defparameter *character-codes* (map 'vector (function char-code) ;; Standard characters: " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~")) (defun character-code-p (code) (find code *character-codes*)) (defun decode-string (stream) (let* ((len (decode-raw-cardinal stream))) (check-type len integer) (let ((separator (stream-read-char stream))) (assert (char= #\: separator) () "Expected a colon after the length of the string, not ~C" separator)) (let ((octets (stream-read-octets (make-array len :element-type '(unsigned-byte 8) :initial-element 0) stream))) (if (every (function character-code-p) octets) (map 'string (function code-char) octets) octets)))) (defun decode-list (stream) (assert (char-equal #\l (stream-read-char stream))) (loop :until (looking-at-end stream) :collect (decode-object stream) :finally (eat-end stream "a list"))) (defun decode-dictionary (stream) (assert (char-equal #\d (stream-read-char stream))) (loop :with dict = (make-hash-table) :until (looking-at-end stream) :do (let ((key (decode-key (decode-object stream)))) (let ((*key-map-exceptions* (key-map-exception key))) (setf (gethash key dict) (decode-object stream)))) :finally (progn (eat-end stream "a dictionary") (return dict)))) (defun decode-object (stream) (let ((type-char (stream-peek-char stream))) (case (char-downcase type-char) ((#\i) (decode-integer stream)) ((#\d) (decode-dictionary stream)) ((#\l) (decode-list stream)) ((#\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9) (decode-string stream)) (otherwise (stream-read-char stream) (error "Unexpected type character in bencoded stream: ~C" type-char))))) (defun decode (stream) "Reads a BEncoded object from the STREAM stream-wrapper." (with-standard-io-syntax (decode-object stream))) ;;;------------------------------------------------------------------------ ;;; ;;; Entry points. ;;; (defun bdecode-from-binary-stream (input) "Reads a BEncoded object from the INPUT binary stream." (decode (make-instance 'binary-stream :stream input))) (defun bencode-to-binary-stream (object output) "Writes a BEncoded OBJECT to the OUTPUT binary stream." (encode-object object (make-instance 'binary-stream :stream output))) (defun bdecode-from-character-stream (input) "Reads a BEncoded object from the INPUT character stream." (decode (make-instance 'character-stream :stream input))) (defun bencode-to-character-stream (object output) "Writes a BEncoded OBJECT to the OUTPUT character stream." (encode-object object (make-instance 'character-stream :stream output))) (defun bencode-to-string (object) "Returns a string containing the BEncoded OBJECT." (with-output-to-string (output) (bencode-to-character-stream object output))) (defun bdecode-from-string (bencoded-string) "Returns the object BEncoded in the BENCODED-STRING." (with-input-from-string (input bencoded-string) (bdecode-from-character-stream input))) ;;;; THE END ;;;;
21,539
Common Lisp
.lisp
453
42.216336
136
0.620737
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
53196cc6d70d87e3d0e2b82060d0730e073769867e5aa4ce406c828dfe4a74f6
5,048
[ -1 ]
5,049
ieee-754-test.lisp
informatimago_lisp/common-lisp/data-encoding/ieee-754-test.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: ieee-754-test.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Test ieee-754.lisp. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2015-02-25 <PJB> Extracted from ieee-754.lisp ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.DATA-ENCODING.IEEE-754.TEST" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SIMPLE-TEST" "COM.INFORMATIMAGO.COMMON-LISP.DATA-ENCODING.IEEE-754") (:export "TEST/ALL")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.DATA-ENCODING.IEEE-754.TEST") (defun test-ieee-read-double () (with-open-file (in "value.ieee-754-double" :direction :input :element-type '(unsigned-byte 8)) (loop :while (< (file-position in) (file-length in)) :do (loop :for i = 1 :then (* i 256) :for v = (read-byte in) :then (+ v (* i (read-byte in))) :repeat 8 :finally (let ((*print-base* 16)) (princ v)) (princ " ") (princ (ieee-754-to-float-64 v)) (terpri))))) (defun test-ieee-read-single () (with-open-file (in "value.ieee-754-single" :direction :input :element-type '(unsigned-byte 8)) (loop :while (< (file-position in) (file-length in)) :do (loop :for i = 1 :then (* i 256) :for v = (read-byte in) :then (+ v (* i (read-byte in))) :repeat 4 :finally (let ((*print-base* 16)) (princ v)) (princ " ") (princ (ieee-754-to-float-32 v)) (terpri))))) (defun test-single-to-ieee (&rest args) (dolist (arg args) (format t "(#x~16,8,'0R ~A)~%" (float-32-to-ieee-754 (coerce arg 'single-float)) arg))) (defun test-double-to-ieee (&rest args) (dolist (arg args) (format t "(#x~16,16,'0R ~A)~%" (float-64-to-ieee-754 (coerce arg 'double-float)) arg))) (defparameter *singles* '((#x00000000 0.0f0) (#x00000000 -0.0f0) (#x0DA24260 1.0F-30) (#x1E3CE508 1.0F-20) (#x2EDBE6FF 1.0F-10) (#x3F800000 1.0) (#x3F99999A 1.2f0) (#x41400000 12.0f0) (#x42F00000 120.0f0) (#x44960000 1200.0f0) (#x449A5225 1234.567f0) (#x501502F9 1.0F+10) (#x60AD78EC 1.0F+20) (#x7149F2CA 1.0F+30) (#x8DA24260 -1.0F-30) (#x9E3CE508 -1.0F-20) (#xAEDBE6FF -1.0F-10) (#xBF800000 -1.0f0) (#xBFC00000 -1.5f0) (#xC1700000 -15.0f0) (#xC3160000 -150.0f0) (#xC49A5225 -1234.567f0) (#xC4BB8000 -1500.0f0) (#xD01502F9 -1.0F+10) (#xE0AD78EC -1.0F+20) (#xF149F2CA -1.0F+30))) (define-test test/encode-single () (loop :for (expected single) :in *singles* :for converted = (float-32-to-ieee-754 single) :do (assert-true (= expected converted) (converted expected single)))) (define-test test/decode-single () (loop :for (ieee expected) :in *singles* :for converted = (ieee-754-to-float-32 ieee) :do (assert-true (= expected converted) (converted expected ieee)))) (defparameter *doubles* '((#x0000000000000000 0.0d0) (#x0000000000000000 -0.0d0) (#x3FF3333333333333 1.2d0) (#x4028000000000000 12.0d0) (#x405E000000000000 120.0d0) (#x4092C00000000000 1200.0d0) (#x40934A449BA5E354 1234.567d0) (#xC202A05F20000000 -1.0D+10) (#x4202A05F20000000 1.0D+10) (#xC415AF1D78B58C40 -1.0D+20) (#x4415AF1D78B58C40 1.0D+20) (#xC6293E5939A08CEA -1.0D+30) (#x46293E5939A08CEA 1.0D+30) (#xBDDB7CDFD9D7BDBB -1.0D-10) (#x3DDB7CDFD9D7BDBB 1.0D-10) (#xBBC79CA10C924223 -1.0D-20) (#x3BC79CA10C924223 1.0D-20) (#xB9B4484BFEEBC2A0 -1.0D-30) (#x39B4484BFEEBC2A0 1.0D-30))) (define-test test/encode-double () (loop :for (expected double) :in *doubles* :for converted = (float-64-to-ieee-754 double) :do (assert-true (= expected converted) (converted expected double)))) (define-test test/decode-double () (loop :for (ieee expected) :in *doubles* :for converted = (ieee-754-to-float-64 ieee) :do (assert-true (= expected converted) (converted expected ieee)))) #-(and) (progn (test-single-to-ieee -1f10 1f10 -1f20 1f20 -1f30 1f30 -1f-10 1f-10 -1f-20 1f-20 -1f-30 1f-30) (test-double-to-ieee 1.2d0 12.0d0 120.0d0 1200.0d0 1234.567d0 -1d10 1d10 -1d20 1d20 -1d30 1d30 -1d-10 1d-10 -1d-20 1d-20 -1d-30 1d-30) ) (define-test test/all () (test/encode-single) (test/decode-single) (test/encode-double) (test/decode-double)) ;;;; THE END ;;;;
7,005
Common Lisp
.lisp
150
33.153333
83
0.495242
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
9d2fa3bc4ea1ef97ccb52fc3d84a010dfc5413879702d45be3994119e932e3c0
5,049
[ -1 ]
5,050
hexadecimal.lisp
informatimago_lisp/common-lisp/data-encoding/hexadecimal.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: hexadecimal.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Encode and decode hexadecimal strings. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2013-10-06 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2013 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.DATA-ENCODING.HEXADECIMAL" (:use "COMMON-LISP") (:export "BYTES-TO-HEXADECIMAL-STRING" "BYTES-FROM-HEXADECIMAL-STRING") (:documentation " This package exports functions to encode and decode byte vector buffer into hexadecimal strings. License: AGPL3 Copyright Pascal J. Bourguignon 2013 - 2013 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.DATA-ENCODING.HEXADECIMAL") (defun decode-byte (digit-per-byte byte-sex sex-width base input) (let ((buffer (make-string digit-per-byte))) (ecase byte-sex (:big-endian (loop :for i :below digit-per-byte :do (setf (aref buffer i) (read-char input)))) (:little-endian ;; ddccbba --> abbccdd (loop :with s = 0 :with i = (- digit-per-byte sex-width) :repeat digit-per-byte :do (setf (aref buffer i) (read-char input)) (incf i) (incf s) (when (<= sex-width s) (setf s 0) (decf i (* 2 sex-width)) (when (minusp i) (setf i 0)))))) (parse-integer buffer :radix base :junk-allowed nil))) (assert (= (with-input-from-string (input "0123456789abcdef") (decode-byte 4 :big-endian 2 16 input)) #x0123)) (assert (= (with-input-from-string (input "0123456789abcdef") (decode-byte 4 :little-endian 2 16 input)) #x2301)) (defun decode (string element-type digit-per-byte byte-sex sex-width base) (let ((bytes (make-array (ceiling (length string) digit-per-byte) :element-type (or element-type (list 'unsigned-byte (integer-length (1- (expt base digit-per-byte)))))))) (with-input-from-string (input string) (loop :for i :below (length bytes) :do (setf (aref bytes i) (decode-byte digit-per-byte byte-sex sex-width base input)))) bytes)) (assert (string= (map 'string 'code-char (decode "6b7569706572" '(unsigned-byte 8) 2 :big-endian 1 16)) "kuiper")) (assert (string= (map 'string 'code-char (decode "4d49542d4d414749432d434f4f4b49452d31" '(unsigned-byte 8) 2 :big-endian 1 16)) "MIT-MAGIC-COOKIE-1")) (defun encode-byte (byte padding byte-sex sex-width base case output) (let ((digits (format nil (if (eq case :downcase) "~(~V,V,'0R~)" "~:@(~V,V,'0R~)") base padding byte))) (ecase byte-sex (:big-endian (princ digits output)) (:little-endian (loop :for end :downfrom (length digits) :by sex-width :for start = (max 0 (- end sex-width)) :while (plusp end) :do (princ (subseq digits start end) output)))))) (assert (string= (with-output-to-string (output) (encode-byte #xbabeface00 10 :little-endian 4 16 :upcase output)) "CE00BEFABA")) (defun encode (byte-vector padding byte-sex sex-width base case) (with-output-to-string (output) (loop :for byte :across byte-vector :do (encode-byte byte padding byte-sex sex-width base case output)))) (assert (string= (encode #(#xba #xbe #xfa #xce) 2 :little-endian 1 16 :downcase) "abebafec")) (assert (string= (encode #(#xbabeface #xb19b00b5 #xdeadface) 12 :little-endian 2 16 :downcase) "cefabeba0000b5009bb10000cefaadde0000")) (defun validate-integer (object) (check-type object integer) object) (defun parse-element-type (element-type) (when (atom element-type) (error "Expected an element-type specifying the byte size, not ~S." element-type)) (case (first element-type) ((unsigned-byte) (values (validate-integer (second element-type)) nil)) ((signed-byte (values (validate-integer (second element-type)) t))) ((integer) (let ((lower (validate-integer (second element-type))) (upper (validate-integer (third element-type)))) (assert (<= lower upper) () "Invalid integer type ~S" element-type) (if (minusp lower) (values (1+ (integer-length (if (minusp upper) (1- (abs lower)) (max (1- (abs lower)) upper)))) t) (values (integer-length (max (abs lower) (abs upper))) nil)))) (otherwise (error "Expected an UNSIGNED-BYTE, SIGNED-BYTE or INTEGER element-type specifying the byte size, not ~S." element-type)))) ;; (parse-element-type '(integer 0 15)) ;; (parse-element-type '(integer -1 9)) (defun bytes-to-hexadecimal-string (byte-vector &key (element-type nil) (padding nil) (byte-sex :big-endian) (case :downcase)) " ELEMENT-TYPE: The element-type of the BYTE-VECTOR (if NIL, then (ARRAY-ELEMENT-TYPE BYTE-VECTOR) is used. PADDING: When NIL, the number of hexadecimal digits per byte is the minimum required (a vector of (unsigned-byte 3) would use one hexadecimal digit per element). Otherwise it's at least PADDING. BYTE-SEX: When more than one octet are needed to store the bytes, they're ordered according to the byte-sex: :big-endian most significant octets first. :little-endian least significant octets first. Notice that the quads in the octets are always stored first. RETURN: A string containing the hexadecimal digits representing the vector. " (multiple-value-bind (bits signed) (parse-element-type (or element-type (array-element-type byte-vector))) (when signed (error "Not implemented yet")) (encode byte-vector (or padding (ceiling bits 4)) byte-sex 2. 16. case))) #-(and) (bytes-to-hexadecimal-string (coerce (loop for i from 0 to 255 collect i) 'vector) :element-type '(unsigned-byte 8) :padding 4 :byte-sex :little-endian :case :upcase) (defun bytes-from-hexadecimal-string (string &key (element-type nil) (padding nil) (byte-sex :big-endian) (case :downcase)) " ELEMENT-TYPE: The element-type of the BYTE-VECTOR (if NIL, then (unsigned-byte 8) is used). PADDING: When NIL, the number of hexadecimal digits per byte is the minimum required (a vector of (unsigned-byte 3) would use one hexadecimal digit per element). Otherwise it's at least PADDING. BYTE-SEX: When more than one octet are needed to store the bytes, they're ordered according to the byte-sex: :big-endian most significant octets first. :little-endian least significant octets first. Notice that the quads in the octets are always stored first. RETURN: A string containing the hexadecimal digits representing the vector. " (declare (ignore case)) (multiple-value-bind (bits signed) (parse-element-type (or element-type '(unsigned-byte 8))) (when signed (error "Not implemented yet")) (decode string (or element-type '(unsigned-byte 8)) (or padding (ceiling bits 4)) byte-sex 2. 16.))) (assert (equalp (bytes-from-hexadecimal-string "4d49542d4d414749432d434f4f4b49452d31") #(77 73 84 45 77 65 71 73 67 45 67 79 79 75 73 69 45 49))) ;;;; THE END ;;;;
9,845
Common Lisp
.lisp
211
38.146919
127
0.610426
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
0e5014c177d7654ab4a2ad7401526937a0e50b5b7e13e49b0fdb15f26f4a74c7
5,050
[ -1 ]
5,051
com.informatimago.common-lisp.data-encoding.asd
informatimago_lisp/common-lisp/data-encoding/com.informatimago.common-lisp.data-encoding.asd
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: com.informatimago.common-lisp.data-encoding.asd ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; ASD file to load the com.informatimago.common-lisp.data-encoding library. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2012-02-05 <PJB> Added ecp. ;;;; 2010-12-09 <PJB> Added bencode. ;;;; 2010-10-31 <PJB> Created this .asd file. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2010 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see http://www.gnu.org/licenses/ ;;;;************************************************************************** (asdf:defsystem "com.informatimago.common-lisp.data-encoding" ;; system attributes: :description "Informatimago Common Lisp Various Data Encoding/Decoding Algorithms." :long-description " Various Data Encoding/Decoding Algorithms: - data-encoding: a specific way to encode and decode data in a byte vector buffer. - bencode: the encoding used by Torrent files; - ecp: Minitel-1b Error Correction Procedure; " :author "Pascal J. Bourguignon <[email protected]>" :maintainer "Pascal J. Bourguignon <[email protected]>" :licence "AGPL3" ;; component attributes: :version "1.4.0" :properties ((#:author-email . "[email protected]") (#:date . "Autumn 2010") ((#:albert #:output-dir) . "/tmp/documentation/com.informatimago.common-lisp.data-encoding/") ((#:albert #:formats) . ("docbook")) ((#:albert #:docbook #:template) . "book") ((#:albert #:docbook #:bgcolor) . "white") ((#:albert #:docbook #:textcolor) . "black")) #+asdf-unicode :encoding #+asdf-unicode :utf-8 :depends-on ("com.informatimago.common-lisp.cesarum" "com.informatimago.common-lisp.arithmetic") :components ((:file "data-encoding" :depends-on ()) (:file "bencode" :depends-on ()) (:file "hexadecimal" :depends-on ()) (:file "ecp" :depends-on ()) (:file "ieee-754" :depends-on ())) #+adsf3 :in-order-to #+adsf3 ((asdf:test-op (asdf:test-op "com.informatimago.common-lisp.data-encoding.test")))) ;;;; THE END ;;;;
3,189
Common Lisp
.lisp
67
43.597015
117
0.597624
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
bcb2d6012e2c710f740ffb237556aa83312e9afc992f9ca1166dbf151bb52b64
5,051
[ -1 ]
5,052
ieee-754.lisp
informatimago_lisp/common-lisp/data-encoding/ieee-754.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: ieee-754.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Export functions to encode/decode IEEE-754 floating point numbers. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2015-02-25 <PJB> Extracted from heap.lisp. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.DATA-ENCODING.IEEE-754" (:use "COMMON-LISP") (:export "FLOAT-32-TO-IEEE-754" "IEEE-754-TO-FLOAT-32" "FLOAT-64-TO-IEEE-754" "IEEE-754-TO-FLOAT-64" "GEN-IEEE-ENCODING")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.DATA-ENCODING.IEEE-754") ;; [floatx[0,6] v6 v5 v4 | v3 v2 v1 v0] (defmacro gen-ieee-encoding (name type exponent-bits mantissa-bits) ;; Thanks to ivan4th ([email protected]) for correcting an off-by-1 `(progn (defun ,(intern (with-standard-io-syntax (format nil "~A-TO-IEEE-754" name)) (symbol-package name)) (float) "Convert FLOAT to a IEEE-753 representation stored in an integer." (if (zerop float) 0 (multiple-value-bind (mantissa exponent sign) (integer-decode-float float) (dpb (if (minusp sign) 1 0) (byte 1 ,(1- (+ exponent-bits mantissa-bits))) (dpb (+ ,(+ (- (expt 2 (1- exponent-bits)) 2) mantissa-bits) exponent) (byte ,exponent-bits ,(1- mantissa-bits)) (ldb (byte ,(1- mantissa-bits) 0) mantissa)))))) (defun ,(intern (with-standard-io-syntax (format nil "IEEE-754-TO-~A" name)) (symbol-package name)) (ieee) "Convert the IEEE representation (stored as an integer) into a floating point number." (if (zerop ieee) ,(coerce 0 type) (let ((aval (scale-float (coerce (dpb 1 (byte 1 ,(1- mantissa-bits)) (ldb (byte ,(1- mantissa-bits) 0) ieee)) ',type) (- (ldb (byte ,exponent-bits ,(1- mantissa-bits)) ieee) ,(1- (expt 2 (1- exponent-bits))) ,(1- mantissa-bits))))) (if (zerop (ldb (byte 1 ,(1- (+ exponent-bits mantissa-bits))) ieee)) aval (- aval))))))) ;; Yet another sbcl bug: #-sbcl (gen-ieee-encoding float-32 single-float 8 24) #-sbcl (gen-ieee-encoding float-64 double-float 11 53) ;;;; THE END ;;;;
3,723
Common Lisp
.lisp
82
37.670732
93
0.556534
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
1816db5151594ed0d02e2aab3107b9f59a71420cbb9c241cbf906c8af3469e77
5,052
[ -1 ]
5,053
data-encoding-test.lisp
informatimago_lisp/common-lisp/data-encoding/data-encoding-test.lisp
;;;; -*- coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: data-encoding-test.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Some test cases of COM.INFORMATIMAGO.COMMON-LISP.DATA-ENCODING.DATA-ENCODING. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2004-06-20 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; GPL ;;;; ;;;; Copyright Pascal J. Bourguignon 2004 - 2016 ;;;; ;;;; This program is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU General Public License ;;;; as published by the Free Software Foundation; either version ;;;; 2 of the License, or (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be ;;;; useful, but WITHOUT ANY WARRANTY; without even the implied ;;;; warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ;;;; PURPOSE. See the GNU General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU General Public ;;;; License along with this program; if not, write to the Free ;;;; Software Foundation, Inc., 59 Temple Place, Suite 330, ;;;; Boston, MA 02111-1307 USA ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.DATA-ENCODING.DATA-ENCODING.TEST" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SIMPLE-TEST" "COM.INFORMATIMAGO.COMMON-LISP.DATA-ENCODING.DATA-ENCODING")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.DATA-ENCODING.DATA-ENCODING.TEST") (eval-when (:compile-toplevel :load-toplevel :execute) (def-enctype buint8 () (number unsigned 1 big-endian)) (def-enctype buint16 () (number unsigned 2 big-endian)) (def-enctype buint24 () (number unsigned 3 big-endian)) (def-enctype buint32 () (number unsigned 4 big-endian)) (def-enctype bint8 () (number two-complement 1 big-endian)) (def-enctype bint16 () (number two-complement 2 big-endian)) (def-enctype bint24 () (number two-complement 3 big-endian)) (def-enctype bint32 () (number two-complement 4 big-endian)) (def-enctype bbcd (siz) (number binary-coded-decimal siz big-endian)) (def-enctype luint8 () (number unsigned 1 little-endian)) (def-enctype luint16 () (number unsigned 2 little-endian)) (def-enctype luint24 () (number unsigned 3 little-endian)) (def-enctype luint32 () (number unsigned 4 little-endian)) (def-enctype lint8 () (number two-complement 1 little-endian)) (def-enctype lint16 () (number two-complement 2 little-endian)) (def-enctype lint24 () (number two-complement 3 little-endian)) (def-enctype lint32 () (number two-complement 4 little-endian)) (def-enctype lbcd (siz) (number binary-coded-decimal siz little-endian)) (def-enctype m2-string (len) (string len null :terminated :if-smaller)) (def-enctype cobol-string (len) (string len space :padded :strip)) (def-enctype pascal-string (len) (string len :green-length (number unsigned 1))) (def-enctype c-string (len) (string len null :terminated)) ) ;;progn (def-encrecord test-rec (buint8 buint8) (buint24 buint24) (luint8 luint8) (luint24 luint24) (buint16 buint16) (luint16 luint16) (buint32 buint32) (luint32 luint32) (bint8 bint8) (bint24 bint24) (lint8 lint8) (lint24 lint24) (bint16 bint16) (lint16 lint16) (bint32 bint32) (lint32 lint32) (lbcd1 (lbcd 1)) (lbcd7 (lbcd 7)) (bbcd1 (bbcd 1)) (bbcd7 (bbcd 7)) (cstr1 (c-string 16) :offset 64) (cstr2 (c-string 16)) (cstr3 (c-string 16)) (m2str1 (m2-string 16)) (m2str2 (m2-string 16)) (m2str3 (m2-string 16)) (cbstr1 (cobol-string 16)) (cbstr2 (cobol-string 16)) (cbstr3 (cobol-string 16)) (pstr1 (pascal-string 16)) (pstr2 (pascal-string 16)) (pstr3 (pascal-string 16)) (bstr1 (string 16 :green-length (number unsigned 2))) (bstr2 (string 16 :green-length (number unsigned 2))) (bstr3 (string 16 :green-length (number unsigned 2)))) (defun test-write-read (record write read) (with-open-file (file "/tmp/test.data" :direction :output :if-does-not-exist :create :if-exists :supersede :element-type '(unsigned-byte 8)) (funcall write record file)) (assert-true (equalp record (with-open-file (file "/tmp/test.data" :direction :input :if-does-not-exist :error :element-type '(unsigned-byte 8)) (funcall read file))))) (define-test test/write-read-1 () (test-write-read (make-test-rec) (function write-test-rec) (function read-test-rec))) (define-test test/192-write-read () (dotimes (i 192) (test-write-read (make-test-rec :buint8 i :buint24 (* (+ 32768 512 3) i) :luint8 i :luint24 (* (+ 32768 512 3) i) :buint16 (* (+ 128 2) i) :luint16 (* (+ 128 2) i) :buint32 (* (+ 4194304 32768 512 3) i) :luint32 (* (+ 4194304 32768 512 3) i) :bint8 (- i 128) :bint24 (- (* (+ 32768 512 3) i) (expt 2 23)) :lint8 (- i 128) :lint24 (- (* (+ 32768 512 3) i) (expt 2 23)) :bint16 (- (* (+ 128 2) i) (expt 2 15)) :lint16 (- (* (+ 128 2) i) (expt 2 15)) :bint32 (- (* (+ 4194304 32768 512 3) i) (expt 2 31)) :lint32 (- (* (+ 4194304 32768 512 3) i) (expt 2 31)) :lbcd1 (- (mod i 19) 9) :lbcd7 (- (mod (* 12345678 i) 1999999) 999999) :bbcd1 (- (mod i 19) 9) :bbcd7 (- (mod (* 12345678 i) 1999999) 999999) :cstr1 (format nil "~10,'0D" i) :cstr2 (format nil "~15,'0D" i) :cstr3 "" :m2str1 (format nil "~10,'0D" i) :m2str2 (format nil "~15,'0D" i) :m2str3 (format nil "~16,'0D" i) :cbstr1 (format nil "~10,'0D" i) :cbstr2 (format nil "~15,'0D" i) :cbstr3 (format nil "~16,'0D" i) :pstr1 (format nil "~10,'0D" i) :pstr2 (format nil "~15,'0D" i) :pstr3 "" :bstr1 (format nil "~10,'0D" i) :bstr2 (format nil "~14,'0D" i) :bstr3 "") (function write-test-rec) (function read-test-rec)))) (define-test test/write-read-2 () (test-write-read (make-test-rec :buint8 #x12 :buint24 #x123456 :luint8 #x12 :luint24 #x123456 :buint16 #x1234 :luint16 #x1234 :buint32 #x12345678 :luint32 #x12345678 :bint8 (- #xfe #x100) :bint24 (- #xfedcba #x1000000) :lint8 (- #xfe #x100) :lint24 (- #xfedcba #x1000000) :bint16 (- #xfedc #x10000) :lint16 (- #xfedc #x10000) :bint32 (- #xfedcba98 #x100000000) :lint32 (- #xfedcba98 #x100000000) :lbcd1 -7 :lbcd7 1234567 :bbcd1 -7 :bbcd7 1234567 :cstr1 "cstr1" :cstr2 "Pascal" :cstr3 "" :m2str1 "m2str1" :m2str2 "Jacques" :m2str3 "" :cbstr1 "cbstr1" :cbstr2 "Bourguignon" :cbstr3 "" :pstr1 "pstr1" :pstr2 "La Manga" :pstr3 "" :bstr1 "bstr1" :bstr2 "del Mar Menor" :bstr3 "") (function write-test-rec) (function read-test-rec))) (define-test test/data () (assert-true (equalp (print (with-open-file (file "/tmp/test.data" :direction :input :if-does-not-exist :error :element-type '(unsigned-byte 8)) (let ((buffer (make-array '(304) :element-type '(unsigned-byte 8)))) (assert-true (= 304 (read-sequence buffer file))) buffer))) #(18 18 52 86 18 86 52 18 18 52 52 18 18 52 86 120 120 86 52 18 254 254 220 186 254 186 220 254 254 220 220 254 254 220 186 152 152 186 220 254 125 124 86 52 18 0 0 0 125 0 0 0 18 52 86 124 0 0 0 0 0 0 0 0 99 115 116 114 49 0 0 0 0 0 0 0 0 0 0 0 80 97 115 99 97 108 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 109 50 115 116 114 49 0 0 0 0 0 0 0 0 0 0 74 97 99 113 117 101 115 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 99 98 115 116 114 49 32 32 32 32 32 32 32 32 32 32 66 111 117 114 103 117 105 103 110 111 110 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 5 112 115 116 114 49 0 0 0 0 0 0 0 0 0 0 8 76 97 32 77 97 110 103 97 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 98 115 116 114 49 0 0 0 0 0 0 0 0 0 0 13 100 101 108 32 77 97 114 32 77 101 110 111 114 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)))) (define-test test/all () (test/write-read-1) (test/write-read-2) (test/192-write-read) (test/data)) ;;;; THE END ;;;;
9,307
Common Lisp
.lisp
229
35.021834
85
0.573761
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
3e90593a62e4fcbca38212e2d0c7dd443ba90706a7bedcbdf4c906064b68d0ea
5,053
[ -1 ]
5,054
bencode-test.lisp
informatimago_lisp/common-lisp/data-encoding/bencode-test.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: bencode-test.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Test bencode.lisp. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2015-02-25 <PJB> Extracted from bencode.lisp. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.DATA-ENCODING.BENCODE.TEST" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SIMPLE-TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.LIST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY" "COM.INFORMATIMAGO.COMMON-LISP.DATA-ENCODING.BENCODE") (:export "TEST/ALL")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.DATA-ENCODING.BENCODE.TEST") (define-test test/string (&key (verbose nil)) (let* ((str (concatenate 'string "l" "i43e" "4:spam" "l" "4:spam" "4:eggs" "e" "d" "3:cow" "3:moo" "4:spam" "4:eggs" "e" "d" "4:spam" "l" "1:a" "1:b" "e" "e" "e")) (object (bdecode-from-string str)) (obj (maptree (lambda (node) (if (hash-table-p node) (cons 'dict (hash-table-entries node)) node)) object))) (when verbose (print str) (print obj)) (assert-true (equal obj '(43 "spam" ("spam" "eggs") (dict (:cow . "moo") (:spam . "eggs")) (dict (:spam "a" "b"))))) (assert-true (string= (bencode-to-string object) str)))) ;; (defun dictp (dict) ;; (and (listp dict) (eql 'dict (first dict)))) ;; ;; (defun dict-get (dict key &optional (default nil)) ;; (assert (dictp dict)) ;; (let ((entry (if (keywordp key) ;; (assoc key (rest dict)) ;; (assoc key (rest dict) :test (function string=))))) ;; (if entry ;; (values (cdr entry) t) ;; (values default nil)))) ;; ;; (defun dict-get* (dict &rest keys) ;; (if (null keys) ;; dict ;; (apply (function dict-get*) (dict-get dict (first keys)) (rest keys)))) ;; ;; (defun (setf dict-get) (new-value dict key &optional (default nil)) ;; (declare (ignore default)) ;; (assert (dictp dict)) ;; (let ((entry (if (keywordp key) ;; (assoc key (rest dict)) ;; (assoc key (rest dict) :test (function string=))))) ;; (if entry ;; (setf (cdr entry) new-value) ;; (push (rest dict) (cons key new-value))) ;; new-value)) ;; ;; (defun dict-count (dict) ;; (assert (dictp dict)) ;; (length (rest dict))) ;; ;; (defun dict-keys (dict) ;; (assert (dictp dict)) ;; (mapcpar (function car) (rest dict))) #|| (defparameter *sizes* (mapcar (lambda (path) (finish-output) (handler-case (print (cons path (hash-table-path (with-open-file (torrent path :element-type '(unsigned-byte 8)) (let ((*key-map-exceptions* *torrent-key-map-exceptions*)) (bdecode-from-binary-stream torrent))) :info :length))) (error (err) (format t "~%~A: ~A~%" path err)))) (directory "/home/p2p/incoming/files/wikileaks/torrent/**/*.torrent"))) (reduce (function +) *sizes* :key (lambda (x) (or (cdr x) 0))) (let ((inpath "/home/p2p/incoming/files/wikileaks/torrent/iran-telco-attachments-2009/5th-neshast.pdf.torrent") (outpath "/tmp/test.bencode")) (with-open-file (out outpath :element-type '(unsigned-byte 8) :direction :output :if-does-not-exist :create :if-exists :supersede) (let ((*key-map-exceptions* *torrent-key-map-exceptions* )) (bencode-to-binary-stream (with-open-file (torrent inpath :element-type '(unsigned-byte 8)) (let ((*key-map-exceptions* *torrent-key-map-exceptions* )) (bdecode-from-binary-stream torrent))) out)))) #S(HASH-TABLE :TEST EXT:FASTHASH-EQL (:URL-LIST . "http://88.80.16.63/file/iran-telco-attachments-2009%2F5th-neshast.pdf") (:INFO . #S(HASH-TABLE :TEST EXT:FASTHASH-EQL (:PIECES . #(35 67 174 26 34 98 126 29 18 21 102 158 184 27 231 17 96 241 244 126 83 244 165 89 75 132 178 62 76 94 64 120 0 179 45 188 230 49 41 15 205 251 190 150 68 235 201 12 14 65 60 160 192 250 217 53 217 188 207 188)) (:PIECE-LENGTH . 262144) (:NAME . "iran-telco-attachments-2009/5th-neshast.pdf") (:LENGTH . 601447))) (:CREATION-DATE . 1291401958) (:CREATED-BY . "mktorrent 1.0") (:COMMENT . "WikiLeaks release - iran-telco-attachments-2009/5th-neshast.pdf") (:ANNOUNCE-LIST . (("http://tracker.openbittorrent.com/announce") ("udp://tracker.openbittorrent.com:80/announce"))) (:ANNOUNCE . "http://tracker.openbittorrent.com/announce")) ||# (define-test test/all () (test/string)) ;;;; THE END ;;;;
6,734
Common Lisp
.lisp
150
35.36
121
0.520779
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
0853c9e884d12acdb5001385fe8be039fbc1bf6b7dcb9fc5e4f9f04a86ae809d
5,054
[ -1 ]
5,055
ecp.lisp
informatimago_lisp/common-lisp/data-encoding/ecp.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: ecp.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;nDESCRIPTION ;;;; ;;;; Minitel-1b Error Correction Procedure. ;;;; Reference: page 55 and on in http://543210.free.fr/TV/stum1b.pdf ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2012-02-04 <PJB> Converted from C. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2012 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.DATA-ENCODING.ECP" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.ASCII" "COM.INFORMATIMAGO.COMMON-LISP.ARITHMETIC.P127N2") (:export "+ECP-BLOCK-SIZE+" "ECP-DATA" "ECP-ACTIVE" "ECP-STATE" "START-ECP" "STOP-ECP" "STATISTICS" "STATISTICS-BYTES-RECEIVED" "STATISTICS-PARITY-ERRORS" "STATISTICS-UNCORRECTABLE-COUNT" "STATISTICS-UNCORRECTED-COUNT" "STATISTICS-CORRECTED-COUNT" "STATISTICS-INVALID-COUNT" "STATISTICS-CORRECT-COUNT" "STATISTICS-VALID-SYN-COUNT" "STATISTICS-INVALID-SYN-COUNT" "PROCESS-OUTPUT-BUFFER") (:documentation " Minitel-1b Error Correction Procedure. Reference: page 55 and on in <http://543210.free.fr/TV/stum1b.pdf> License: AGPL3 Copyright Pascal J. Bourguignon 2012 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.DATA-ENCODING.ECP") (defstruct statistics "Statistics for the ECP algorithm." (bytes-received 0) (parity-errors 0) (uncorrectable-count 0) (uncorrected-count 0) (corrected-count 0) (invalid-count 0) (correct-count 0) (valid-syn-count 0) (invalid-syn-count 0)) (setf (documentation 'statistics-bytes-received 'function) "ECP statistics: number of bytes processed." (documentation 'statistics-parity-errors 'function) "ECP statistics: number of parity errors." (documentation 'statistics-uncorrectable-count 'function) "ECP statistics: number of uncorrectable errors." (documentation 'statistics-uncorrected-count 'function) "ECP statistics: number of uncorrected errors." (documentation 'statistics-corrected-count 'function) "ECP statistics: number of corrected errors." (documentation 'statistics-invalid-count 'function) "ECP statistics: number of invalid blocks." (documentation 'statistics-correct-count 'function) "ECP statistics: number of correct blocks." (documentation 'statistics-valid-syn-count 'function) "ECP statistics: number of valid syn." (documentation 'statistics-invalid-syn-count 'function) "ECP statistics: number of invalid syn.") (deftype ecp-state () '(member :ecp-start :ecp-block :ecp-syn)) (defconstant +ecp-block-size+ 17 "Size of an ECP block.") (defstruct (ecp-data (:conc-name ecp-)) "State for the ECP algorithm." (active nil :type boolean) (state :ecp-start :type ecp-state) (count 0) ; bytes in block (parity-index 0) ; of first error (parity-errors 0) (block-number 0) ; current block (block (make-array +ecp-block-size+ :element-type '(unsigned-byte 8) :initial-element 0))) (setf (documentation 'ecp-active 'function) "Whether the ECP is active." (documentation 'ecp-state 'function) "State of the ECP, one of :ecp-start, :ecp-block or :ecp-syn.") (defun start-ecp (ecp) "Initialize the ECP data." (check-type ecp ecp-data) (setf (ecp-active ecp) t (ecp-state ecp) :ecp-start (ecp-count ecp) 0 (ecp-parity-index ecp) 0 (ecp-parity-errors ecp) 0 (ecp-block-number ecp) 0) ecp) (defun stop-ecp (ecp) "Resets the ECP data." (setf (ecp-active ecp) nil) (assert (zerop (ecp-count ecp))) ecp) (defun clear-parity (buffer &key (start 0) (end nil)) " DO: Resets the parity bit in each octets of the BUFFER between START and END, RETURN: BUFFER " (let ((end (or end (length buffer)))) (loop :for i :from start :below end :do (setf (aref buffer i) (logand (aref buffer i) #x7f))) buffer)) (defun set-parity (buffer &key (start 0) (end nil)) " DO: Modifies the octets in the BUFFER between START and END, setting the parity bit to even parity. RETURN: BUFFER " (let ((end (or end (length buffer)))) (loop :for i :from start :below end :do (setf (aref buffer i) (even-parity (aref buffer i)))) buffer)) (defun remove-escapes (buffer &key (start 0) (end nil)) " PRE: bytes in buffer are with no parity. POST: DLE escapes and the trailling NULs are removed from the buffer. DO: Modifies the buffer. RETURN: the new byte count. " (let* ((end (or end (length buffer))) (i start) (j start) (ncount 0) (count (- end start))) (loop :while (plusp count) :do (cond ((= (aref buffer j) dle) (incf j) (decf count) (setf (aref buffer i) (aref buffer j)) (incf i) (incf ncount)) ((plusp (aref buffer j)) ; BUG: not only the trailing NULs are removed, but also NULs in the middle, if they're not escaped by a DLE. (setf (aref buffer i) (aref buffer j)) (incf i) (incf ncount))) (incf j) (decf count)) ncount)) (defconstant +g+ (+ (ash 1 7) (ash 1 3) (ash 1 0))) (defvar *ecp-rank* (make-array 128 :element-type '(unsigned-byte 8) :initial-contents '( 0 0 1 31 2 62 32 103 3 7 63 15 33 84 104 93 4 124 8 121 64 79 16 115 34 11 85 38 105 46 94 51 5 82 125 60 9 44 122 77 65 67 80 42 17 69 116 23 35 118 12 28 86 25 39 57 106 19 47 89 95 71 52 110 6 14 83 92 126 30 61 102 10 37 45 50 123 120 78 114 66 41 68 22 81 59 43 76 18 88 70 109 117 27 24 56 36 49 119 113 13 91 29 101 87 108 26 55 40 21 58 75 107 54 20 74 48 112 90 100 96 97 72 98 53 73 111 99 ))) ;; A ECP block contains 17 octets: 15 bytes of payload, one octet of ;; check and one nul octet. Each octet contains 7 bit of data and one ;; bit of even parity in the most significant position. ;; ;; +------------------------+-----------------+--------------+ ;; | payload (15 octets) | check (1 octet) | 00 (1 octet) | ;; +------------------------+-----------------+--------------+ ;; ;; The value of check is such that the remainder of the polynom ;; divided by x^7+x^3+x^0 is 0. (defun process-input-buffer (ecp buffer &key (start 0) (end nil) ((:statistics stats) nil) (send-nak nil) (cancel-nak nil)) " DO: Process the bytes in the BUFFER from START to END. ECP: An ECP-DATA structure maintaining the persistent data between calls to PROCESS-INPUT-BUFFER. BUFFER: Input octet vector. START: Index of the first octet in BUFFER to process. END: Index of the first octet in BUFFER after the last to process. STATS: A STATISTICS structure. SEND-NAK: A thunk to call when an uncorrectable error is detected. CANCEL-NAK: A thunk to call when a SYN SYN 4x sequence is received (so it can cancel the NAK timer). RETURN: NIL; next; NIL; STATS -- in case of incomplete or erroneous block. data-vector; next; block-number; STATS -- when a valid block is received. next is the index of the next start in buffer. " (check-type ecp ecp-data) (check-type stats (or null statistics)) (check-type start (integer 0)) (check-type end (or null (integer 0))) (check-type send-nak (or null symbol function)) (check-type cancel-nak (or null symbol function)) (let* ((stats (or stats (make-statistics))) (end (or end (length buffer))) (b start) (c (- end start)) (count c)) (flet ((process-block () ;; (print `(process-block :ecp ,ecp :start ,start :end ,end :b ,b :c ,c :count ,count :stats ,stats)) (finish-output) (loop :named accumulates-until-end-of-block :while (and (plusp c) (< (ecp-count ecp) +ecp-block-size+)) :do ;; check parity errors (when (/= (aref buffer b) (even-parity (aref buffer b))) (when (< (ecp-parity-errors ecp) 2) (when (zerop (ecp-parity-errors ecp)) (setf (ecp-parity-index ecp) (ecp-count ecp))) (incf (ecp-parity-errors ecp))) (incf (statistics-parity-errors stats))) (setf (aref (ecp-block ecp) (ecp-count ecp)) (aref buffer b)) (incf (ecp-count ecp)) (incf b) (decf c)) (incf (statistics-bytes-received stats) (- count c)) (setf count c) (cond ((< 1 (ecp-parity-errors ecp)) ;; (print '(< 1 (ecp-parity-errors ecp))) (finish-output) (incf (statistics-uncorrectable-count stats)) (setf (ecp-state ecp) :ecp-start) (when send-nak (funcall send-nak))) ((= (ecp-count ecp) +ecp-block-size+) ;; (print '(= (ecp-count ecp) +ecp-block-size+)) (finish-output) ;; check the block (if (/= 0 (aref (ecp-block ecp) 16)) ; 17th byte (progn ; invalid block ;; (print '(/= 0 (aref (ecp-block ecp) 16))) (finish-output) (incf (statistics-invalid-count stats)) (setf (ecp-state ecp) :ecp-start) (when send-nak (funcall send-nak))) (let ((poly (poly-from-bytes (ecp-block ecp))) remainder) ;; (print '(= 0 (aref (ecp-block ecp) 16))) (finish-output) (remove-bit7 poly) (setf remainder (remainder32 poly +g+)) (assert (< remainder 128)) ;; since deg(+g+)=7 (cond ((and (zerop remainder) (zerop (ecp-parity-errors ecp))) ;; correct block ;; (print '(and (zerop remainder) (zerop (ecp-parity-errors ecp)))) (finish-output) (incf (statistics-correct-count stats)) (clear-parity (ecp-block ecp) :end (- +ecp-block-size+ 2)) (let ((cnt (remove-escapes (ecp-block ecp) :end (- +ecp-block-size+ 2))) (bn (ecp-block-number ecp))) (setf (ecp-block-number ecp) (mod (1+ (ecp-block-number ecp)) 16) (ecp-state ecp) :ecp-start) (return-from process-input-buffer (values (subseq (ecp-block ecp) 0 cnt) b bn stats)))) ((and (plusp remainder) (= 1 (ecp-parity-errors ecp))) ;; (print '(and (plusp remainder) (= 1 (ecp-parity-errors ecp)))) (finish-output) ;; correctable block (let* ((rank (aref *ecp-rank* remainder)) (index (- (- +ecp-block-size+ 2) (truncate (1+ rank) 8)))) ;; NOTE: ;; rank |----> (index,bit) ;; = (16,rank) if rank < 7 ;; = (16-((rank+1)/8),(rank+1)%8) if rank >= 7 ;; but we don't care and don't correct the CRC byte when rank<7 because ;; the CRC byte is not used thereafter. (if (= index (ecp-parity-index ecp)) (progn ; corrected block (incf (statistics-corrected-count stats)) (setf (aref (ecp-block ecp) index) (logxor (aref (ecp-block ecp) index) (ash 1 (mod (1+ rank) 8)))) (clear-parity (ecp-block ecp) :end (- +ecp-block-size+ 2)) (let ((cnt (remove-escapes (ecp-block ecp) :end (- +ecp-block-size+ 2))) (bn (ecp-block-number ecp))) (setf (ecp-block-number ecp) (mod (1+ (ecp-block-number ecp)) 16) (ecp-state ecp) :ecp-start) (return-from process-input-buffer (values (subseq (ecp-block ecp) 0 cnt) b bn stats)))) (progn ; uncorrected block (incf (statistics-uncorrected-count stats)) (setf (ecp-state ecp) :ecp-start) (when send-nak (funcall send-nak)))))) (t ;; (print 'else-2) (finish-output) ;; uncorrectable block (incf (statistics-uncorrectable-count stats)) (setf (ecp-state ecp) :ecp-start) (when send-nak (funcall send-nak))))))) (t ;; else wait for a full block ;; (print 'else) (finish-output) )))) (loop :while (plusp c) :do (ecase (ecp-state ecp) (:ecp-start (loop :named skip-nuls :while (and (plusp c) (zerop (aref buffer b))) :do (decf c) (incf b)) (setf (ecp-state ecp) :ecp-block (ecp-parity-errors ecp) 0 (ecp-count ecp) 0) (incf (statistics-bytes-received stats) (- count c)) (setf count c) (process-block)) (:ecp-block (process-block)) (:ecp-syn ;; wait for a SYN SYN 4x sequence (loop :while (and (plusp c) (eql :ecl-syn (ecp-state ecp))) :do (let ((byte (logand (aref buffer b) #x7f))) (if (= (ecp-count ecp) 2) ; get the 4x (progn (when cancel-nak (funcall cancel-nak)) (if (and (= (aref buffer b) (even-parity byte)) (= byte (+ #x40 (ecp-block-number ecp)))) (progn (incf (statistics-valid-syn-count stats)) (setf (ecp-state ecp) :ecp-start (ecp-parity-errors ecp) 0 (ecp-count ecp) 0)) (progn (incf (statistics-invalid-syn-count stats)) (when send-nak (funcall send-nak))))) (progn (if (= (aref buffer b) (even-parity byte)) (if (= byte #x16) (incf (ecp-count ecp)) ; one more SYN (progn ; Not SYN (incf (statistics-invalid-syn-count stats) (ecp-count ecp)) (setf (ecp-count ecp) 0))) ; parity error (progn (incf (statistics-parity-errors stats)) (when (= byte #x16) (incf (statistics-invalid-syn-count stats)) (when send-nak (funcall send-nak))) (setf (ecp-count ecp) 0))))) (incf b) (decf c))) (incf (statistics-bytes-received stats) (- count c)) (setf count c))))) (values nil b nil stats))) (defun process-output-buffer (ecp buffer &key (start 0) (end nil) (last nil)) " ECP: An ECP-DATA structure maintaining the persistent data between calls to PROCESS-OUTPUT-BUFFER. BUFFER: Source data octet vector (only 7-bit values). START: Index of the first octet in BUFFER to process. END: Index of the first octet in BUFFER after the last to process. LAST: When true, if there's not enough bytes in the BUFFER to fill a packet, the packet is padded with NULs. DO: Encode an ECP packet from bytes obtained from BUFFER, between START and END. RETURN: index of first byte not processed from BUFFER; (ecp-block ecp) -- when a packet is complete, index of first byte not processed from BUFFER; nil -- when the package is not complete. " (let* ((end (or end (length buffer))) (i start)) (flet ((generate (byte) (setf (aref (ecp-block ecp) (ecp-count ecp)) (even-parity byte)) (incf (ecp-count ecp)) (when (<= (- +ecp-block-size+ 2) (ecp-count ecp)) (setf (aref (ecp-block ecp) (- +ecp-block-size+ 1)) 0 (aref (ecp-block ecp) (- +ecp-block-size+ 2)) 0) ;; (set-parity (ecp-block ecp) :end (- +ecp-block-size+ 2)) (let ((poly (poly-from-bytes (ecp-block ecp))) remainder) (remove-bit7 poly) (setf remainder (remainder32 poly +g+) (aref (ecp-block ecp) (- +ecp-block-size+ 2)) (even-parity remainder) (ecp-count ecp) 0)) (return-from process-output-buffer (values i (ecp-block ecp)))))) (loop :while (and (< (ecp-count ecp) (- +ecp-block-size+ 2)) (< i end)) :do (let ((byte (logand (aref buffer i) #x7f))) (incf i) (if (or (= byte dle) (= byte nul) (= byte syn) (= byte nak)) (if (< (ecp-count ecp) (- +ecp-block-size+ 4)) (progn (generate dle) (generate nul)) (generate nul)) (generate byte)))) (when last (loop :while (< (ecp-count ecp) (- +ecp-block-size+ 2)) :do (generate 0))) (values i nil)))) (defun test () (let* ((text "Hao Wang, logicien americain. L'algorithme en question a ete publie en 1960 dans l'IBM Journal, article intitule \"Toward Mechanical Mathematics\", avec des variantes et une extension au calcul des predicats. Il s'agit ici du \"premier programme\" de Wang, systeme \"P\". ") (data (map '(vector (unsigned-byte 8)) (function char-code) text)) (ecp (make-ecp-data)) (stats (make-statistics)) (packets '())) (start-ecp ecp) (loop :with start = 0 :while (< start (length data)) :do (multiple-value-bind (next packet) (process-output-buffer ecp data :start start :last t) (when packet ;; (print packet) (finish-output) (push (copy-seq packet) packets)) (when (= start next) (error "no change in start ~D" start)) (setf start next))) (setf packets (reverse packets)) (let ((stream (make-array (* 20 (length packets)) :element-type '(unsigned-byte 8) :initial-element 0))) (loop :with i = 0 :for packet :in packets :do (progn (replace stream packet :start1 i) ;; (print i) (finish-output) (incf i (+ 17 (random 3))))) ;; (print stream) (print (map 'string (lambda (x) (code-char (logand x #x7f))) stream)) (finish-output) (start-ecp ecp) (assert (string= (let ((*print-pretty* nil) (*print-escape* nil)) (with-output-to-string (out) (loop :with start = 0 :while (< start (length stream)) :do (multiple-value-bind (data-chunk next block-number) (process-input-buffer ecp stream :start start :statistics stats) (declare (ignorable block-number)) (setf start next) ;; (print (list start block-number data-chunk (map 'string (function code-char) data-chunk))) (finish-output) (princ (map 'string (function code-char) data-chunk) out)) :finally (print stats) (terpri) (finish-output) ))) text)) :success))) ;;;; THE END ;;;;
22,701
Common Lisp
.lisp
458
36.696507
150
0.525505
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
9ad494e777a731fa3a88e40d6a0968144baf582a56c7ecfae599b7a62098cfe6
5,055
[ -1 ]
5,056
package-def.lisp
informatimago_lisp/common-lisp/lisp-reader/package-def.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: package-def.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; This file defines the standard packages. ;;;; ;;;; ;;;; Implements the Common Lisp package system. ;;;; ;;;; <Xach> The basic idea of that file is that the semantics of the CL ;;;; package system can be implemented by an object with three special ;;;; kinds of tables (present-table, shadowing-table, external-table) ;;;; and two lists (used-packs, used-by-packs). The rest is ;;;; implementation. ;;;; ;;;;AUTHORS ;;;; <XACH> Zachary Beane <[email protected]>, ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2012-04-03 <PJB> Completed corrections to pass package ansi-tests. ;;;; 2012-03-30 <PJB> Added checks, made the API conforming to CL. ;;;; 2012-03-30 <PJB> Added this header; Removed "Z" prefix to CL ;;;; symbol names; shadowed and exported them. ;;;;BUGS ;;;; ;;;; make-load-form for packages should probably return two forms, since ;;;; packages can have circular dependencies. ;;;; ;;;; Are missing some standard restarts to correct ;;;; conflicts. (choosing one or the other symbol, doing the same ;;;; for all conflicts, etc). ;;;; ;;;;LEGAL ;;;; Copyright (c) 2012 Zachary Beane <[email protected]>, All Rights Reserved ;;;; Copyright (c) 2012 Pascal J. Bourguignon <[email protected]>, All Rights Reserved ;;;; ;;;; Redistribution and use in source and binary forms, with or without ;;;; modification, are permitted provided that the following conditions ;;;; are met: ;;;; ;;;; * Redistributions of source code must retain the above copyright ;;;; notice, this list of conditions and the following disclaimer. ;;;; ;;;; * Redistributions in binary form must reproduce the above ;;;; copyright notice, this list of conditions and the following ;;;; disclaimer in the documentation and/or other materials ;;;; provided with the distribution. ;;;; ;;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED ;;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ;;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ;;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ;;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ;;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ;;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (cl:in-package "COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.PACKAGE") ;; with COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.PACKAGE (defpackage "KEYWORD" (:use) (:documentation "The KEYWORD package.")) ;; with COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.PACKAGE (defpackage "COMMON-LISP" (:use) (:nicknames "CL") (:export "&ALLOW-OTHER-KEYS" "&AUX" "&BODY" "&ENVIRONMENT" "&KEY" "&OPTIONAL" "&REST" "&WHOLE" "*" "**" "***" "*BREAK-ON-SIGNALS*" "*COMPILE-FILE-PATHNAME*" "*COMPILE-FILE-TRUENAME*" "*COMPILE-PRINT*" "*COMPILE-VERBOSE*" "*DEBUG-IO*" "*DEBUGGER-HOOK*" "*DEFAULT-PATHNAME-DEFAULTS*" "*ERROR-OUTPUT*" "*FEATURES*" "*GENSYM-COUNTER*" "*LOAD-PATHNAME*" "*LOAD-PRINT*" "*LOAD-TRUENAME*" "*LOAD-VERBOSE*" "*MACROEXPAND-HOOK*" "*MODULES*" "*PACKAGE*" "*PRINT-ARRAY*" "*PRINT-BASE*" "*PRINT-CASE*" "*PRINT-CIRCLE*" "*PRINT-ESCAPE*" "*PRINT-GENSYM*" "*PRINT-LENGTH*" "*PRINT-LEVEL*" "*PRINT-LINES*" "*PRINT-MISER-WIDTH*" "*PRINT-PPRINT-DISPATCH*" "*PRINT-PRETTY*" "*PRINT-RADIX*" "*PRINT-READABLY*" "*PRINT-RIGHT-MARGIN*" "*QUERY-IO*" "*RANDOM-STATE*" "*READ-BASE*" "*READ-DEFAULT-FLOAT-FORMAT*" "*READ-EVAL*" "*READ-SUPPRESS*" "*READTABLE*" "*STANDARD-INPUT*" "*STANDARD-OUTPUT*" "*TERMINAL-IO*" "*TRACE-OUTPUT*" "+" "++" "+++" "-" "/" "//" "///" "/=" "1+" "1-" "<" "<=" "=" ">" ">=" "ABORT" "ABS" "ACONS" "ACOS" "ACOSH" "ADD-METHOD" "ADJOIN" "ADJUST-ARRAY" "ADJUSTABLE-ARRAY-P" "ALLOCATE-INSTANCE" "ALPHA-CHAR-P" "ALPHANUMERICP" "AND" "APPEND" "APPLY" "APROPOS" "APROPOS-LIST" "AREF" "ARITHMETIC-ERROR" "ARITHMETIC-ERROR-OPERANDS" "ARITHMETIC-ERROR-OPERATION" "ARRAY" "ARRAY-DIMENSION" "ARRAY-DIMENSION-LIMIT" "ARRAY-DIMENSIONS" "ARRAY-DISPLACEMENT" "ARRAY-ELEMENT-TYPE" "ARRAY-HAS-FILL-POINTER-P" "ARRAY-IN-BOUNDS-P" "ARRAY-RANK" "ARRAY-RANK-LIMIT" "ARRAY-ROW-MAJOR-INDEX" "ARRAY-TOTAL-SIZE" "ARRAY-TOTAL-SIZE-LIMIT" "ARRAYP" "ASH" "ASIN" "ASINH" "ASSERT" "ASSOC" "ASSOC-IF" "ASSOC-IF-NOT" "ATAN" "ATANH" "ATOM" "BASE-CHAR" "BASE-STRING" "BIGNUM" "BIT" "BIT-AND" "BIT-ANDC1" "BIT-ANDC2" "BIT-EQV" "BIT-IOR" "BIT-NAND" "BIT-NOR" "BIT-NOT" "BIT-ORC1" "BIT-ORC2" "BIT-VECTOR" "BIT-VECTOR-P" "BIT-XOR" "BLOCK" "BOOLE" "BOOLE-1" "BOOLE-2" "BOOLE-AND" "BOOLE-ANDC1" "BOOLE-ANDC2" "BOOLE-C1" "BOOLE-C2" "BOOLE-CLR" "BOOLE-EQV" "BOOLE-IOR" "BOOLE-NAND" "BOOLE-NOR" "BOOLE-ORC1" "BOOLE-ORC2" "BOOLE-SET" "BOOLE-XOR" "BOOLEAN" "BOTH-CASE-P" "BOUNDP" "BREAK" "BROADCAST-STREAM" "BROADCAST-STREAM-STREAMS" "BUILT-IN-CLASS" "BUTLAST" "BYTE" "BYTE-POSITION" "BYTE-SIZE" "CAAAAR" "CAAADR" "CAAAR" "CAADAR" "CAADDR" "CAADR" "CAAR" "CADAAR" "CADADR" "CADAR" "CADDAR" "CADDDR" "CADDR" "CADR" "CALL-ARGUMENTS-LIMIT" "CALL-METHOD" "CALL-NEXT-METHOD" "CAR" "CASE" "CATCH" "CCASE" "CDAAAR" "CDAADR" "CDAAR" "CDADAR" "CDADDR" "CDADR" "CDAR" "CDDAAR" "CDDADR" "CDDAR" "CDDDAR" "CDDDDR" "CDDDR" "CDDR" "CDR" "CEILING" "CELL-ERROR" "CELL-ERROR-NAME" "CERROR" "CHANGE-CLASS" "CHAR" "CHAR-CODE" "CHAR-CODE-LIMIT" "CHAR-DOWNCASE" "CHAR-EQUAL" "CHAR-GREATERP" "CHAR-INT" "CHAR-LESSP" "CHAR-NAME" "CHAR-NOT-EQUAL" "CHAR-NOT-GREATERP" "CHAR-NOT-LESSP" "CHAR-UPCASE" "CHAR/=" "CHAR<" "CHAR<=" "CHAR=" "CHAR>" "CHAR>=" "CHARACTER" "CHARACTERP" "CHECK-TYPE" "CIS" "CLASS" "CLASS-NAME" "CLASS-OF" "CLEAR-INPUT" "CLEAR-OUTPUT" "CLOSE" "CLRHASH" "CODE-CHAR" "COERCE" "COMPILATION-SPEED" "COMPILE" "COMPILE-FILE" "COMPILE-FILE-PATHNAME" "COMPILED-FUNCTION" "COMPILED-FUNCTION-P" "COMPILER-MACRO" "COMPILER-MACRO-FUNCTION" "COMPLEMENT" "COMPLEX" "COMPLEXP" "COMPUTE-APPLICABLE-METHODS" "COMPUTE-RESTARTS" "CONCATENATE" "CONCATENATED-STREAM" "CONCATENATED-STREAM-STREAMS" "COND" "CONDITION" "CONJUGATE" "CONS" "CONSP" "CONSTANTLY" "CONSTANTP" "CONTINUE" "CONTROL-ERROR" "COPY-ALIST" "COPY-LIST" "COPY-PPRINT-DISPATCH" "COPY-READTABLE" "COPY-SEQ" "COPY-STRUCTURE" "COPY-SYMBOL" "COPY-TREE" "COS" "COSH" "COUNT" "COUNT-IF" "COUNT-IF-NOT" "CTYPECASE" "DEBUG" "DECF" "DECLAIM" "DECLARATION" "DECLARE" "DECODE-FLOAT" "DECODE-UNIVERSAL-TIME" "DEFCLASS" "DEFCONSTANT" "DEFGENERIC" "DEFINE-COMPILER-MACRO" "DEFINE-CONDITION" "DEFINE-METHOD-COMBINATION" "DEFINE-MODIFY-MACRO" "DEFINE-SETF-EXPANDER" "DEFINE-SYMBOL-MACRO" "DEFMACRO" "DEFMETHOD" "DEFPACKAGE" "DEFPARAMETER" "DEFSETF" "DEFSTRUCT" "DEFTYPE" "DEFUN" "DEFVAR" "DELETE" "DELETE-DUPLICATES" "DELETE-FILE" "DELETE-IF" "DELETE-IF-NOT" "DELETE-PACKAGE" "DENOMINATOR" "DEPOSIT-FIELD" "DESCRIBE" "DESCRIBE-OBJECT" "DESTRUCTURING-BIND" "DIGIT-CHAR" "DIGIT-CHAR-P" "DIRECTORY" "DIRECTORY-NAMESTRING" "DISASSEMBLE" "DIVISION-BY-ZERO" "DO" "DO*" "DO-ALL-SYMBOLS" "DO-EXTERNAL-SYMBOLS" "DO-SYMBOLS" "DOCUMENTATION" "DOLIST" "DOTIMES" "DOUBLE-FLOAT" "DOUBLE-FLOAT-EPSILON" "DOUBLE-FLOAT-NEGATIVE-EPSILON" "DPB" "DRIBBLE" "DYNAMIC-EXTENT" "ECASE" "ECHO-STREAM" "ECHO-STREAM-INPUT-STREAM" "ECHO-STREAM-OUTPUT-STREAM" "ED" "EIGHTH" "ELT" "ENCODE-UNIVERSAL-TIME" "END-OF-FILE" "ENDP" "ENOUGH-NAMESTRING" "ENSURE-DIRECTORIES-EXIST" "ENSURE-GENERIC-FUNCTION" "EQ" "EQL" "EQUAL" "EQUALP" "ERROR" "ETYPECASE" "EVAL" "EVAL-WHEN" "EVENP" "EVERY" "EXP" "EXPORT" "EXPT" "EXTENDED-CHAR" "FBOUNDP" "FCEILING" "FDEFINITION" "FFLOOR" "FIFTH" "FILE-AUTHOR" "FILE-ERROR" "FILE-ERROR-PATHNAME" "FILE-LENGTH" "FILE-NAMESTRING" "FILE-POSITION" "FILE-STREAM" "FILE-STRING-LENGTH" "FILE-WRITE-DATE" "FILL" "FILL-POINTER" "FIND" "FIND-ALL-SYMBOLS" "FIND-CLASS" "FIND-IF" "FIND-IF-NOT" "FIND-METHOD" "FIND-PACKAGE" "FIND-RESTART" "FIND-SYMBOL" "FINISH-OUTPUT" "FIRST" "FIXNUM" "FLET" "FLOAT" "FLOAT-DIGITS" "FLOAT-PRECISION" "FLOAT-RADIX" "FLOAT-SIGN" "FLOATING-POINT-INEXACT" "FLOATING-POINT-INVALID-OPERATION" "FLOATING-POINT-OVERFLOW" "FLOATING-POINT-UNDERFLOW" "FLOATP" "FLOOR" "FMAKUNBOUND" "FORCE-OUTPUT" "FORMAT" "FORMATTER" "FOURTH" "FRESH-LINE" "FROUND" "FTRUNCATE" "FTYPE" "FUNCALL" "FUNCTION" "FUNCTION-KEYWORDS" "FUNCTION-LAMBDA-EXPRESSION" "FUNCTIONP" "GCD" "GENERIC-FUNCTION" "GENSYM" "GENTEMP" "GET" "GET-DECODED-TIME" "GET-DISPATCH-MACRO-CHARACTER" "GET-INTERNAL-REAL-TIME" "GET-INTERNAL-RUN-TIME" "GET-MACRO-CHARACTER" "GET-OUTPUT-STREAM-STRING" "GET-PROPERTIES" "GET-SETF-EXPANSION" "GET-UNIVERSAL-TIME" "GETF" "GETHASH" "GO" "GRAPHIC-CHAR-P" "HANDLER-BIND" "HANDLER-CASE" "HASH-TABLE" "HASH-TABLE-COUNT" "HASH-TABLE-P" "HASH-TABLE-REHASH-SIZE" "HASH-TABLE-REHASH-THRESHOLD" "HASH-TABLE-SIZE" "HASH-TABLE-TEST" "HOST-NAMESTRING" "IDENTITY" "IF" "IGNORABLE" "IGNORE" "IGNORE-ERRORS" "IMAGPART" "IMPORT" "IN-PACKAGE" "INCF" "INITIALIZE-INSTANCE" "INLINE" "INPUT-STREAM-P" "INSPECT" "INTEGER" "INTEGER-DECODE-FLOAT" "INTEGER-LENGTH" "INTEGERP" "INTERACTIVE-STREAM-P" "INTERN" "INTERNAL-TIME-UNITS-PER-SECOND" "INTERSECTION" "INVALID-METHOD-ERROR" "INVOKE-DEBUGGER" "INVOKE-RESTART" "INVOKE-RESTART-INTERACTIVELY" "ISQRT" "KEYWORD" "KEYWORDP" "LABELS" "LAMBDA" "LAMBDA-LIST-KEYWORDS" "LAMBDA-PARAMETERS-LIMIT" "LAST" "LCM" "LDB" "LDB-TEST" "LDIFF" "LEAST-NEGATIVE-DOUBLE-FLOAT" "LEAST-NEGATIVE-LONG-FLOAT" "LEAST-NEGATIVE-NORMALIZED-DOUBLE-FLOAT" "LEAST-NEGATIVE-NORMALIZED-LONG-FLOAT" "LEAST-NEGATIVE-NORMALIZED-SHORT-FLOAT" "LEAST-NEGATIVE-NORMALIZED-SINGLE-FLOAT" "LEAST-NEGATIVE-SHORT-FLOAT" "LEAST-NEGATIVE-SINGLE-FLOAT" "LEAST-POSITIVE-DOUBLE-FLOAT" "LEAST-POSITIVE-LONG-FLOAT" "LEAST-POSITIVE-NORMALIZED-DOUBLE-FLOAT" "LEAST-POSITIVE-NORMALIZED-LONG-FLOAT" "LEAST-POSITIVE-NORMALIZED-SHORT-FLOAT" "LEAST-POSITIVE-NORMALIZED-SINGLE-FLOAT" "LEAST-POSITIVE-SHORT-FLOAT" "LEAST-POSITIVE-SINGLE-FLOAT" "LENGTH" "LET" "LET*" "LISP-IMPLEMENTATION-TYPE" "LISP-IMPLEMENTATION-VERSION" "LIST" "LIST*" "LIST-ALL-PACKAGES" "LIST-LENGTH" "LISTEN" "LISTP" "LOAD" "LOAD-LOGICAL-PATHNAME-TRANSLATIONS" "LOAD-TIME-VALUE" "LOCALLY" "LOG" "LOGAND" "LOGANDC1" "LOGANDC2" "LOGBITP" "LOGCOUNT" "LOGEQV" "LOGICAL-PATHNAME" "LOGICAL-PATHNAME-TRANSLATIONS" "LOGIOR" "LOGNAND" "LOGNOR" "LOGNOT" "LOGORC1" "LOGORC2" "LOGTEST" "LOGXOR" "LONG-FLOAT" "LONG-FLOAT-EPSILON" "LONG-FLOAT-NEGATIVE-EPSILON" "LONG-SITE-NAME" "LOOP" "LOOP-FINISH" "LOWER-CASE-P" "MACHINE-INSTANCE" "MACHINE-TYPE" "MACHINE-VERSION" "MACRO-FUNCTION" "MACROEXPAND" "MACROEXPAND-1" "MACROLET" "MAKE-ARRAY" "MAKE-BROADCAST-STREAM" "MAKE-CONCATENATED-STREAM" "MAKE-CONDITION" "MAKE-DISPATCH-MACRO-CHARACTER" "MAKE-ECHO-STREAM" "MAKE-HASH-TABLE" "MAKE-INSTANCE" "MAKE-INSTANCES-OBSOLETE" "MAKE-LIST" "MAKE-LOAD-FORM" "MAKE-LOAD-FORM-SAVING-SLOTS" "MAKE-METHOD" "MAKE-PACKAGE" "MAKE-PATHNAME" "MAKE-RANDOM-STATE" "MAKE-SEQUENCE" "MAKE-STRING" "MAKE-STRING-INPUT-STREAM" "MAKE-STRING-OUTPUT-STREAM" "MAKE-SYMBOL" "MAKE-SYNONYM-STREAM" "MAKE-TWO-WAY-STREAM" "MAKUNBOUND" "MAP" "MAP-INTO" "MAPC" "MAPCAN" "MAPCAR" "MAPCON" "MAPHASH" "MAPL" "MAPLIST" "MASK-FIELD" "MAX" "MEMBER" "MEMBER-IF" "MEMBER-IF-NOT" "MERGE" "MERGE-PATHNAMES" "METHOD" "METHOD-COMBINATION" "METHOD-COMBINATION-ERROR" "METHOD-QUALIFIERS" "MIN" "MINUSP" "MISMATCH" "MOD" "MOST-NEGATIVE-DOUBLE-FLOAT" "MOST-NEGATIVE-FIXNUM" "MOST-NEGATIVE-LONG-FLOAT" "MOST-NEGATIVE-SHORT-FLOAT" "MOST-NEGATIVE-SINGLE-FLOAT" "MOST-POSITIVE-DOUBLE-FLOAT" "MOST-POSITIVE-FIXNUM" "MOST-POSITIVE-LONG-FLOAT" "MOST-POSITIVE-SHORT-FLOAT" "MOST-POSITIVE-SINGLE-FLOAT" "MUFFLE-WARNING" "MULTIPLE-VALUE-BIND" "MULTIPLE-VALUE-CALL" "MULTIPLE-VALUE-LIST" "MULTIPLE-VALUE-PROG1" "MULTIPLE-VALUE-SETQ" "MULTIPLE-VALUES-LIMIT" "NAME-CHAR" "NAMESTRING" "NBUTLAST" "NCONC" "NEXT-METHOD-P" "NIL" "NINTERSECTION" "NINTH" "NO-APPLICABLE-METHOD" "NO-NEXT-METHOD" "NOT" "NOTANY" "NOTEVERY" "NOTINLINE" "NRECONC" "NREVERSE" "NSET-DIFFERENCE" "NSET-EXCLUSIVE-OR" "NSTRING-CAPITALIZE" "NSTRING-DOWNCASE" "NSTRING-UPCASE" "NSUBLIS" "NSUBST" "NSUBST-IF" "NSUBST-IF-NOT" "NSUBSTITUTE" "NSUBSTITUTE-IF" "NSUBSTITUTE-IF-NOT" "NTH" "NTH-VALUE" "NTHCDR" "NULL" "NUMBER" "NUMBERP" "NUMERATOR" "NUNION" "ODDP" "OPEN" "OPEN-STREAM-P" "OPTIMIZE" "OR" "OTHERWISE" "OUTPUT-STREAM-P" "PACKAGE" "PACKAGE-ERROR" "PACKAGE-ERROR-PACKAGE" "PACKAGE-NAME" "PACKAGE-NICKNAMES" "PACKAGE-SHADOWING-SYMBOLS" "PACKAGE-USE-LIST" "PACKAGE-USED-BY-LIST" "PACKAGEP" "PAIRLIS" "PARSE-ERROR" "PARSE-INTEGER" "PARSE-NAMESTRING" "PATHNAME" "PATHNAME-DEVICE" "PATHNAME-DIRECTORY" "PATHNAME-HOST" "PATHNAME-MATCH-P" "PATHNAME-NAME" "PATHNAME-TYPE" "PATHNAME-VERSION" "PATHNAMEP" "PEEK-CHAR" "PHASE" "PI" "PLUSP" "POP" "POSITION" "POSITION-IF" "POSITION-IF-NOT" "PPRINT" "PPRINT-DISPATCH" "PPRINT-EXIT-IF-LIST-EXHAUSTED" "PPRINT-FILL" "PPRINT-INDENT" "PPRINT-LINEAR" "PPRINT-LOGICAL-BLOCK" "PPRINT-NEWLINE" "PPRINT-POP" "PPRINT-TAB" "PPRINT-TABULAR" "PRIN1" "PRIN1-TO-STRING" "PRINC" "PRINC-TO-STRING" "PRINT" "PRINT-NOT-READABLE" "PRINT-NOT-READABLE-OBJECT" "PRINT-OBJECT" "PRINT-UNREADABLE-OBJECT" "PROBE-FILE" "PROCLAIM" "PROG" "PROG*" "PROG1" "PROG2" "PROGN" "PROGRAM-ERROR" "PROGV" "PROVIDE" "PSETF" "PSETQ" "PUSH" "PUSHNEW" "QUOTE" "RANDOM" "RANDOM-STATE" "RANDOM-STATE-P" "RASSOC" "RASSOC-IF" "RASSOC-IF-NOT" "RATIO" "RATIONAL" "RATIONALIZE" "RATIONALP" "READ" "READ-BYTE" "READ-CHAR" "READ-CHAR-NO-HANG" "READ-DELIMITED-LIST" "READ-FROM-STRING" "READ-LINE" "READ-PRESERVING-WHITESPACE" "READ-SEQUENCE" "READER-ERROR" "READTABLE" "READTABLE-CASE" "READTABLEP" "REAL" "REALP" "REALPART" "REDUCE" "REINITIALIZE-INSTANCE" "REM" "REMF" "REMHASH" "REMOVE" "REMOVE-DUPLICATES" "REMOVE-IF" "REMOVE-IF-NOT" "REMOVE-METHOD" "REMPROP" "RENAME-FILE" "RENAME-PACKAGE" "REPLACE" "REQUIRE" "REST" "RESTART" "RESTART-BIND" "RESTART-CASE" "RESTART-NAME" "RETURN" "RETURN-FROM" "REVAPPEND" "REVERSE" "ROOM" "ROTATEF" "ROUND" "ROW-MAJOR-AREF" "RPLACA" "RPLACD" "SAFETY" "SATISFIES" "SBIT" "SCALE-FLOAT" "SCHAR" "SEARCH" "SECOND" "SEQUENCE" "SERIOUS-CONDITION" "SET" "SET-DIFFERENCE" "SET-DISPATCH-MACRO-CHARACTER" "SET-EXCLUSIVE-OR" "SET-MACRO-CHARACTER" "SET-PPRINT-DISPATCH" "SET-SYNTAX-FROM-CHAR" "SETF" "SETQ" "SEVENTH" "SHADOW" "SHADOWING-IMPORT" "SHARED-INITIALIZE" "SHIFTF" "SHORT-FLOAT" "SHORT-FLOAT-EPSILON" "SHORT-FLOAT-NEGATIVE-EPSILON" "SHORT-SITE-NAME" "SIGNAL" "SIGNED-BYTE" "SIGNUM" "SIMPLE-ARRAY" "SIMPLE-BASE-STRING" "SIMPLE-BIT-VECTOR" "SIMPLE-BIT-VECTOR-P" "SIMPLE-CONDITION" "SIMPLE-CONDITION-FORMAT-ARGUMENTS" "SIMPLE-CONDITION-FORMAT-CONTROL" "SIMPLE-ERROR" "SIMPLE-STRING" "SIMPLE-STRING-P" "SIMPLE-TYPE-ERROR" "SIMPLE-VECTOR" "SIMPLE-VECTOR-P" "SIMPLE-WARNING" "SIN" "SINGLE-FLOAT" "SINGLE-FLOAT-EPSILON" "SINGLE-FLOAT-NEGATIVE-EPSILON" "SINH" "SIXTH" "SLEEP" "SLOT-BOUNDP" "SLOT-EXISTS-P" "SLOT-MAKUNBOUND" "SLOT-MISSING" "SLOT-UNBOUND" "SLOT-VALUE" "SOFTWARE-TYPE" "SOFTWARE-VERSION" "SOME" "SORT" "SPACE" "SPECIAL" "SPECIAL-OPERATOR-P" "SPEED" "SQRT" "STABLE-SORT" "STANDARD" "STANDARD-CHAR" "STANDARD-CHAR-P" "STANDARD-CLASS" "STANDARD-GENERIC-FUNCTION" "STANDARD-METHOD" "STANDARD-OBJECT" "STEP" "STORAGE-CONDITION" "STORE-VALUE" "STREAM" "STREAM-ELEMENT-TYPE" "STREAM-ERROR" "STREAM-ERROR-STREAM" "STREAM-EXTERNAL-FORMAT" "STREAMP" "STRING" "STRING-CAPITALIZE" "STRING-DOWNCASE" "STRING-EQUAL" "STRING-GREATERP" "STRING-LEFT-TRIM" "STRING-LESSP" "STRING-NOT-EQUAL" "STRING-NOT-GREATERP" "STRING-NOT-LESSP" "STRING-RIGHT-TRIM" "STRING-STREAM" "STRING-TRIM" "STRING-UPCASE" "STRING/=" "STRING<" "STRING<=" "STRING=" "STRING>" "STRING>=" "STRINGP" "STRUCTURE" "STRUCTURE-CLASS" "STRUCTURE-OBJECT" "STYLE-WARNING" "SUBLIS" "SUBSEQ" "SUBSETP" "SUBST" "SUBST-IF" "SUBST-IF-NOT" "SUBSTITUTE" "SUBSTITUTE-IF" "SUBSTITUTE-IF-NOT" "SUBTYPEP" "SVREF" "SXHASH" "SYMBOL" "SYMBOL-FUNCTION" "SYMBOL-MACROLET" "SYMBOL-NAME" "SYMBOL-PACKAGE" "SYMBOL-PLIST" "SYMBOL-VALUE" "SYMBOLP" "SYNONYM-STREAM" "SYNONYM-STREAM-SYMBOL" "T" "TAGBODY" "TAILP" "TAN" "TANH" "TENTH" "TERPRI" "THE" "THIRD" "THROW" "TIME" "TRACE" "TRANSLATE-LOGICAL-PATHNAME" "TRANSLATE-PATHNAME" "TREE-EQUAL" "TRUENAME" "TRUNCATE" "TWO-WAY-STREAM" "TWO-WAY-STREAM-INPUT-STREAM" "TWO-WAY-STREAM-OUTPUT-STREAM" "TYPE" "TYPE-ERROR" "TYPE-ERROR-DATUM" "TYPE-ERROR-EXPECTED-TYPE" "TYPE-OF" "TYPECASE" "TYPEP" "UNBOUND-SLOT" "UNBOUND-SLOT-INSTANCE" "UNBOUND-VARIABLE" "UNDEFINED-FUNCTION" "UNEXPORT" "UNINTERN" "UNION" "UNLESS" "UNREAD-CHAR" "UNSIGNED-BYTE" "UNTRACE" "UNUSE-PACKAGE" "UNWIND-PROTECT" "UPDATE-INSTANCE-FOR-DIFFERENT-CLASS" "UPDATE-INSTANCE-FOR-REDEFINED-CLASS" "UPGRADED-ARRAY-ELEMENT-TYPE" "UPGRADED-COMPLEX-PART-TYPE" "UPPER-CASE-P" "USE-PACKAGE" "USE-VALUE" "USER-HOMEDIR-PATHNAME" "VALUES" "VALUES-LIST" "VARIABLE" "VECTOR" "VECTOR-POP" "VECTOR-PUSH" "VECTOR-PUSH-EXTEND" "VECTORP" "WARN" "WARNING" "WHEN" "WILD-PATHNAME-P" "WITH-ACCESSORS" "WITH-COMPILATION-UNIT" "WITH-CONDITION-RESTARTS" "WITH-HASH-TABLE-ITERATOR" "WITH-INPUT-FROM-STRING" "WITH-OPEN-FILE" "WITH-OPEN-STREAM" "WITH-OUTPUT-TO-STRING" "WITH-PACKAGE-ITERATOR" "WITH-SIMPLE-RESTART" "WITH-SLOTS" "WITH-STANDARD-IO-SYNTAX" "WRITE" "WRITE-BYTE" "WRITE-CHAR" "WRITE-LINE" "WRITE-SEQUENCE" "WRITE-STRING" "WRITE-TO-STRING" "Y-OR-N-P" "YES-OR-NO-P" "ZEROP") (:documentation "The COMMON-LISP package.")) ;; with COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.PACKAGE (defpackage "COMMON-LISP-USER" (:use "COMMON-LISP") (:nicknames "CL-USER") (:documentation "The COMMON-LISP-USER package.")) (eval-when (:execute :load-toplevel #-mocl :compile-toplevel) (setf *keyword-package* (find-package "KEYWORD") *common-lisp-package* (find-package "COMMON-LISP") *common-lisp-user-package* (find-package "COMMON-LISP-USER") *package* *common-lisp-user-package*)) ;;;; THE END ;;;;
18,963
Common Lisp
.lisp
317
56.488959
93
0.690075
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
099d2c83a9ef9fba496ae1e244238fc14e5212166f51d2081a631c33bbc96629
5,056
[ -1 ]
5,057
reader-test.lisp
informatimago_lisp/common-lisp/lisp-reader/reader-test.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: reader-test.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Test COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.READER. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2015-01-25 <PJB> Extracted from reader. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2024 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.READER.TEST" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SIMPLE-TEST") (:shadowing-import-from "COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.READER" "READTABLE" "COPY-READTABLE" "MAKE-DISPATCH-MACRO-CHARACTER" "READ" "READ-PRESERVING-WHITESPACE" "READ-DELIMITED-LIST" "READ-FROM-STRING" "READTABLE-CASE" "READTABLEP" "SET-DISPATCH-MACRO-CHARACTER" "GET-DISPATCH-MACRO-CHARACTER" "SET-MACRO-CHARACTER" "GET-MACRO-CHARACTER" "SET-SYNTAX-FROM-CHAR" "WITH-STANDARD-IO-SYNTAX" "*READ-BASE*" "*READ-DEFAULT-FLOAT-FORMAT*" "*READ-EVAL*" "*READ-SUPPRESS*" "*READTABLE*" ;; Extensions: "READTABLE-SYNTAX-TABLE" "READTABLE-PARSE-TOKEN" "SET-INDIRECT-DISPATCH-MACRO-CHARACTER" "SET-INDIRECT-MACRO-CHARACTER" "LIST-ALL-MACRO-CHARACTERS" "SIMPLE-READER-ERROR" "SIMPLE-END-OF-FILE" "MISSING-PACKAGE-ERROR" "SYMBOL-IN-MISSING-PACKAGE-ERROR" "MISSING-SYMBOL-ERROR" "SYMBOL-MISSING-IN-PACKAGE-ERROR" "INTERN-HERE" "RETURN-UNINTERNED" ;; Utilities: "POTENTIAL-NUMBER-P") (:import-from "COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.READER" "EVAL-FEATURE" "PROPER-LIST-P") (:export "TEST/ALL" "TEST/READER" "TEST/SYMBOLS" "TEST/FEATURES" "TEST/LISTS" "TEST/SHARP-PLUS-WITH-SHARP-REFERENCES" "TEST/BIT-VECTOR--NUMBERS--PATHNAMES" "TEST/COMPLEX-NUMBERS" "TEST/READ-DELIMITED-LIST/COMMENTS" "TEST/LISTS/COMMENTS" "TEST/VECTOR-WITH-TOO-MUCH-DATA" "TEST/NON-EMPTY-VECTOR-WITH-TOO-LITTLE-DATA" "TEST/VECTORS" "TEST/CHECK-SYMBOLS" "TEST/POTENTIAL-NUMBER-P" "TEST/MULTIPLE-ESCAPE") (:documentation " This package tests the COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.READER package. License: AGPL3 Copyright Pascal J. Bourguignon 2006 - 2024 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.READER.TEST") (define-test test/proper-list-p () (map nil (lambda (test) (check eq (proper-list-p (second test)) (first test) ((first test) (second test)))) '((nil x) (t ()) (t (a)) (t (a b)) (t (a b c)) (t (a b c d)) (nil (a . x)) (nil (a b . x)) (nil (a b c . x)) (nil (a b c d . x)) (nil #1=(a . #1#)) (nil #2=(a b . #2#)) (nil #3=(a b c . #3#)) (nil #4=(a b c d . #4#)) (nil (1 . #1#)) (nil (1 2 . #1#)) (nil (1 2 3 . #1#)) (nil (1 2 3 4 . #1#)) (nil (1 . #2#)) (nil (1 2 . #2#)) (nil (1 2 3 . #2#)) (nil (1 2 3 4 . #2#)) (nil (1 . #3#)) (nil (1 2 . #3#)) (nil (1 2 3 . #3#)) (nil (1 2 3 4 . #3#)) (nil (1 . #4#)) (nil (1 2 . #4#)) (nil (1 2 3 . #4#)) (nil (1 2 3 4 . #4#))))) (define-test test/reader () (let ((*read-base* 10) (*read-eval* t) (*read-suppress* nil) (*read-default-float-format* 'single-float) (*package* (find-package "COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.READER.TEST"))) (dolist (test '( ;; integer ::= [sign] digit+ (nil "0" 0.) (nil "1" 1.) (nil "2" 2.) (nil "9" 9.) (nil "10" 10.) (nil "11" 11.) (nil "12" 12.) (nil "19" 19.) (((*read-base* 3.)) "0" 0.) (((*read-base* 3.)) "1" 1.) (((*read-base* 3.)) "2" 2.) (((*read-base* 3.)) "9" |9|) (((*read-base* 3.)) "10" 3.) (((*read-base* 3.)) "11" 4.) (((*read-base* 3.)) "13" |13|) (nil "-0" -0.) (nil "-1" -1.) (nil "-2" -2.) (nil "-9" -9.) (nil "-10" -10.) (nil "-11" -11.) (nil "-12" -12.) (nil "-19" -19.) (((*read-base* 3.)) "-0" -0.) (((*read-base* 3.)) "-1" -1.) (((*read-base* 3.)) "-2" -2.) (((*read-base* 3.)) "-9" |-9|) (((*read-base* 3.)) "-10" -3.) (((*read-base* 3.)) "-11" -4.) (((*read-base* 3.)) "-13" |-13|) (nil "+0" +0.) (nil "+1" +1.) (nil "+2" +2.) (nil "+9" +9.) (nil "+10" +10.) (nil "+11" +11.) (nil "+12" +12.) (nil "+19" +19.) (((*read-base* 3.)) "+0" +0.) (((*read-base* 3.)) "+1" +1.) (((*read-base* 3.)) "+2" +2.) (((*read-base* 3.)) "+9" |+9|) (((*read-base* 3.)) "+10" +3.) (((*read-base* 3.)) "+11" +4.) (((*read-base* 3.)) "+13" |+13|) ;; integer ::= [sign] decimal-digit+ decimal-point (nil "0." 0.) (nil "1." 1.) (nil "2." 2.) (nil "9." 9.) (nil "10." 10.) (nil "11." 11.) (nil "12." 12.) (nil "19." 19.) (((*read-base* 3.)) "0." 0.) (((*read-base* 3.)) "1." 1.) (((*read-base* 3.)) "2." 2.) (((*read-base* 3.)) "9." 9.) (((*read-base* 3.)) "10." 10.) (((*read-base* 3.)) "11." 11.) (((*read-base* 3.)) "13." 13.) (nil "-0." -0.) (nil "-1." -1.) (nil "-2." -2.) (nil "-9." -9.) (nil "-10." -10.) (nil "-11." -11.) (nil "-12." -12.) (nil "-19." -19.) (((*read-base* 3.)) "-0." -0.) (((*read-base* 3.)) "-1." -1.) (((*read-base* 3.)) "-2." -2.) (((*read-base* 3.)) "-9." -9.) (((*read-base* 3.)) "-10." -10.) (((*read-base* 3.)) "-11." -11.) (((*read-base* 3.)) "-13." -13.) (nil "+0." +0.) (nil "+1." +1.) (nil "+2." +2.) (nil "+9." +9.) (nil "+10." +10.) (nil "+11." +11.) (nil "+12." +12.) (nil "+19." +19.) (((*read-base* 3.)) "+0." +0.) (((*read-base* 3.)) "+1." +1.) (((*read-base* 3.)) "+2." +2.) (((*read-base* 3.)) "+9." +9.) (((*read-base* 3.)) "+10." +10.) (((*read-base* 3.)) "+11." +11.) (((*read-base* 3.)) "+13." +13.) ;; ratio ::= [sign] {digit}+ slash {digit}+ (nil "0/0" nil division-by-zero) (nil "1/0" nil division-by-zero) (nil "10/000" nil division-by-zero) (nil "0/1" 0) (nil "1/1" 1) (nil "2/1" 2) (nil "20/10" 2) (nil "200/100" 2) (nil "0/2" 0) (nil "1/2" 1/2) (nil "0/20" 0) (nil "10/20" 1/2) (nil "100/200" 1/2) (nil "001/2" 1/2) (nil "000/20" 0) (nil "010/20" 1/2) (nil "100/200" 1/2) (nil "12345/54321" 12345/54321) (nil "+0/0" nil division-by-zero) (nil "+1/0" nil division-by-zero) (nil "+10/000" nil division-by-zero) (nil "+0/1" 0) (nil "+1/1" 1) (nil "+2/1" 2) (nil "+20/10" 2) (nil "+200/100" 2) (nil "+0/2" 0) (nil "+1/2" 1/2) (nil "+0/20" 0) (nil "+10/20" 1/2) (nil "+100/200" 1/2) (nil "+001/2" 1/2) (nil "+000/20" 0) (nil "+010/20" 1/2) (nil "+100/200" 1/2) (nil "+12345/54321" 12345/54321) (nil "-0/0" nil division-by-zero) (nil "-1/0" nil division-by-zero) (nil "-10/000" nil division-by-zero) (nil "-0/1" -0) (nil "-1/1" -1) (nil "-2/1" -2) (nil "-20/10" -2) (nil "-200/100" -2) (nil "-0/2" -0) (nil "-1/2" -1/2) (nil "-0/20" -0) (nil "-10/20" -1/2) (nil "-100/200" -1/2) (nil "-001/2" -1/2) (nil "-000/20" -0) (nil "-010/20" -1/2) (nil "-100/200" -1/2) (nil "-12345/54321" -12345/54321) ;;; float ::= [sign] {decimal-digit}* decimal-point {decimal-digit}+ exponent ;;; float ::= [sign] {decimal-digit}* decimal-point {decimal-digit}+ ;;; float ::= [sign] {decimal-digit}+ exponent ;;; float ::= [sign] {decimal-digit}+ decimal-point {decimal-digit}* exponent ;;; exponent ::= exponent-marker [sign] {digit}+ ;;; ;;; consing-dot ::= dot ;;; ;;; symbol ::= symbol-name ;;; | package-marker symbol-name ;;; | package-marker package-marker symbol-name ;;; | package-name package-marker symbol-name ;;; | package-name package-marker package-marker symbol-name ) :success) (multiple-value-bind (val err) (ignore-errors (eval `(progv ',(mapcar (function first) (first test)) ',(mapcar (function second) (first test)) (read-from-string ,(second test))))) (assert-true (if (fourth test) (typep err (fourth test)) (eql val (third test))) (err (fourth test) val (third test)) "~S gives ~:[~S~;~:*~S~*~]; expected: ~S" `(let ,(first test) (read-from-string ,(second test))) err val (or (fourth test) (third test))))))) (defun test-cases (test-name cases) (let ((*package* (find-package "COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.READER.TEST"))) (dolist (test cases :success) (destructuring-bind (expression expected-values expected-error) test (multiple-value-bind (actual-values actual-error) (ignore-errors (multiple-value-list (eval expression))) (assert-true (or (and (null expected-error) (null actual-error)) (typep actual-error expected-error)) (expression expected-error actual-error) "Test ~A~%Testing ~S, expected ~ ~:[no error~;an error of type ~:*~S~], ~ got this error: ~A" test-name expression expected-error actual-error) (assert-true (equalp expected-values actual-values) (expression expected-values actual-values) "Test ~A~%Testing ~S, expected ~S, got ~S" expression test-name expected-values actual-values)))))) (defmacro tests (&rest cases) (if (stringp (first cases)) `(test-cases ,(first cases) ',(rest cases)) `(test-cases "unamed" ',cases))) (define-test test/symbols () (tests "symbols" ((read-from-string "( abc ab a || |a| |ab| |a b c| )") ((abc ab a || |a| |ab| |a b c|) ; 32) nil))) (define-test test/features () (let ((*features* '(:a :b :c))) (tests "*features*" ((eval-feature ':a *standard-input*) (t) nil) ((eval-feature ':z *standard-input*) (nil) nil) ((eval-feature '42 *standard-input*) (nil) nil) ((eval-feature '(:not :a) *standard-input*) (nil) nil) ((eval-feature '(:not :z) *standard-input*) (t) nil) ((eval-feature '(:not :a :b) *standard-input*) () reader-error) ((eval-feature '(:and) *standard-input*) (t) nil) ((eval-feature '(:and :a) *standard-input*) (t) nil) ((eval-feature '(:and :a :b) *standard-input*) (t) nil) ((eval-feature '(:and :a :c) *standard-input*) (t) nil) ((eval-feature '(:and :a :z) *standard-input*) (nil) nil) ((eval-feature '(:and :y :z) *standard-input*) (nil) nil) ((eval-feature '(:or) *standard-input*) (nil) nil) ((eval-feature '(:or :a) *standard-input*) (t) nil) ((eval-feature '(:or :a :b) *standard-input*) (t) nil) ((eval-feature '(:or :a :c) *standard-input*) (t) nil) ((eval-feature '(:or :a :z) *standard-input*) (t) nil) ((eval-feature '(:or :y :z) *standard-input*) (nil) nil) ((eval-feature '(:or (:and :a (:not :z)) (:and (:not :a) :z)) *standard-input*) (t) nil) ((eval-feature '(:and (:or :a (:not :z)) (:or (:not :a) :z)) *standard-input*) (nil) nil) ((eval-feature '(:and :a :b (:or :y :z (:not :a))) *standard-input*) (nil) nil) ((eval-feature '(:and :a :b (:or :y :z (:not 42))) *standard-input*) (t) nil)))) (define-test test/lists () (tests "lists" ((read-from-string "()") (() 2) nil) ((read-from-string "(a)") ((a) 3) nil) ((read-from-string "(a b)") ((a b) 5) nil) ((read-from-string "(a b c)") ((a b c) 7) nil) ((read-from-string "(a b c d)") ((a b c d) 9) nil) ((read-from-string "(a b c . d)") ((a b c . d) 11) nil) ((read-from-string "(a b c . d e)") nil reader-error) ((read-from-string "(a b c . . d)") nil reader-error) ((read-from-string "(a b c . d .)") nil reader-error) ((let ((*features* '(:test))) (read-from-string "(a b c #+test d)")) ((a b c d) 16) nil) ((let ((*features* '(:test))) (read-from-string "(a b c #-test d)")) ((a b c) 16) nil) ((let ((*features* '(:test))) (read-from-string "(a b c . #+test d)")) ((a b c . d) 18) nil) ((let ((*features* '(:test))) (read-from-string "(a b c . #-test d e)")) ((a b c . e) 20) nil) ((let ((*features* '(:test))) (read-from-string "(a b c #+test . d)")) ((a b c . d) 18) nil) ((let ((*features* '(:test))) (read-from-string "(a b c #-test . d)")) ((a b c d) 18) nil) ((read-from-string "(#+(or) #$foo xyz)") nil reader-error) ((read-from-string "(#+(or) abc:def:ghi xyz)") ((xyz) 24) nil))) (define-test test/sharp-plus-with-sharp-references () (tests "#+ with #= and ##" ((let ((*features* (quote (:a :b)))) (read-from-string "(#+#1=(or a b) #1#)")) (((:or :a :b)) 19) nil) ((let ((*features* (quote (:a :b)))) (read-from-string "(#+#.(cl:if (cl:eq :a (cl:first cl:*features*)) '(:and) '(:or)) equal)")) ((equal) 70) nil))) #-(and) (tests ((let ((*features* (quote (:a :b)))) (read-from-string "#+#1=(or a b) #1#")) ((:or :a :b) 44) nil)) (define-test test/bit-vector--numbers--pathnames () (tests "bit vectors, numbers, and pathnames" ((read-from-string "(#*101111 #6*10111110101 #6*101111 #6*1010 #6*1011 #* #0*11010)") ((#*101111 #*101111 #*101111 #*101000 #*101111 #* #*) 63) nil) ((read-from-string "(#b10111101 #o275 #xbd #36r59)") ((189 189 189 189) 30) nil) ((read-from-string "#P\"/tmp/a.c\"") (#.(make-pathname :directory '(:absolute "tmp") :name "a" :type "c" :version #+(or ecl sbcl) :newest #-(or ecl sbcl) nil :case :local) 12) nil))) #- (and) (tests ((progn (defstruct s a b c) (read-from-string "#S(s a 1 b 2 c 3)")) (#s(s :a 1 :b 2 :c 3) 17) nil)) (define-test test/complex-numbers () #-clisp (tests "complex numbers" ((read-from-string "( #C(123 456) #c(-123 456) #C(12.3f0 456) #c(-123 45.6f0) #C(123/10 456/100) #c(-123/10 456/100))") (( #c(123 456) #c(-123 456) #c(12.3f0 456) #c(-123 45.6f0) #c(123/10 456/100) #c(-123/10 456/100) ) 155) nil))) (define-test test/read-delimited-list/comments () (tests "read-delimited-list with comments" ((with-input-from-string (src " \"!A\" ) def) ") (values (read-delimited-list #\) src) (read-delimited-list #\) src))) (("!A") (def)) nil) ((with-input-from-string (src "#( \"!A\" ) (def) ") (values (read src) (read src))) (#("!A") (def)) nil) ((with-input-from-string (src "( \"!A\" ) (def) ") (values (read src) (read src))) (("!A") (def)) nil) ((with-input-from-string (src " \"!A\" ; comment ) def) ") (values (read-delimited-list #\) src) (read-delimited-list #\) src))) (("!A") (def)) nil) ((with-input-from-string (src "#( \"!A\" ; comment ) (def) ") (values (read src) (read src))) (#("!A") (def)) nil) ((with-input-from-string (src "( \"!A\" ; comment ) (def) ") (values (read src) (read src))) (("!A") (def)) nil))) (define-test test/lists/comments () (tests "lists with comments" ((read-from-string "( () (a) (a b) (a b c) (a . ()) (a . b) (a b . ()) (a b . c) ( ; comment ) (a ; comment ) (a ; comment b) (a b c ; comment ) (a ; comment . ()) (a . ; comment ()) (a ; comment . b) (a . ; comment b) (a . b ; comment ) (a b .; comment ()) (a b . c;comment ))") ((nil (a) (a b) (a b c) (a) (a . b) (a b) (a b . c) nil (a) (a b) (a b c) (a) (a) (a . b) (a . b) (a . b) (a b) (a b . c)) 469) nil))) (define-test test/vector-with-too-much-data () (tests "vector with too much data" ((with-input-from-string (input "#2(a b c) d e") (values (read input) (read-line input))) (#(a b) " d e") nil))) (define-test test/vector-with-too-little-data () (tests "non-empty vector with too little data" ((length (read-from-string "#2()")) (2) nil))) (define-test test/vectors () (tests "vectors and vectors with comments" ((read-from-string "( #() #(a) #(a b) #(a b c) #(a #()) #(a b) #(a b #()) #(a b c) #2(a) #2(a b) #2(a b c) #2(a #()) #2(a b) #2(a b #()) #2(a b c) #( ; comment ) #(a ; comment ) #(a ; comment b) #(a b c ; comment ) #(a ; comment #()) #(a ; comment #()) #(a ; comment b) #(a ; comment b) #(a b ; comment ) #(a b ; comment #()) #(a b c;comment ))") ((#() #(a) #(a b) #(a b c) #(a #()) #(a b) #(a b #()) #(a b c) #(a a) #(a b) #(a b) #(a #()) #(a b) #(a b) #(a b) #() #(a) #(a b) #(a b c) #(a #()) #(a #()) #(a b) #(a b) #(a b) #(a b #()) #(a b c)) 580) nil))) (define-test test/check-symbols () (dolist (sym '("READTABLE" "COPY-READTABLE" "MAKE-DISPATCH-MACRO-CHARACTER" "READ" "READ-PRESERVING-WHITESPACE" "READ-DELIMITED-LIST" "READ-FROM-STRING" "READTABLE-CASE" "READTABLEP" "SET-DISPATCH-MACRO-CHARACTER" "GET-DISPATCH-MACRO-CHARACTER" "SET-MACRO-CHARACTER" "GET-MACRO-CHARACTER" "SET-SYNTAX-FROM-CHAR" "WITH-STANDARD-IO-SYNTAX" "*READ-BASE*" "*READ-DEFAULT-FLOAT-FORMAT*" "*READ-EVAL*" "*READ-SUPPRESS*" "*READTABLE*") :success) (let ((s-here (find-symbol sym *package*)) (s-cl (find-symbol sym "COMMON-LISP"))) (assert-true (not (eq s-here s-cl)) () "The symbol ~S is interned both in COMMON-LISP and in ~A" s-here (package-name *package*))))) (define-test test/potential-number-p () (assert-true (every (function potential-number-p) '("1b5000" "777777q" "1.7J" "-3/4+6.7J" "12/25/83" "27^19" "3^4/5" "6//7" "3.1.2.6" "^-43^" "3.141_592_653_589_793_238_4" "-3.7+2.6i-6.17j+19.6k" "+.e2"))) (assert-true (notany (function potential-number-p) '("/" "/5" "+" "1+" "1-" "foo+" "ab.cd" "_" "^" "^/-"))) (let ((pns '("bad-face" "25-dec-83" "a/b" "fad_cafe" "f^" ))) (let ((*read-base* 16.)) (assert-true (every (function potential-number-p) pns))) (let ((*read-base* 10.)) (assert-true (notany (function potential-number-p) pns))))) (define-test test/multiple-escape () (assert-true (numberp (read-from-string "5"))) (assert-true (symbolp (read-from-string "||5"))) (assert-true (symbolp (read-from-string "5||"))) (assert-true (numberp (read-from-string "5."))) (assert-true (symbolp (read-from-string "||5."))) (assert-true (symbolp (read-from-string "5.||"))) (assert-true (symbolp (read-from-string "5||."))) (assert-true (numberp (read-from-string "5/2"))) (assert-true (symbolp (read-from-string "||5/2"))) (assert-true (symbolp (read-from-string "5/2||"))) (assert-true (symbolp (read-from-string "5||/2"))) (assert-true (numberp (read-from-string "5.2"))) (assert-true (symbolp (read-from-string "||5.2"))) (assert-true (symbolp (read-from-string "5.2||"))) (assert-true (symbolp (read-from-string "5||.2")))) (define-test test/all () (let ((*package* (find-package "COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.READER.TEST"))) (test/proper-list-p) (test/reader) (test/symbols) (test/features) (test/lists) (test/sharp-plus-with-sharp-references) (test/bit-vector--numbers--pathnames) (test/complex-numbers) (test/read-delimited-list/comments) (test/lists/comments) (test/vector-with-too-much-data) (test/vector-with-too-little-data) (test/vectors) (test/check-symbols) (test/potential-number-p) (test/multiple-escape))) ;;;; THE END ;;;;
26,358
Common Lisp
.lisp
633
29.883096
103
0.436312
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
24ad81a512e831addff26a55832611064068a0bdd4fe28f2f0547dbf0a1a6175
5,057
[ -1 ]
5,058
package-pac.lisp
informatimago_lisp/common-lisp/lisp-reader/package-pac.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: package.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; See defpackage documentation string. ;;;; ;;;;AUTHORS ;;;; <XACH> Zachary Beane <[email protected]>, ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2012-04-03 <PJB> Completed corrections to pass package ansi-tests. ;;;; 2012-03-30 <PJB> Added checks, made the API conforming to CL. ;;;; 2012-03-30 <PJB> Added this header; Removed "Z" prefix to CL ;;;; symbol names; shadowed and exported them. ;;;;BUGS ;;;; ;;;; make-load-form for packages should probably return two forms, since ;;;; packages can have circular dependencies. ;;;; ;;;; Are missing some standard restarts to correct ;;;; conflicts. (choosing one or the other symbol, doing the same ;;;; for all conflicts, etc). ;;;; ;;;;LEGAL ;;;; Copyright (c) 2012 Zachary Beane <[email protected]>, All Rights Reserved ;;;; Copyright (c) 2012 Pascal J. Bourguignon <[email protected]>, All Rights Reserved ;;;; ;;;; Redistribution and use in source and binary forms, with or without ;;;; modification, are permitted provided that the following conditions ;;;; are met: ;;;; ;;;; * Redistributions of source code must retain the above copyright ;;;; notice, this list of conditions and the following disclaimer. ;;;; ;;;; * Redistributions in binary form must reproduce the above ;;;; copyright notice, this list of conditions and the following ;;;; disclaimer in the documentation and/or other materials ;;;; provided with the distribution. ;;;; ;;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED ;;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ;;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ;;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ;;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ;;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ;;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (cl:defpackage "COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.PACKAGE" (:use "COMMON-LISP") (:nicknames "ZPACK") (:shadow "SIMPLE-TYPE-ERROR" "PRINT-NOT-READABLE" "PRINT-NOT-READABLE-OBJECT") (:shadow . #1=("SYMBOL" "SYMBOLP" "MAKE-SYMBOL" "SYMBOL-NAME" "SYMBOL-PACKAGE" "SYMBOL-VALUE" "SYMBOL-FUNCTION" "SYMBOL-PLIST" "BOUNDP" "FBOUNDP" "KEYWORD" "KEYWORDP" "PACKAGE" "PACKAGEP" "MAKE-PACKAGE" "FIND-PACKAGE" "DELETE-PACKAGE" "FIND-SYMBOL" "IMPORT" "INTERN" "SHADOW" "SHADOWING-IMPORT" "EXPORT" "UNEXPORT" "UNINTERN" "USE-PACKAGE" "UNUSE-PACKAGE" "PACKAGE-NAME" "PACKAGE-NICKNAMES" "PACKAGE-USE-LIST" "PACKAGE-USED-BY-LIST" "PACKAGE-SHADOWING-SYMBOLS" "LIST-ALL-PACKAGES" "FIND-ALL-SYMBOLS" "RENAME-PACKAGE" "*PACKAGE*" "WITH-PACKAGE-ITERATOR" "DO-SYMBOLS" "DO-EXTERNAL-SYMBOLS" "DO-ALL-SYMBOLS" "DEFPACKAGE" "IN-PACKAGE" "PACKAGE-ERROR" "PACKAGE-ERROR-PACKAGE")) (:export . #1#) ;; Additionnal conditions: (:export "PACKAGE-EXISTS-ERROR" "PACKAGE-DOES-NOT-EXIST-ERROR" "SYMBOL-CONFLICT-ERROR" "SYMBOL-CONFLICT-EXISTING-SYMBOL" "SYMBOL-CONFLICT-IMPORTED-SYMBOL" "PACKAGE-DOCUMENTATION") (:documentation " This package implements the Common Lisp package system. <Xach> The basic idea of that file is that the semantics of the CL package system can be implemented by an object with three special kinds of tables (present-table, shadowing-table, external-table) and two lists (used-packs, used-by-packs). The rest is implementation. It shadows the CL symbols dealing with packages, and exports replacements that implement the package system anew. Additionnal symbol exported: PACKAGE-EXISTS-ERROR PACKAGE-DOES-NOT-EXIST-ERROR SYMBOL-CONFLICT-ERROR SYMBOL-CONFLICT-EXISTING-SYMBOL SYMBOL-CONFLICT-IMPORTED-SYMBOL PACKAGE-DOCUMENTATION License: BSD Copyright (c) 2012 Zachary Beane <[email protected]>, All Rights Reserved Copyright (c) 2012 Pascal J. Bourguignon <[email protected]>, All Rights Reserved Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ")) ;;;; THE END ;;;;
6,391
Common Lisp
.lisp
129
44.604651
93
0.670349
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
0f5930e1964427873b1b3ab35fe6494d48a5455450ac7828fc26b0ef7ba7002d
5,058
[ -1 ]
5,059
reader.lisp
informatimago_lisp/common-lisp/lisp-reader/reader.lisp
;;;;************************************************************************** ;;;;FILE: reader.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; See defpackage documentation string. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2024-07-09 <PJB> Corrected || bug. Now 5|| is read as a symbol. ;;;; 2015-07-21 <PJB> Synchronized list-all-macro-characters with the one in com.informatimago.tools. ;;;; 2012-05-14 <PJB> Corrected set-syntax-from-char. ;;;; 2011-04-29 <PJB> Added potential-number-p. ;;;; 2009-08-26 <PJB> Corrected bugs reading "||", "( ;comment )" and "#C(123 456)". ;;;; 2007-03-04 <PJB> Extracted from source.lisp ;;;;BUGS ;;;; ;;;; When we've reached the end of the stream, if we (read stream nil) ;;;; it goes on an infinite loop. ;;;; ;;;; (READ-FROM-STRING "#1=(a b . #1#)") gives an error. ;;;; ;;;; `(,@x) is read as `(, @x) instead of `(,@ x) ;;;; ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2006 - 2024 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.READER" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.LISP-SEXP.SOURCE-FORM") (:shadow "READTABLE" "COPY-READTABLE" "MAKE-DISPATCH-MACRO-CHARACTER" "READ" "READ-PRESERVING-WHITESPACE" "READ-DELIMITED-LIST" "READ-FROM-STRING" "READTABLE-CASE" "READTABLEP" "SET-DISPATCH-MACRO-CHARACTER" "GET-DISPATCH-MACRO-CHARACTER" "SET-MACRO-CHARACTER" "GET-MACRO-CHARACTER" "SET-SYNTAX-FROM-CHAR" "WITH-STANDARD-IO-SYNTAX" "*READ-BASE*" "*READ-DEFAULT-FLOAT-FORMAT*" "*READ-EVAL*" "*READ-SUPPRESS*" "*READTABLE*") (:export "READTABLE" "COPY-READTABLE" "MAKE-DISPATCH-MACRO-CHARACTER" "READ" "READ-PRESERVING-WHITESPACE" "READ-DELIMITED-LIST" "READ-FROM-STRING" "READTABLE-CASE" "READTABLEP" "SET-DISPATCH-MACRO-CHARACTER" "GET-DISPATCH-MACRO-CHARACTER" "SET-MACRO-CHARACTER" "GET-MACRO-CHARACTER" "SET-SYNTAX-FROM-CHAR" "WITH-STANDARD-IO-SYNTAX" "*READ-BASE*" "*READ-DEFAULT-FLOAT-FORMAT*" "*READ-EVAL*" "*READ-SUPPRESS*" "*READTABLE*" ;; Extensions: "READTABLE-SYNTAX-TABLE" "READTABLE-PARSE-TOKEN" "SET-INDIRECT-DISPATCH-MACRO-CHARACTER" "SET-INDIRECT-MACRO-CHARACTER" "LIST-ALL-MACRO-CHARACTERS" "SIMPLE-READER-ERROR" "SIMPLE-END-OF-FILE" "MISSING-PACKAGE-ERROR" "SYMBOL-IN-MISSING-PACKAGE-ERROR" "MISSING-SYMBOL-ERROR" "SYMBOL-MISSING-IN-PACKAGE-ERROR" "UNEXPORTED-SYMBOL-ERROR" "INTERN-HERE" "RETURN-UNINTERNED" "INVALID-SYMBOL-COMPONENT-LIST" "INTERNAL-SYMBOL" "MISSING-SYMBOL" "MISSING-PACKAGE" "SYMBOL-FROM-SPLIT-TOKEN" "MAKE-SYMBOL-PARSER-FUNCTION" "MAKE-TOKEN-PARSER" ;; Utilities: "POTENTIAL-NUMBER-P") (:documentation " This package implements a standard Common Lisp reader. We implement a Common Lisp Reader to be able to read lisp sources. This is a complete standard compliant lisp reader, with additionnal hooks (token parser). A READTABLE-PARSE-TOKEN function takes a TOKEN as argument, and must return two values: - A boolean indicating whether the it could parse the token, - a parsed lisp object it could, or an error message (string) if not. See also the TOKEN functions, CONSTITUENT-TRAIT, SYNTAX-TABLE and CHARACTER-DESCRIPTION... License: AGPL3 Copyright Pascal J. Bourguignon 2006 - 2024 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.READER") (define-condition simple-reader-error (simple-error reader-error) () (:documentation "A simple reader error condition.")) (define-condition simple-end-of-file (simple-error end-of-file) () (:documentation "A simple end-of-file condition.")) (define-condition missing-package-error (reader-error) ((package-name :initarg :package-name)) (:documentation "The error condition signaled when trying use an inexistant package.")) (define-condition symbol-in-missing-package-error (missing-package-error) ((symbol-name :initarg :symbol-name)) (:documentation "The error condition signaled when trying to read a symbol in an inexistant package.") (:report (lambda (condition stream) (format stream "Tried to read a symbol named ~S in an inexistant package named ~S." (slot-value condition 'symbol-name) (slot-value condition 'package-name))))) (define-condition missing-symbol-error (reader-error) ((symbol-name :initarg :symbol-name)) (:documentation "The error condition signaled when trying to read a symbol not exported from a package.")) (define-condition symbol-missing-in-package-error (missing-symbol-error) ((package-name :initarg :package-name)) (:documentation "The error condition signaled when trying to read a symbol not exported from a package.") (:report (lambda (condition stream) (format stream "Tried to read an inexistant external symbol named ~S the package ~S." (slot-value condition 'symbol-name) (slot-value condition 'package-name))))) (define-condition unexported-symbol-error (missing-symbol-error) ((package-name :initarg :package-name)) (:documentation "The error condition signaled when trying to read a symbol not exported from a package.") (:report (lambda (condition stream) (format stream "Tried to read an unexported symbol named ~S the package ~S." (slot-value condition 'symbol-name) (slot-value condition 'package-name))))) (defun serror (condition stream control-string &rest arguments) (error condition :stream stream :format-control control-string :format-arguments arguments)) ;; (LET ((*READTABLE* (COPY-READTABLE NIL))) ;; (SET-DISPATCH-MACRO-CHARACTER ;; #\# #\. (LAMBDA (&REST ARGS) ARGS))) ;; ;; (setf (readtable-case *readtable*) :preserve) ;; (let ((*readtable* (copy-readtable))) ;; ;; Quick and dirty disable : --> read three or four tokens ;; ;; for pack:sym or pack::sym ;; (set-macro-character #\: (lambda (stream char) #\:) nil) ;; (SAFE-TEXT-FILE-TO-STRING-LIST path)) ;; ;; ;; (defun unnamed-char-p (ch) ;; (not (null (regexp:match "^U\\([0-9A-F]\\{4\\}\\|[0-9A-F]\\{8\\}\\)$" ;; (char-name ch))))) ;; ;; ;; (defun collect-chars (&key (start 0) (end #x11000) name) ;; (loop ;; :with table = (make-hash-table :test (function equalp)) ;; :for code :from start :below end ;; :for char = (code-char code) ;; :for name = (char-name char) ;; :do (unless (unnamed-char-p char) ;; (dolist (word (regexp:regexp-split "[-_]" name)) ;; (push char (gethash word table nil)))) ;; :finally (return table))) ;;---------------------------------------- (defclass character-description () ((syntax :reader character-syntax :initarg :syntax) (traits :reader character-constituent-traits :initarg :traits :initform nil) (macro :reader character-macro :initarg :macro :initform nil :documentation "A macro character function.") (dispatch :reader character-dispatch :initarg :dispatch :initform nil :documentation "A HASH-TABLE character -> dmc function.")) (:documentation " Description of one character. In the syntax tables, a single character description instance can be shared by several characters, but with copy-on-write. ")) ;; macro-character-function ;; dispatch-macro --> map character -> dispatch-macro-character-function (eval-when (:compile-toplevel :load-toplevel :execute) ;;; Character syntaxes: (defconstant +cs-invalid+ 0) (defconstant +cs-whitespace+ 1) (defconstant +cs-single-escape+ 2) (defconstant +cs-multiple-escape+ 3) (defconstant +cs-constituent+ 4) (defconstant +cs-terminating-macro-character+ 5) (defconstant +cs-non-terminating-macro-character+ 6) ;;; Constituent traits: (defconstant +ct-invalid+ #b00000000000001) (defconstant +ct-alphabetic+ #b00000000000010) (defconstant +ct-digit+ #b00000000000100) (defconstant +ct-alphadigit+ #b00000000000110) (defconstant +ct-package-marker+ #b00000000001000) (defconstant +ct-plus-sign+ #b00000000010000) (defconstant +ct-minus-sign+ #b00000000100000) (defconstant +ct-sign+ #b00000000110000) (defconstant +ct-dot+ #b00000001000000) (defconstant +ct-decimal-point+ #b00000010000000) (defconstant +ct-ratio-marker+ #b00000100000000) (defconstant +ct-float-exponent-marker+ #b00001000000000) (defconstant +ct-short-float-exponent-marker+ #b00011000000000) (defconstant +ct-single-float-exponent-marker+ #b00101000000000) (defconstant +ct-double-float-exponent-marker+ #b01001000000000) (defconstant +ct-long-float-exponent-marker+ #b10001000000000) (defconstant +ct-max+ +ct-long-float-exponent-marker+) ) ;;eval-when (deftype constituent-trait () `(integer 0 ,(expt 2 (integer-length +ct-max+)))) (declaim (inline traitp)) (defun traitp (trait traits) "Returns whether the TRAIT is in the TRAITS 'set'." (plusp (logand trait traits))) ;;; The shared character descriptions: (defparameter *cd-invalid* (make-instance 'character-description :syntax +cs-invalid+ :traits +ct-invalid+)) (defparameter *cd-whitespace* (make-instance 'character-description :syntax +cs-whitespace+ :traits +ct-invalid+)) (defparameter *cd-constituent-invalid* (make-instance 'character-description :syntax +cs-whitespace+ :traits +ct-invalid+)) (defparameter *cd-constituent-alphabetic* (make-instance 'character-description :syntax +cs-constituent+ :traits +ct-alphabetic+)) ;; ---------------------------------------- (defclass syntax-table () (standard-characters extended-characters constituent invalid) (:documentation " STANDARD-CHARACTERS is a vector of CHARACTER-DESCRIPTION instances for the standard character codes below +STANDARD-CHARACTERS-LIMIT+. EXTENDED-CHARACTERS is NIL, or a HASH-TABLE mapping characters to CHARACTER-DESCRIPTIONS instances for the extended characters with codes above +STANDARD-CHARACTERS-LIMIT+. Extended characters without an entry in EXTENDED-CHARACTERS either have CONSTITUENT or INVALID CHARACTER-DESCRIPTION, depending on whether they're GRAPHIC-CHAR-P or not. ")) (defconstant +standard-characters-limit+ 128) (defmethod initialize-instance :after ((self syntax-table) &key &allow-other-keys) (let ((table (make-array +standard-characters-limit+ :initial-element *cd-invalid*))) (setf (aref table (char-code #\Backspace)) *cd-constituent-invalid* (aref table (char-code #\Rubout)) *cd-constituent-invalid* (aref table (char-code #\Tab)) *cd-whitespace* (aref table (char-code #\Newline)) *cd-whitespace* (aref table (char-code #\Linefeed)) *cd-whitespace* (aref table (char-code #\Page)) *cd-whitespace* (aref table (char-code #\Return)) *cd-whitespace* (aref table (char-code #\Space)) *cd-whitespace*) (loop :for chdesc :in '((#.+cs-terminating-macro-character+ "\"'(),;`" #.+ct-alphabetic+) (#.+cs-non-terminating-macro-character+ "#" #.+ct-alphabetic+) (#.+cs-single-escape+ "\\" #.+ct-alphabetic+) (#.+cs-multiple-escape+ "|" #.+ct-alphabetic+) (#.+cs-constituent+ "!$%&*<=>?@[]^_{}~" #.+ct-alphabetic+) (#.+cs-constituent+ ":" #.+ct-package-marker+) (#.+cs-constituent+ "+" #.+ct-alphabetic+ #.+ct-plus-sign+) (#.+cs-constituent+ "-" #.+ct-alphabetic+ #.+ct-minus-sign+) (#.+cs-constituent+ "." #.+ct-alphabetic+ #.+ct-dot+ #.+ct-decimal-point+) (#.+cs-constituent+ "/" #.+ct-alphabetic+ #.+ct-ratio-marker+) (#.+cs-constituent+ "0123456789" #.+ct-alphadigit+) (#.+cs-constituent+ "Dd" #.+ct-alphadigit+ #.+ct-double-float-exponent-marker+) (#.+cs-constituent+ "Ee" #.+ct-alphadigit+ #.+ct-float-exponent-marker+) (#.+cs-constituent+ "Ff" #.+ct-alphadigit+ #.+ct-single-float-exponent-marker+) (#.+cs-constituent+ "Ll" #.+ct-alphadigit+ #.+ct-long-float-exponent-marker+) (#.+cs-constituent+ "Ss" #.+ct-alphadigit+ #.+ct-short-float-exponent-marker+) (#.+cs-constituent+ "ABCGHIJKMNOPQRTUVWXYZabcghijkmnopqrtuvwxyz" #.+ct-alphadigit+)) :do (loop :with desc = (make-instance 'character-description :syntax (first chdesc) :traits (if (null (cdddr chdesc)) (third chdesc) (apply (function logior) (cddr chdesc)))) :for ch :across (second chdesc) :do (setf (aref table (char-code ch)) desc))) (setf (slot-value self 'standard-characters) table (slot-value self 'extended-characters) nil)) self) (defgeneric copy-syntax-table (syntax-table)) (defgeneric character-description (syntax-table character)) (defmethod copy-syntax-table ((self syntax-table)) (let ((copy (make-instance 'syntax-table))) (setf (slot-value copy 'standard-characters) (copy-seq (slot-value self 'standard-characters)) (slot-value copy 'extended-characters) (and (slot-value self 'extended-characters) (copy-hash-table (slot-value self 'extended-characters)))) copy)) (defmethod character-description ((self syntax-table) (ch character)) (let ((code (char-code ch))) (if (< code +standard-characters-limit+) (aref (slot-value self 'standard-characters) code) (or (and (slot-value self 'extended-characters) (gethash code (slot-value self 'extended-characters))) (if (graphic-char-p ch) *cd-constituent-alphabetic* *cd-invalid*))))) (defgeneric (setf character-description) (val syntax-table character)) (defmethod (setf character-description) (val (self syntax-table) (ch character)) (let ((code (char-code ch))) (if (< code +standard-characters-limit+) (setf (aref (slot-value self 'standard-characters) code) val) (progn (unless (slot-value self 'extended-characters) (setf (slot-value self 'extended-characters) (make-hash-table))) (setf (gethash code (slot-value self 'extended-characters)) val))))) ;;---------------------------------------- (defvar *standard-readtable* nil "Only used by SET-SYNTAX-FROM-CHAR") (defvar *readtable* nil " The value of *READTABLE* is called the current readtable. It controls the parsing behavior of the Lisp reader, and can also influence the Lisp printer (e.g., see the function READTABLE-CASE). URL: <http://www.lispworks.com/documentation/HyperSpec/Body/v_rdtabl.htm> ") (defvar *read-base* 10 " Controls the interpretation of tokens by READ as being integers or ratios. The value of *READ-BASE*, called the current input base, is the radix in which integers and ratios are to be read by the Lisp reader. The parsing of other numeric types (e.g., floats) is not affected by this option. The effect of *READ-BASE* on the reading of any particular rational number can be locally overridden by explicit use of the #O, #X, #B, or #nR syntax or by a trailing decimal point. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/v_rd_bas.htm> ") (defvar *read-eval* t " If it is true, the #. reader macro has its normal effect. Otherwise, that reader macro signals an error of type reader-error. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/v_rd_eva.htm> ") (defvar *read-suppress* nil " This variable is intended primarily to support the operation of the read-time conditional notations #+ and #-. If it is false, the Lisp reader operates normally. If the value of *read-suppress* is true, read, read-preserving-whitespace, read-delimited-list, and read-from-string all return a primary value of nil when they complete successfully. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/v_rd_sup.htm> ") (defvar *read-default-float-format* 'single-float " Controls the floating-point format that is to be used when reading a floating-point number that has no exponent marker or that has e or E for an exponent marker. Other exponent markers explicitly prescribe the floating-point format to be used. The printer uses *read-default-float-format* to guide the choice of exponent markers when printing floating-point numbers. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/v_rd_def.htm> ") ;; extensions (defvar *input-stream* nil " Bound to the input stream, during token parsing. Consequences are undefined, if any destructive operations are attempted on this stream. ") (declaim (ftype (function (t) t) parse-token)) (defgeneric readtable-parse-token (readtable) (:documentation "RETURN: The function used to parse a token that has been read.")) (defgeneric (setf readtable-parse-token) (new-function readtable) (:documentation "DO: Set the function used to parse a token that has been read.")) (defgeneric readtable-syntax-table (readtable) (:documentation "RETURN: The syntax-table of the readtable.")) (declaim (function make-token-parser)) (defclass readtable () ((case :initarg :case :initform :upcase :type (member :upcase :downcase :preserve :invert)) (syntax-table :accessor readtable-syntax-table :initarg :syntax-table :initform (make-instance 'syntax-table)) (parse-token :accessor readtable-parse-token :initarg :parse-token :initform (make-token-parser))) (:documentation " A READTABLE maps characters into syntax types for the Lisp reader; see Section 2 (Syntax). A readtable also contains associations between macro characters and their reader macro functions, and records information about the case conversion rules to be used by the Lisp reader when parsing symbols. Each simple character must be representable in the readtable. It is implementation-defined whether non-simple characters can have syntax descriptions in the readtable. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/t_rdtabl.htm> ")) (defun copy-readtable (&optional (from-readtable *readtable*) (to-readtable nil)) " DO: Copy the readtable. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_cp_rdt.htm> " (if (null from-readtable) (if (null to-readtable) (make-instance 'readtable) (progn (setf (readtable-case to-readtable) :upcase (readtable-syntax-table to-readtable) (make-instance 'syntax-table) (readtable-parse-token to-readtable) (function parse-token)) to-readtable)) (if (null to-readtable) (make-instance 'readtable :case (readtable-case from-readtable) :syntax-table (copy-syntax-table (readtable-syntax-table from-readtable)) :parse-token (readtable-parse-token from-readtable)) (progn (setf (readtable-case to-readtable) (readtable-case from-readtable) (readtable-syntax-table to-readtable) (copy-syntax-table (readtable-syntax-table from-readtable)) (readtable-parse-token to-readtable) (readtable-parse-token from-readtable)) to-readtable)))) (defun reader-dispatch-macro-error-undefined (stream ch sub-char) (serror 'simple-reader-error stream "After #\\~A is #\\~A an undefined dispatch macro character" ch sub-char)) (defun reader-dispatch-macro-error-invalid (stream sub-char arg) (declare (ignore sub-char arg)) (serror 'simple-reader-error stream "objects printed as # in view of *PRINT-LEVEL* cannot be read back in")) (defun reader-macro-dispatch-function (stream ch) (let* ((arg (loop :for ch = (read-char stream t nil t) :while (digit-char-p ch) :collect ch :into digits :finally (unread-char ch stream) (return (when digits (parse-integer (coerce digits 'string)))))) (sub-char (read-char stream t nil t)) (cd (character-description (readtable-syntax-table *readtable*) ch)) (fun (gethash (char-upcase sub-char) (character-dispatch cd)))) (if fun (funcall fun stream arg sub-char) (reader-dispatch-macro-error-undefined stream ch sub-char)))) (defgeneric process-case-function (mode) (:method ((mode (eql :preserve))) (declare (ignorable mode)) (function identity)) (:method ((mode (eql :downcase))) (declare (ignorable mode)) (function char-downcase)) (:method ((mode (eql :upcase))) (declare (ignorable mode)) (function char-upcase)) (:method ((mode (eql :invert))) (declare (ignorable mode)) (lambda (ch) (cond ((upper-case-p ch) (char-downcase ch)) ((lower-case-p ch) (char-upcase ch)) (t ch))))) ;;; For tokens we need to keep track of the characters and their ;;; traits in parallel: (declaim (inline make-token token-text token-traits token-length token-char token-char-traits token-collect-character)) (defstruct token (characters (make-array 8 :adjustable t :fill-pointer 0 :element-type 'character)) (constituent-traits (make-array 8 :adjustable t :fill-pointer 0 :element-type 'constituent-trait)) ;; We also need to keep track of the use of || in case of empty escaped substring: (has-multiple-escape-p nil)) (defun token-text (token) (token-characters token)) (defun token-traits (token) (token-constituent-traits token)) (defun token-length (token) (length (token-characters token))) (defun token-char (token index) (aref (token-characters token) index)) (defun token-char-traits (token index) (aref (token-constituent-traits token) index)) (defun token-collect-character (token character traits) (vector-push-extend character (token-characters token)) (vector-push-extend traits (token-constituent-traits token))) (defun token-collect-multiple-escape (token) (setf (token-has-multiple-escape-p token) t)) (defun token-delimiter-p (character) (let ((cs (character-syntax (character-description (readtable-syntax-table *readtable*) character)))) (or (= cs +cs-whitespace+) (= cs +cs-terminating-macro-character+)))) (defvar *references* nil "Used to implement #= and ##.") (defun read-token (input-stream eof-error-p eof-value recursive-p preserve-whitespace-p first-char readtable) " DO: Implements parts of READ and READ-PRESERVING-WHITESPACE. INPUT-STREAM: The stream that is read. EOF-ERROR-P: Whether we should signal an END-OF-FILE error upon EOF. EOF-VALUE: Unless EOF-ERROR-P, the value to be returned in case of EOF. RECURSIVE-P: Whether the read is recursive. The *reference* table is reset only when RECURSIVE-P is false. PRESERVE-WHITESPACE-P: Whether a terminating whitespace will be unread or not. FIRST-CHAR: NIL or a CHARACTER that is used first, before reading the stream. This should be faster than UNREAD-CHAR it, and foremost, it allows for two unread character, this FIRST-CHAR plus an actual UNREAD-CHAR one. READTABLE: The readtable to use. RETURN: tokenp == t ; a token. Or tokenp == :EOF ; the eof-value. Or tokenp == NIL ; a list of values read. BUG: The handling of readtable-case :invert is wrong. " (macrolet ((unless-eof (place &body body) `(cond (,place ,@body) (eof-error-p (serror 'simple-end-of-file input-stream "input stream ~S has reached its end" input-stream)) (t (return-from read-token (values :eof eof-value))))) (error-invalid-character (ch) `(serror 'simple-reader-error input-stream "invalid character #\\~A" ,ch))) (let ((*references* (if recursive-p *references* (make-hash-table)))) (prog (x y (token (make-token)) (syntax-table (readtable-syntax-table readtable)) (procase (process-case-function (readtable-case readtable)))) :begin (setf x (or first-char (read-char input-stream nil nil t)) first-char nil) (unless-eof x (let ((cd (character-description syntax-table x))) (ecase (character-syntax cd) ((#.+cs-invalid+) (error-invalid-character x)) ((#.+cs-whitespace+) (go :begin)) ((#.+cs-single-escape+) (let ((z (read-char input-stream nil nil t))) (unless-eof z (token-collect-character token z +ct-alphabetic+))) (go :collect-token)) ((#.+cs-multiple-escape+) (go :collect-multiple-escape-token)) ((#.+cs-constituent+) (token-collect-character token (funcall procase x) (character-constituent-traits cd)) (go :collect-token)) ((#.+cs-terminating-macro-character+ #.+cs-non-terminating-macro-character+) ;; If the macro returns no value, the caller will ;; have to call us again, or not: (#-(and)x) (return-from read-token (values nil (multiple-value-list (funcall (get-macro-character x readtable) input-stream x)))))))) :collect-token (setf y (read-char input-stream nil nil t)) (if y (let ((cd (character-description syntax-table y))) (ecase (character-syntax cd) ((#.+cs-invalid+) (error-invalid-character y)) ((#.+cs-whitespace+) (when preserve-whitespace-p (unread-char y input-stream)) (go :parse-token)) ((#.+cs-single-escape+) (let ((z (read-char input-stream nil nil t))) (unless-eof z (token-collect-character token z +ct-alphabetic+))) (go :collect-token)) ((#.+cs-multiple-escape+) (go :collect-multiple-escape-token)) ((#.+cs-constituent+ #.+cs-non-terminating-macro-character+) (token-collect-character token (funcall procase y) (character-constituent-traits cd)) (go :collect-token)) ((#.+cs-terminating-macro-character+) (unread-char y input-stream) (go :parse-token)))) (go :parse-token)) :collect-multiple-escape-token (token-collect-multiple-escape token) (setf y (read-char input-stream nil nil t)) (unless-eof y (let ((cd (character-description syntax-table y))) (ecase (character-syntax cd) ((#.+cs-invalid+) (error-invalid-character y)) ((#.+cs-single-escape+) (let ((z (read-char input-stream nil nil t))) (unless-eof z (token-collect-character token z +ct-alphabetic+))) (go :collect-multiple-escape-token)) ((#.+cs-multiple-escape+) (go :collect-token)) ((#.+cs-whitespace+ #.+cs-constituent+ #.+cs-non-terminating-macro-character+ #.+cs-terminating-macro-character+) (token-collect-character token y +ct-alphabetic+) (go :collect-multiple-escape-token))))) :parse-token ;; token can be of zero length... (return (values t token)))))) ;; numeric-token ::= integer | ratio | float ;; integer ::= [sign] decimal-digit+ decimal-point ;; integer ::= [sign] digit+ ;; ratio ::= [sign] {digit}+ slash {digit}+ ;; float ::= [sign] {decimal-digit}* decimal-point {decimal-digit}+ exponent ;; float ::= [sign] {decimal-digit}* decimal-point {decimal-digit}+ ;; float ::= [sign] {decimal-digit}+ exponent ;; float ::= [sign] {decimal-digit}+ decimal-point {decimal-digit}* exponent ;; exponent ::= exponent-marker [sign] {digit}+ ;; ;; consing-dot ::= dot ;; ;; symbol ::= symbol-name ;; | package-marker symbol-name ;; | package-marker package-marker symbol-name ;; | package-name package-marker symbol-name ;; | package-name package-marker package-marker symbol-name ;; ;; symbol-name ::= {alphabetic}+ ;; package-name ::= {alphabetic}+ (defmacro defparser (name arguments &body body) "Defines a token parser function, which parses its argument token and returns three values: a ok flag; a type of value; and a value parsed from the token. When the ok flag is false, the type indicates whether it's a strong error, and the value returned is an error message. A strong error is a lexical error that is not ambiguous. A weak error is when the token could still be of another lexical category. In the body of the parser, there are macrolet defined to REJECT or ACCEPT the token, and to describe the parsed syntax with ALT, ZERO-OR-MORE, ONE-OR-MORE and OPT-SIGN." (multiple-value-bind (docu decl body) (parse-body :lambda body) `(defun ,name ,arguments ,@docu ,@decl (macrolet ((reject (strongp &rest ctrlstring-and-args) `(return-from ,',name (values nil ,strongp ,(when ctrlstring-and-args `(format nil ,@ctrlstring-and-args))))) (accept (type token) `(return-from ,',name (values t ,type ,token))) (alt (&rest clauses) `(cond ,@clauses)) (zero-or-more (test &body body) `(loop :while ,test :do ,@body)) (one-or-more (test &body body) `(progn (if ,test (progn ,@body) (reject nil)) (loop :while ,test :do ,@body))) (opt-sign (sign token i) `(alt ((>= ,i (token-length ,token))) ((traitp +ct-plus-sign+ (token-char-traits ,token ,i)) (setf ,sign +1 ,i (1+ ,i))) ((traitp +ct-minus-sign+ (token-char-traits ,token ,i)) (setf ,sign -1 ,i (1+ ,i)))))) ,@body)))) (defparser parse-decimal-integer-token (token) "integer ::= [sign] decimal-digit+ decimal-point" (let ((sign 1) (mant 0) (i 0)) (when (token-has-multiple-escape-p token) (reject nil)) (unless (< i (token-length token)) (reject nil)) (unless (traitp +ct-decimal-point+ (token-char-traits token (1- (token-length token)))) (reject nil)) (opt-sign sign token i) (one-or-more (and (< i (token-length token)) (traitp +ct-digit+ (token-char-traits token i)) (digit-char-p (token-char token i))) (setf mant (+ (* 10. mant) (digit-char-p (token-char token i))) i (1+ i))) (if (and (= (1+ i) (token-length token)) (traitp +ct-decimal-point+ (token-char-traits token i))) (accept 'integer (* sign mant)) (reject t (if (= (1+ i) (token-length token)) "Missing decimal point in decimal integer ~S" "Junk after decimal point in decimal integer ~S") (token-text token))))) (defparser parse-integer-token (token) "integer ::= [sign] digit+" (let ((sign 1) (mant 0) (i 0)) (when (token-has-multiple-escape-p token) (reject nil)) (unless (< i (token-length token)) (reject nil)) (opt-sign sign token i) (one-or-more (and (< i (token-length token)) (traitp +ct-digit+ (token-char-traits token i)) (digit-char-p (token-char token i) *read-base*)) (setf mant (+ (* *read-base* mant) (digit-char-p (token-char token i) *read-base*)) i (1+ i))) (if (= i (token-length token)) (accept 'integer (* sign mant)) (reject t "Junk after integer ~S" (token-text token))))) (defun %parse-integer (string &key (start 0) (end nil) (radix 10.) (junk-allowed nil) &aux (end (or end (length string)))) (loop :named parse :with sign = (case (aref string start) (#\+ (incf start) +1) (#\- (incf start) -1) (otherwise +1)) :with mant = 0 :for i :from start :below end :do (let ((digit (digit-char-p (aref string i) radix))) (cond (digit (setf mant (+ (* mant radix) digit))) (junk-allowed (return-from parse (values (* sign mant) i))) (t (error 'parse-error))) ()) :finally (return-from parse (values (* sign mant) i)))) (defparser parse-ratio-token (token) "ratio ::= [sign] {digit}+ slash {digit}+" (let ((sign 1) (nume 0) (denu 0) (i 0)) (when (token-has-multiple-escape-p token) (reject nil)) (unless (< i (token-length token)) (reject nil)) (opt-sign sign token i) (one-or-more (and (< i (token-length token)) (traitp +ct-digit+ (token-char-traits token i)) (digit-char-p (token-char token i) *read-base*)) (setf nume (+ (* *read-base* nume) (digit-char-p (token-char token i) *read-base*)) i (1+ i))) (if (traitp +ct-ratio-marker+ (token-char-traits token i)) (incf i) (reject nil)) (one-or-more (and (< i (token-length token)) (traitp +ct-digit+ (token-char-traits token i)) (digit-char-p (token-char token i) *read-base*)) (setf denu (+ (* *read-base* denu) (digit-char-p (token-char token i) *read-base*)) i (1+ i))) (cond ((< i (token-length token)) (reject t "Junk after ratio ~S" (token-text token))) #|| ((zerop denu) (reject t "Zero denominator ratio ~S" (token-text token))) ||# (t (accept 'ratio (/ (* sign nume) denu)))))) (defparser parse-float-1-token (token) "float ::= [sign] {decimal-digit}* decimal-point {decimal-digit}+ [exponent] exponent ::= exponent-marker [sign] {digit}+" (let ((sign 1) (nume 0) (denu 1) (type *read-default-float-format*) (esgn 1) (expo 0) (i 0)) (when (token-has-multiple-escape-p token) (reject nil)) (opt-sign sign token i) (zero-or-more (and (< i (token-length token)) (traitp +ct-digit+ (token-char-traits token i)) (digit-char-p (token-char token i))) (setf nume (+ (* 10. nume) (digit-char-p (token-char token i))) i (1+ i))) (if (and (< i (token-length token)) (traitp +ct-decimal-point+ (token-char-traits token i))) (incf i) (reject nil)) (one-or-more (and (< i (token-length token)) (traitp +ct-digit+ (token-char-traits token i)) (digit-char-p (token-char token i))) (setf nume (+ (* 10. nume) (digit-char-p (token-char token i))) denu (* 10. denu) i (1+ i))) (when (and (< i (token-length token)) (traitp +ct-float-exponent-marker+ (token-char-traits token i))) (cond ((traitp +ct-short-float-exponent-marker+ (token-char-traits token i)) (setf type 'short-float)) ((traitp +ct-single-float-exponent-marker+ (token-char-traits token i)) (setf type 'single-float)) ((traitp +ct-double-float-exponent-marker+ (token-char-traits token i)) (setf type 'double-float)) ((traitp +ct-long-float-exponent-marker+ (token-char-traits token i)) (setf type 'long-float))) (incf i) (opt-sign esgn token i) (one-or-more (and (< i (token-length token)) (traitp +ct-digit+ (token-char-traits token i)) (digit-char-p (token-char token i))) (setf expo (+ (* 10. expo) (digit-char-p (token-char token i))) i (1+ i)))) (if (= i (token-length token)) (accept type (* (coerce (/ (* sign nume) denu) type) (expt (coerce 10. type) (* esgn expo)))) (reject t "Junk after floating point number ~S" (token-text token))))) (defparser parse-float-2-token (token) "float ::= [sign] {decimal-digit}+ [decimal-point {decimal-digit}*] exponent exponent ::= exponent-marker [sign] {digit}+" (let ((sign 1) (nume 0) (denu 1) (type *read-default-float-format*) (esgn 1) (expo 0) (i 0)) (when (token-has-multiple-escape-p token) (reject nil)) (opt-sign sign token i) (one-or-more (and (< i (token-length token)) (traitp +ct-digit+ (token-char-traits token i)) (digit-char-p (token-char token i))) (setf nume (+ (* 10. nume) (digit-char-p (token-char token i))) i (1+ i))) (when (and (< i (token-length token)) (traitp +ct-decimal-point+ (token-char-traits token i))) (incf i) (one-or-more (and (< i (token-length token)) (traitp +ct-digit+ (token-char-traits token i)) (digit-char-p (token-char token i))) (setf nume (+ (* 10. nume) (digit-char-p (token-char token i))) denu (* 10. denu) i (1+ i)))) (unless (and (< i (token-length token)) (traitp +ct-float-exponent-marker+ (token-char-traits token i))) (reject nil)) (cond ((traitp +ct-short-float-exponent-marker+ (token-char-traits token i)) (setf type 'short-float)) ((traitp +ct-single-float-exponent-marker+ (token-char-traits token i)) (setf type 'single-float)) ((traitp +ct-double-float-exponent-marker+ (token-char-traits token i)) (setf type 'double-float)) ((traitp +ct-long-float-exponent-marker+ (token-char-traits token i)) (setf type 'long-float))) (incf i) (opt-sign esgn token i) (one-or-more (and (< i (token-length token)) (traitp +ct-digit+ (token-char-traits token i)) (digit-char-p (token-char token i))) (setf expo (+ (* 10. expo) (digit-char-p (token-char token i))) i (1+ i))) (if (= i (token-length token)) (accept type (* (coerce (/ (* sign nume) denu) type) (expt (coerce 10. type) (* esgn expo)))) (reject t "Junk after floating point number ~S" (token-text token))))) ;; (defparser parse-consing-dot-token (token) ;; "consing-dot ::= dot" ;; (if (and (= 1 (token-length token)) ;; (traitp +ct-dot+ (token-char-traits token 0))) ;; (accept 'consing-dot ".") ;; (reject nil))) (defun invalid-symbol-component-list (components) " COMPONENTS: Parsed symbol components. DO: Handles invalid components lists. " (error "Invalid symbol component list ~S" components)) (defun internal-symbol (package sname sym) " We tried to read PNAME:SNAME but the symbol is not exported. PACKAGE: the package specified for the symbol. SNAME: symbol name. DO: Handles the internal symbol error with restarts to export it or return it unexported. NOTE: We could also find symbols with the same name in other packages. " (restart-case (error 'unexported-symbol-error :stream *input-stream* :package-name (package-name package) :symbol-name sname) (export (&rest rest) :report "Export the unexported symbol." (declare (ignore rest)) (export sym package) sym) (return-unexported (&rest rest) :report "Return the symbol unexported." (declare (ignore rest)) sym))) (defun missing-symbol (package sname) " We tried to read PNAME:SNAME but no symbol found with this name. PACKAGE: the package specified for the symbol. SNAME: symbol name. DO: Handles the symbol missing error with restarts to intern in the package (and possibly export it) or return an uninterned symbol. NOTE: We could also find symbols with the same name in other packages. " (restart-case (error 'symbol-missing-in-package-error :stream *input-stream* :package-name (package-name package) :symbol-name sname) (intern-and-export (&rest rest) :report "Intern the missing symbol and export it" (declare (ignore rest)) (let ((sym (intern sname package))) (export (list sym) package) sym)) (intern (&rest rest) :report "Intern the missing symbol without exporting it" (declare (ignore rest)) (intern sname package)) (return-uninterned (&rest rest) :report "Return an uninterned symbol." (declare (ignore rest)) (make-symbol sname)))) (defun missing-package (pname sname) " We tried to read PNAME:SNAME, but there's no package named PNAME. PNAME: package name SNAME: symbol name DO: Handles the missing package error with restarts to intern in the current package or return an uninterned symbol. NOTE: We could also find other packages with a similar name to correct typoes. " (restart-case (error 'symbol-in-missing-package-error :stream *input-stream* :package-name pname :symbol-name sname) #|TODO: add a restart to create the missing package.|# (intern-here (&rest rest) :report "Intern the symbol in the current package instead." (declare (ignore rest)) (intern sname)) (return-uninterned (&rest rest) :report "Return an uninterned symbol." (declare (ignore rest)) (make-symbol sname)))) (defun symbol-from-split-token (components) " COMPONENTS: a list of strings separated by integers specifying the number of colons. EXAMPLES: X (\"X\") :Y (1 \"Y\") X:Y (\"X\" 1 \"Y\") X::Y (\"X\" 2 \"Y\") X:::Y (\"X\" 3 \"Y\") X:: (\"X\" 2) X:Y:Z (\"X\" 1 \"Y\" 1 \"Z\") RETURN: A symbol designated by the components, or signal an error. NOTE: This function implements the standard semantics, where only one occurence of : or :: is allowed, and depending on : or ::, an exported symbol is expected or not. " (values (case (length components) (1 (if (stringp (first components)) (intern (first components) *package*) (invalid-symbol-component-list components))) (2 (case (first components) ((1 2) (intern (second components) (load-time-value (find-package "KEYWORD")))) (otherwise (invalid-symbol-component-list components)))) (3 (destructuring-bind (pname colons sname) components (assert (stringp pname) (pname) "Symbol component was expected to be a string.") (assert (stringp sname) (sname) "Symbol component was expected to be a string.") (let ((package (find-package pname))) ; *** this is the critical call for relative packages. (if package (case colons (1 (multiple-value-bind (sym where) (find-symbol sname package) (case where ((nil) (missing-symbol package sname)) ((:internal) (internal-symbol package sname sym)) ((:external) sym)))) (2 (intern sname package)) (otherwise (invalid-symbol-component-list components))) (missing-package pname sname))))) (otherwise (invalid-symbol-component-list components))))) (defun make-symbol-parser-function (symbol-internalize-function) (lambda (token) (flet ((package-marker-p (traits) (traitp +ct-package-marker+ traits))) (handler-case (let ((symbol (funcall symbol-internalize-function (loop :with components := '() :for start := 0 :then after-colons :for colon := (position-if (function package-marker-p) (token-traits token) :start start) :for after-colons := (when colon (position-if-not (function package-marker-p) (token-traits token) :start (1+ colon))) :while colon :do (when (plusp colon) (push (subseq (token-text token) start colon) components)) (push (- after-colons colon) components) :finally (push (subseq (token-text token) start colon) components) (return (nreverse components)))))) (values t 'symbol symbol)) (error (err) (values nil t (princ-to-string err))))))) (defun make-token-parser (&key (parse-decimal-integer-token (function parse-decimal-integer-token)) (parse-integer-token (function parse-integer-token)) (parse-ratio-token (function parse-ratio-token)) (parse-float-1-token (function parse-float-1-token)) (parse-float-2-token (function parse-float-2-token)) (parse-symbol-token (make-symbol-parser-function (function symbol-from-split-token)))) (lambda (token) "RETURN: okp ; the parsed lisp object if okp, or an error message if (not okp)" (let ((message nil)) (macrolet ((rom (&body body) "Result Or Message" (if (null body) 'nil (let ((vals (gensym))) `(let ((,vals (multiple-value-list ,(car body)))) ;; (format *trace-output* "~S --> ~S~%" ',(car body) ,vals) (if (first ,vals) (values-list ,vals) (progn (when (second ,vals) (setf message (third ,vals))) (rom ,@(cdr body))))))))) (multiple-value-bind (ok type object) (rom (funcall parse-decimal-integer-token token) (funcall parse-integer-token token) (funcall parse-ratio-token token) (funcall parse-float-1-token token) (funcall parse-float-2-token token) ;; (parse-consing-dot-token token) (funcall parse-symbol-token token)) (declare (ignorable type)) ;; (format *trace-output* "ok = ~S ; type = ~S ; object = ~S~%" ;; ok type object) (values ok (if ok object message))))))) (defun all-dots-p (token) " RETURN: Whether the token is all dots, (excluding escaped dots). " (and (not (token-has-multiple-escape-p token)) (plusp (length (token-text token))) (every (lambda (traits) (traitp +ct-dot+ traits)) (token-traits token)))) (defun read-0/1 (input-stream eof-error-p eof-value recursive-p preserve-whitespace-p first-char allowed-all-dots) " DO: Read zero or one token. Use the *READTABLE*. INPUT-STREAM: The stream that is read. EOF-ERROR-P: Whether we should signal an END-OF-FILE error upon EOF. EOF-VALUE: Unless EOF-ERROR-P, the value to be returned in case of EOF. RECURSIVE-P: Whether the read is recursive. The *reference* table is reset only when RECURSIVE-P is false. PRESERVE-WHITESPACE-P: Whether a terminating whitespace will be unread or not. FIRST-CHAR: NIL or a CHARACTER that is used first, before reading the stream. This should be faster than UNREAD-CHAR it, and foremost, it allows for two unread character, this FIRST-CHAR plus an actual UNREAD-CHAR one. ALLOWED-ALL-DOTS: May be T in which case tokens containing only dots are allowed, or a (possibly empty) list of strings containing only dots that are explicitely allowed (others rejected). Typically (\".\"). RETURN: tokenp == t ; an unparsed (alldots) token. Or tokenp == :EOF ; the eof-value. Or tokenp == NIL ; a list of values read. " (multiple-value-bind (tokenp token) (read-token input-stream eof-error-p eof-value recursive-p preserve-whitespace-p first-char *readtable*) (if (eq 't tokenp) (cond (*read-suppress* (values nil (list nil))) ((or (eq 't allowed-all-dots) (not (all-dots-p token))) ; We got a token, let's parse it. (values nil (list (multiple-value-bind (okp object) (let ((*input-stream* input-stream)) (funcall (readtable-parse-token *readtable*) token)) (if okp object (serror 'simple-reader-error input-stream "~A" object)))))) ((member (token-text token) allowed-all-dots :test (function string=)) (values t token)) (t (serror 'simple-reader-error input-stream "a token consisting only of dots cannot be ~ meaningfully read in"))) (values tokenp token)))) (defun read-1 (input-stream eof-error-p eof-value recursive-p preserve-whitespace-p first-char allowed-all-dots) " DO: Read exactly one token. Use the *READTABLE*. INPUT-STREAM: The stream that is read. EOF-ERROR-P: Whether we should signal an END-OF-FILE error upon EOF. EOF-VALUE: Unless EOF-ERROR-P, the value to be returned in case of EOF. RECURSIVE-P: Whether the read is recursive. The *reference* table is reset only when RECURSIVE-P is false. PRESERVE-WHITESPACE-P: Whether a terminating whitespace will be unread or not. FIRST-CHAR: NIL or a CHARACTER that is used first, before reading the stream. This should be faster than UNREAD-CHAR it, and foremost, it allows for two unread character, this FIRST-CHAR plus an actual UNREAD-CHAR one. ALLOWED-ALL-DOTS: May be T in which case tokens containing only dots are allowed, or a (possibly empty) list of strings containing only dots that are explicitely allowed (others rejected). Typically (\".\"). RETURN: The token read, or when EOF-ERROR-P is false and EOF occurs, EOF-VALUE. " (loop :for (tokenp token) = (multiple-value-list (read-0/1 input-stream eof-error-p eof-value recursive-p preserve-whitespace-p first-char allowed-all-dots)) :until (or (eq :eof tokenp) token) :finally (return (if (eq :eof tokenp) token (first token))))) (defun read (&optional input-stream (eof-error-p t) (eof-value nil) (recursive-p nil)) " RETURN: An object read. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_rd_rd.htm> " (read-1 input-stream eof-error-p eof-value recursive-p nil nil '())) (defun read-preserving-whitespace (&optional input-stream (eof-error-p t) (eof-value nil) (recursive-p nil)) " RETURN: An object read. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_rd_rd.htm> " (read-1 input-stream eof-error-p eof-value recursive-p t nil '())) (defun read-delimited-list (char &optional (input-stream *standard-input*) (recursive-p nil)) " RETURN: A list of objects read. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_rd_del.htm> " (loop :with result = '() :for peek = (peek-char t input-stream nil input-stream recursive-p) :do (cond ((eql peek input-stream) (serror 'simple-end-of-file input-stream "input stream ~S has reached its end" input-stream)) ((char= peek char) (read-char input-stream nil nil recursive-p) (return-from read-delimited-list (nreverse result))) (t (multiple-value-bind (kind tokens) (read-0/1 input-stream t nil recursive-p nil nil '()) (declare (ignore kind)) (when tokens (push (first tokens) result))))))) (defun read-from-string (string &optional (eof-error-p t) (eof-value nil) &key (start 0) (end nil) (preserve-whitespace nil)) " RETURN: An object read from the string. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_rd_fro.htm> " (let ((index 0)) (values (with-input-from-string (input string :index index :start start :end end) (funcall (if preserve-whitespace (function read-preserving-whitespace) (function read)) input eof-error-p eof-value)) index))) (defun readtable-case (readtable) " RETURN: The case of the readtable. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_rdtabl.htm> " (slot-value readtable 'case)) (defun (setf readtable-case) (value readtable) " DO: Set the case of the readtable. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_rdtabl.htm> " (check-type value (member :upcase :downcase :preserve :invert)) (setf (slot-value readtable 'case) value)) (defun readtablep (object) " RETURN: Whether the object is a readtable. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_rdta_1.htm> " (typep object 'readtable)) (defun make-dispatch-macro-character (char &optional (non-terminating-p nil) (readtable *readtable*)) " DO: Make the character a dispatch macro character in the readtable. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_mk_dis.htm> " (let ((rst (readtable-syntax-table readtable))) (setf (character-description rst char) (make-instance 'character-description :syntax (if non-terminating-p +cs-non-terminating-macro-character+ +cs-terminating-macro-character+) :traits (character-constituent-traits (character-description rst char)) :macro (function reader-macro-dispatch-function) :dispatch (make-hash-table))))) (defun get-dispatch-macro-character (disp-char sub-char &optional (readtable *readtable*)) " RETURN: The dispatch macro character function. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_set__1.htm> " (let* ((rst (readtable-syntax-table readtable)) (cd (character-description rst disp-char))) (unless (character-dispatch cd) (error "~S is not a dispatch macro character" disp-char)) (and (character-dispatch cd) (gethash (char-upcase sub-char) (character-dispatch cd))))) (defun set-dispatch-macro-character (disp-char sub-char new-function &optional (readtable *readtable*)) " DO: Set the dispatch macro character function. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_set__1.htm> " (let* ((rst (readtable-syntax-table readtable)) (cd (character-description rst disp-char))) (unless (character-dispatch cd) (error "~S is not a dispatch macro character" disp-char)) (setf (gethash (char-upcase sub-char) (character-dispatch cd)) new-function)) t) (defun get-macro-character (char &optional (readtable *readtable*)) " RETURN: The macro character function. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_set_ma.htm> " (let* ((rst (readtable-syntax-table readtable)) (cd (character-description rst char))) (values (character-macro cd) (= (character-syntax cd) +cs-non-terminating-macro-character+)))) (defun set-macro-character (char new-function &optional (non-terminating-p nil) (readtable *readtable*)) " DO: Set then macro character function. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_set_ma.htm> " (let* ((rst (readtable-syntax-table readtable))) (setf (character-description rst char) (make-instance 'character-description :syntax (if non-terminating-p +cs-non-terminating-macro-character+ +cs-terminating-macro-character+) :traits (character-constituent-traits (character-description rst char)) :macro new-function))) t) (defun set-indirect-dispatch-macro-character (disp-char sub-char function-name &optional (readtable *readtable*)) "Like set-dispatch-macro-character, but with an indirect function, to enable TRACE and redefinitions of the dispatch macro character function." (set-dispatch-macro-character disp-char sub-char #+mocl (lambda (s c a) (funcall function-name s c a)) #-mocl (compile nil (let ((s (gensym)) (c (gensym)) (a (gensym))) `(lambda (,s ,c ,a) (,function-name ,s ,c ,a)))) readtable)) (defun set-indirect-macro-character (char function-name &optional (readtable *readtable*)) "Like set-macro-character, but with an indirect function, to enable TRACE and redefinitions of the macro character function." (set-macro-character char #+mocl (lambda (s c) (funcall function-name s c)) #-mocl (compile nil (let ((s (gensym)) (a (gensym))) `(lambda (,s ,a) (,function-name ,s ,a)))) readtable)) ;; Copied from com.informatimago.common-lisp.cesarum.utility to avoid package use loop. (defun copy-hash-table (table) " TABLE: (OR NULL HASH-TABLE) RETURN: If TABLE is NIL, then NIL, else a new HASH-TABLE with the same TEST, SIZE, REHASH-THRESHOLD REHASH-SIZE and KEY->VALUE associations than TABLE. (Neither the keys nor the values are copied). " (check-type table (or null hash-table)) (when table (let ((copy (make-hash-table :test (hash-table-test table) :size (hash-table-size table) :rehash-threshold (hash-table-rehash-threshold table) :rehash-size (hash-table-rehash-size table)))) (maphash (lambda (k v) (setf (gethash k copy) v)) table) copy))) (defun set-syntax-from-char (to-char from-char &optional (to-readtable *readtable*) (from-readtable *standard-readtable*)) " DO: Copy the syntax between characters in the readtable. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_set_sy.htm> " (let* ((frst (readtable-syntax-table from-readtable)) (trst (readtable-syntax-table to-readtable)) (fcd (character-description frst from-char)) (tcd (character-description trst to-char))) (setf (character-description trst to-char) (make-instance 'character-description :syntax (character-syntax fcd) ;; constituent traits are not copied. :traits (character-constituent-traits tcd) ;; macros are copied only if from is a macro character. :macro (or (character-macro fcd) (character-macro tcd)) :dispatch (if (character-dispatch fcd) (copy-hash-table (character-dispatch fcd)) (character-dispatch tcd))))) t) ;;;---------------------------------------- ;;; STANDARD READER MACRO FUNCTIONS ;;;---------------------------------------- (defun reader-macro-line-comment (stream ch) "Standard ; macro reader." (declare (ignore ch)) (read-line stream nil) (values)) (defun reader-macro-string (stream delim) "Standard \" macro reader." (flet ((error-eof () (serror 'simple-end-of-file stream "input stream ~S ends within a string" stream))) (loop :with rst = (readtable-syntax-table *readtable*) :with string = (make-array 64 :element-type 'character :adjustable t :fill-pointer 0) :for ch = (read-char stream nil nil t) :do (cond ((null ch) (error-eof)) ((eql ch delim) (return-from reader-macro-string (copy-seq string))) ((= (character-syntax (character-description rst ch)) +cs-single-escape+) (let ((next (read-char stream nil nil))) (when (null next) (error-eof)) (vector-push-extend next string))) (t (vector-push-extend ch string)))))) (defun reader-macro-quote (stream ch) "Standard ' macro reader." (declare (ignore ch)) `(quote ,(read stream t nil t))) (defun reader-macro-backquote (stream ch) "Standard ` macro reader." (declare (ignore ch)) `(backquote ,(read stream t nil t))) (defun reader-macro-comma (stream ch) "Standard , macro reader." (declare (ignore ch)) `(,(if (char= #\@ (peek-char nil stream t nil t)) 'splice 'unquote) ,(read stream t nil t))) (defun reader-macro-left-parenthesis (stream ch) "Standard ( macro reader." (declare (ignore ch)) (loop :with result = (cons nil nil) :with last-cons = result :with last-cdr-p = nil :for ch = (progn (peek-char t stream nil t) (read-char stream t nil t)) ;; :do (print `(:result ,result :last-cons ,last-cons ;; :last-cdr-p ,last-cdr-p :ch ,ch)) :do (flet ((read-and-nconc (ch) (let ((objects (nth-value 1 (read-0/1 stream t nil t nil ch '())))) (when objects (case last-cdr-p ((nil) (setf (cdr last-cons) objects ;; (list (first objects)) last-cons (cdr last-cons))) ((t) (setf (cdr last-cons) (first objects) last-cdr-p :done)) (otherwise (serror 'simple-reader-error stream "illegal end of dotted list"))))))) (cond ((char= #\) ch) #-mocl (loop-finish) #+mocl (if (eq last-cdr-p 't) (serror 'simple-reader-error stream "illegal end of dotted list") (return (cdr result)))) ((char= #\. ch) (if (token-delimiter-p (peek-char nil stream t nil t)) (if (eq result last-cons) (serror 'simple-reader-error stream "missing an object before the \".\" in a cons cell") (case last-cdr-p ((nil) (setf last-cdr-p t)) ((t) (serror 'simple-reader-error stream "token \".\" not allowed here")) (otherwise (serror 'simple-reader-error stream "illegal end of dotted list")))) (read-and-nconc ch))) (t (read-and-nconc ch)) )) :finally (if (eq last-cdr-p 't) (serror 'simple-reader-error stream "illegal end of dotted list") (return (cdr result))))) (defun reader-macro-error-start (stream ch) (serror 'simple-reader-error stream "an object cannot start with ~C" ch)) ;;;---------------------------------------- ;;; STANDARD READER DISPATCH MACRO FUNCTIONS ;;;---------------------------------------- (defun reader-dispatch-macro-label-reference (stream arg sub-char) "Standard ## dispatch macro reader." (declare (ignore sub-char)) (unless *read-suppress* (when (null arg) (serror 'simple-reader-error stream "a number must be given between # and #")) (multiple-value-bind (object presentp) (gethash arg *references*) (if presentp object (serror 'simple-reader-error stream "undefined label #~D#" arg))))) (defun reader-dispatch-macro-label-definition (stream arg sub-char) "Standard #= dispatch macro reader." (declare (ignore sub-char)) (unless *read-suppress* (when (null arg) (serror 'simple-reader-error stream "a number must be given between # and =")) (multiple-value-bind (object presentp) (gethash arg *references*) (if presentp (serror 'simple-reader-error stream "label #~D=~S already defined as ~S" (read stream t nil t) arg object) (setf (gethash arg *references*) (read stream t nil t)))))) (defun eval-feature (expression stream) "Evaluates a feature expression as a BOOLEAN." (flet ((illegal-feature () (serror 'simple-reader-error stream "illegal feature ~S" expression)) (eval-term (term) (eval-feature term stream))) (cond ;; Some implementations accept any atom: ((atom expression) (not (null (member expression *features*)))) (t (case (first expression) ((:not) (if (cddr expression) (illegal-feature) (not (eval-feature (second expression) stream)))) ((:and) (every (function eval-term) (rest expression))) ((:or) (some (function eval-term) (rest expression))) (t (illegal-feature))))))) (defun read-feature (stream affirmativep) "Reads a feature expression, and possibly eats one following sexp" (let ((expression (let ((*package* (find-package "KEYWORD")) (*read-suppress* nil)) (read stream nil stream t)))) ;; (print `(:read-feature ,expression)) (when (eq expression stream) (serror 'simple-end-of-file stream "EOF in ~S while reading the feature expression" stream)) (unless (funcall (if affirmativep (function identity) (function not)) (eval-feature expression stream)) ;; (print `(:read-feature ,expression false we eat)) (let ((*read-suppress* t)) ;; (print `(:read-feature ,(read stream t nil nil) :eaten)) (read stream t nil nil))) (values))) (defun reader-dispatch-macro-feature (stream arg sub-char) "Standard #+ dispatch macro reader." (declare (ignore sub-char arg)) (read-feature stream t)) (defun reader-dispatch-macro-not-feature (stream arg sub-char) "Standard #- dispatch macro reader." (declare (ignore sub-char arg)) (read-feature stream nil)) ;; (defparameter *rt* ;; (let ((rt (copy-readtable))) ;; (set-dispatch-macro-character ;; #\# #\+ (function reader-dispatch-macro-feature) rt) ;; (set-dispatch-macro-character ;; #\# #\- (function reader-dispatch-macro-not-feature) rt) ;; rt)) (defun reader-dispatch-macro-read-eval (stream arg sub-char) "Standard #. dispatch macro reader." (declare (ignore sub-char arg)) (if *read-eval* (eval (read stream t nil t)) (serror 'simple-reader-error stream "*READ-EVAL* = NIL does not allow the evaluation of ~S" (read stream t nil t)))) (defun reader-dispatch-macro-uninterned (stream arg sub-char) "Standard #: dispatch macro reader." (declare (ignore sub-char arg)) (multiple-value-bind (tokenp token) (read-token stream t nil t nil nil *readtable*) (if tokenp (make-symbol (token-text token)) (serror 'simple-reader-error stream "token expected after #:")))) (defun reader-dispatch-macro-unreadable (stream arg sub-char) "Standard #< dispatch macro reader." (declare (ignore sub-char arg)) (serror 'simple-reader-error stream "objects printed as #<...> cannot be read back in")) (defun reader-dispatch-macro-comment (stream arg sub-char) "Standard #| dispatch macro reader." (declare (ignore sub-char arg)) ;; #|...|# is treated as a comment by the reader. It must be balanced ;; with respect to other occurrences of #| and |#, but otherwise may ;; contain any characters whatsoever. (loop :with level = 1 :with state = :normal :until (zerop level) :do (case state ((:normal) (case (read-char stream t nil t) ((#\#) (setf state :sharp)) ((#\|) (setf state :pipe)))) ((:sharp) (case (read-char stream t nil t) ((#\#)) ((#\|) (incf level) (setf state :normal)) (otherwise (setf state :normal)))) ((:pipe) (case (read-char stream t nil t) ((#\#) (decf level) (setf state :normal)) ((#\|)) (otherwise (setf state :normal)))))) (values)) (defun reader-dispatch-macro-function (stream arg sub-char) "Standard #' dispatch macro reader." (declare (ignore sub-char arg)) `(cl:function ,(read stream t nil t))) (defun reader-dispatch-macro-vector (stream arg sub-char) "Standard #( dispatch macro reader." (declare (ignore sub-char)) ;; If an unsigned decimal integer appears between the # and (, it ;; specifies explicitly the length of the vector. The consequences are ;; undefined if the number of objects specified before the closing ) ;; exceeds the unsigned decimal integer. If the number of objects ;; supplied before the closing ) is less than the unsigned decimal ;; integer but greater than zero, the last object is used to fill all ;; remaining elements of the vector. The consequences are undefined if ;; the unsigned decimal integer is non-zero and number of objects ;; supplied before the closing ) is zero. In that case, we let the ;; implementation initialize the vector. ;; ;; Thanks to Budden for having signaled a bug in the first version of this function, ;; and thanks to Yulian Tarantuk for signaling the "comment before closing parenthesis" bug. (flet ((finish-vector (vector i) (if arg (progn (cond ((>= i arg) ;; vector is longer than the explicitly given length ;; We just eat the remaining stuff. (loop :until (char= #\) (peek-char t stream t nil t)) :do (let ((*read-suppress* t)) (read-0/1 stream t nil t nil nil '())) :finally (read-char stream nil nil t))) ;; vector is shorter. ((plusp i) ;; If we have at least one element in, ;; we replicate it till the end. (loop :with last-item = (aref vector (1- i)) :for j :from i :below arg :do (setf (aref vector j) last-item))) ;; Otherwise we will let it up to the implementation ;; to do its implementation dependent thing. ) vector) (copy-seq vector)))) (loop :with vector = (if arg (make-array arg) (make-array 1024 :adjustable t :fill-pointer 0)) :for i :from 0 :while (or (not arg) (< i arg)) :do (let ((peek (peek-char t stream nil stream t))) (cond ((eql peek stream) (serror 'simple-end-of-file stream "input stream ~S has reached its end" stream)) ((char= peek #\)) (read-char stream nil nil t) (return-from reader-dispatch-macro-vector (finish-vector vector i))) (t (multiple-value-bind (kind tokens) (read-0/1 stream t nil t nil nil '()) (declare (ignore kind)) ; always nil here. (when tokens (if arg (setf (aref vector i) (first tokens)) (vector-push-extend (first tokens) vector))))))) :finally (return-from reader-dispatch-macro-vector (finish-vector vector i))))) (defun reader-dispatch-macro-bit-vector (stream arg sub-char) "Standard #* dispatch macro reader. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/02_dhd.htm> " (declare (ignore sub-char)) ;; Syntax: #*<<bits>> ;; ;; A simple bit vector is constructed containing the indicated bits (0's ;; and 1's), where the leftmost bit has index zero and the subsequent ;; bits have increasing indices. ;; ;; Syntax: #<<n>>*<<bits>> ;; ;; With an argument n, the vector to be created is of length n. If the ;; number of bits is less than n but greater than zero, the last bit is ;; used to fill all remaining bits of the bit vector. ;; ;; The notations #* and #0* each denote an empty bit vector. ;; ;; Regardless of whether the optional numeric argument n is provided, the ;; token that follows the asterisk is delimited by a normal token ;; delimiter. However, (unless the value of *read-suppress* is true) an ;; error of type reader-error is signaled if that token is not composed ;; entirely of 0's and 1's, or if n was supplied and the token is ;; composed of more than n bits, or if n is greater than one, but no bits ;; were specified. Neither a single escape nor a multiple escape is ;; permitted in this token. (if arg (loop :with vector = (make-array arg :element-type 'bit :initial-element 0) :for i :from 0 :below arg :while (let ((ch (peek-char nil stream nil nil t))) (and ch (not (token-delimiter-p ch)))) :do (setf (aref vector i) (digit-char-p (read-char stream nil nil t))) :finally (progn (cond ((>= i arg) (let ((*read-suppress* t)) (loop :while (let ((ch (peek-char nil stream nil nil t))) (and ch (not (token-delimiter-p ch)))) :do (read-char stream nil nil t)))) ((plusp (aref vector (1- i))) (loop :for j :from i :below arg :do (setf (aref vector j) 1)))) (return vector))) (loop :with vector = (make-array 1024 :adjustable t :fill-pointer 0 :element-type 'bit :initial-element 0) :while (let ((ch (peek-char nil stream nil nil t))) (and ch (not (token-delimiter-p ch)))) ;; TODO: Check the behavior when the character is not a bit. :do (vector-push-extend (digit-char-p (read-char stream nil nil t)) vector) :finally (return (copy-seq vector))))) (defun reader-dispatch-macro-char (stream arg sub-char) "Standard #\\ dispatch macro reader." (declare (ignore sub-char arg)) (read-char stream t nil t)) (defun reader-dispatch-macro-array (stream arg sub-char) "Standard #A dispatch macro reader." (declare (ignore sub-char)) (let ((initial-contents (read stream t nil t))) (labels ((collect-dimensions (n contents dimensions) (if (zerop n) (nreverse dimensions) (collect-dimensions (1- n) (first contents) (cons (length contents) dimensions))))) ;; TODO: we rely on make-array to raise some errors that it may not raise... (make-array (collect-dimensions (or arg 1) initial-contents '()) :initial-contents initial-contents)))) (defun read-rational-in-base (stream arg sub-char *read-base*) " DO: Read a rational number in the base specified. RETURN: The rational read. " (when arg (serror stream "no number allowed between # and ~A" sub-char)) (let ((value (read stream t nil t))) (if (rationalp value) value (serror stream "token \"~A\" after #~A is not a rational number in base ~D" sub-char *read-base*)))) (defun reader-dispatch-macro-binary (stream arg sub-char) "Standard #B dispatch macro reader." (read-rational-in-base stream arg sub-char 2.)) (defun reader-dispatch-macro-octal (stream arg sub-char) "Standard #O dispatch macro reader." (read-rational-in-base stream arg sub-char 8.)) (defun reader-dispatch-macro-hexadecimal (stream arg sub-char) "Standard #X dispatch macro reader." (read-rational-in-base stream arg sub-char 16.)) (defun reader-dispatch-macro-radix (stream arg sub-char) "Standard #R dispatch macro reader." (unless arg (serror stream "the number base must be given between # and ~A" sub-char)) (read-rational-in-base stream nil sub-char arg)) ;; Copied from com.informatimago.common-lisp.cesarum.list to avoid package use loop. (defun proper-list-p (object) " RETURN: whether object is a proper list NOTE: terminates with any kind of list, dotted, circular, etc. " (labels ((proper (current slow) (cond ((null current) t) ((atom current) nil) ((null (cdr current)) t) ((atom (cdr current)) nil) ((eq current slow) nil) (t (proper (cddr current) (cdr slow)))))) (and (listp object) (proper object (cons nil object))))) (defun reader-dispatch-macro-complex (stream arg sub-char) "Standard #C dispatch macro reader." (declare (ignore sub-char arg)) (let ((c (read stream t nil t))) (unless (and (proper-list-p c) (= 2 (length c)) (every (function realp) c)) (serror 'simple-reader-error stream "bad syntax for complex number: #C~S" c)) (complex (first c) (second c)))) (defun reader-dispatch-macro-pathname (stream arg sub-char) "Standard #P dispatch macro reader." (declare (ignore sub-char arg)) (let ((namestring (read stream t nil t))) (if *read-suppress* nil (parse-namestring namestring)))) (defun reader-dispatch-macro-structure (stream arg sub-char) "Standard #S dispatch macro reader." (declare (ignore sub-char arg)) (let* ((data (read stream t nil t)) (constructor (intern (cl:with-standard-io-syntax (format nil "MAKE-~A" (first data))))) (arguments (loop :with keyword-package = (find-package "KEYWORD") :for (k v) :on (rest data) :by (function cddr) :collect (intern (string k) keyword-package) :collect v))) (apply constructor arguments))) #-sbcl (defmethod initialize-instance :after ((self readtable) &rest rest &key &allow-other-keys) (unless (getf rest :syntax-table) (macrolet ((smc (&rest clauses) `(progn ,@(mapcar (lambda (clause) `(set-macro-character ,(first clause) (function ,(second clause)) ,(third clause) self)) clauses)))) (smc (#\; reader-macro-line-comment nil) (#\" reader-macro-string nil) (#\' reader-macro-quote nil) (#\` reader-macro-backquote nil) (#\, reader-macro-comma nil) (#\( reader-macro-left-parenthesis nil) (#\) reader-macro-error-start nil))) (macrolet ((dmc (&rest clauses) `(progn ,@(mapcar (lambda (clause) `(set-dispatch-macro-character ,(first clause) ,(second clause) (function ,(third clause)) self)) clauses)))) (make-dispatch-macro-character #\# t self) (dmc (#\# #\SPACE reader-dispatch-macro-error-invalid) (#\# #\NEWLINE reader-dispatch-macro-error-invalid) (#\# #\# reader-dispatch-macro-label-reference) (#\# #\' reader-dispatch-macro-function) (#\# #\( reader-dispatch-macro-vector) (#\# #\* reader-dispatch-macro-bit-vector) (#\# #\+ reader-dispatch-macro-feature) (#\# #\- reader-dispatch-macro-not-feature) (#\# #\. reader-dispatch-macro-read-eval) (#\# #\: reader-dispatch-macro-uninterned) (#\# #\< reader-dispatch-macro-unreadable) (#\# #\= reader-dispatch-macro-label-definition) (#\# #\A reader-dispatch-macro-array) (#\# #\B reader-dispatch-macro-binary) (#\# #\C reader-dispatch-macro-complex) (#\# #\O reader-dispatch-macro-octal) (#\# #\P reader-dispatch-macro-pathname) (#\# #\R reader-dispatch-macro-radix) (#\# #\S reader-dispatch-macro-structure) (#\# #\X reader-dispatch-macro-hexadecimal) (#\# #\\ reader-dispatch-macro-char) (#\# #\| reader-dispatch-macro-comment) ;; clisp extensions: ;; (#\# #\! reader-dispatch-macro-executable) ;; (#\# #\" reader-dispatch-macro-clisp-pathname) ;; (#\# #\, reader-dispatch-macro-load-eval) ;; (#\# #\Y SYSTEM::CLOSURE-READER) )))) ;; Working around sbcl bugs is always a pleasure… #+sbcl (defun init (self rest) (unless (getf rest :syntax-table) (macrolet ((smc (&rest clauses) `(progn ,@(mapcar (lambda (clause) `(set-macro-character ,(first clause) (function ,(second clause)) ,(third clause) self)) clauses)))) (smc (#\; reader-macro-line-comment nil) (#\" reader-macro-string nil) (#\' reader-macro-quote nil) (#\` reader-macro-backquote nil) (#\, reader-macro-comma nil) (#\( reader-macro-left-parenthesis nil) (#\) reader-macro-error-start nil))) (macrolet ((dmc (&rest clauses) `(progn ,@(mapcar (lambda (clause) `(set-dispatch-macro-character ,(first clause) ,(second clause) (function ,(third clause)) self)) clauses)))) (make-dispatch-macro-character #\# t self) (dmc (#\# #\SPACE reader-dispatch-macro-error-invalid) (#\# #\NEWLINE reader-dispatch-macro-error-invalid) (#\# #\# reader-dispatch-macro-label-reference) (#\# #\' reader-dispatch-macro-function) (#\# #\( reader-dispatch-macro-vector) (#\# #\* reader-dispatch-macro-bit-vector) (#\# #\+ reader-dispatch-macro-feature) (#\# #\- reader-dispatch-macro-not-feature) (#\# #\. reader-dispatch-macro-read-eval) (#\# #\: reader-dispatch-macro-uninterned) (#\# #\< reader-dispatch-macro-unreadable) (#\# #\= reader-dispatch-macro-label-definition) (#\# #\A reader-dispatch-macro-array) (#\# #\B reader-dispatch-macro-binary) (#\# #\C reader-dispatch-macro-complex) (#\# #\O reader-dispatch-macro-octal) (#\# #\P reader-dispatch-macro-pathname) (#\# #\R reader-dispatch-macro-radix) (#\# #\S reader-dispatch-macro-structure) (#\# #\X reader-dispatch-macro-hexadecimal) (#\# #\\ reader-dispatch-macro-char) (#\# #\| reader-dispatch-macro-comment) ;; clisp extensions: ;; (#\# #\! reader-dispatch-macro-executable) ;; (#\# #\" reader-dispatch-macro-clisp-pathname) ;; (#\# #\, reader-dispatch-macro-load-eval) ;; (#\# #\Y SYSTEM::CLOSURE-READER) )))) #+sbcl (defmethod initialize-instance :after ((self readtable) &rest rest &key &allow-other-keys) (init self rest)) (setf *standard-readtable* (copy-readtable nil) *readtable* (copy-readtable nil)) (defun list-all-macro-characters (&optional (*readtable* *readtable*)) " RETURN: A list of all the macro and dispatch-macro characters in the readtable. NOTE: We have the same function in the com.informatimago.tools.reader-macro package, working on cl:readtable instead of com.informatimago.common-lisp.lisp-reader.reader:readtable. " (check-type *readtable* readtable) (loop :with result = '() :for code :below char-code-limit :for ch = (code-char code) :when ch :do (multiple-value-bind (mc nt) (get-macro-character ch) (when mc (if (ignore-errors (progn (get-dispatch-macro-character ch #\a) t)) (loop :for code :below char-code-limit :for sub = (code-char code) :when (and sub (not (and (alpha-char-p sub) (lower-case-p sub))) (get-dispatch-macro-character ch sub)) :do (push (list :dispatch-macro-character nt ch sub #-(and) (format nil "~C~C" ch sub)) result)) (push (list :macro-character nt ch #-(and) (string ch)) result)))) :finally (return (nreverse result)))) (defun potential-number-p (token &optional (*read-base* *read-base*) (ratio-markers "/")) " TOKEN: A string containing the token to be tested. *READ-BASE*: The current radix. RATIO-MARKER: / in the standard readtable, but it could be something else... RETURN: Whether the TOKEN is a potential number. " ;; sign "+-" ;; ratio-markers "/" (by default) ;; decimal-points "." ;; extension-characters "^_" ;; number-markers letters alone (and (plusp (length token)) ;; Letters may be considered to be digits, depending on the ;; current input base, but only in tokens containing no decimal ;; points. (let ((*read-base* (if (find #\. token) 10. *read-base*))) (and ;; 4. The token does not end with a sign (let ((last-ch (aref token (1- (length token))))) (not (find last-ch "+-"))) ;; 3. The token begins with a digit, sign, decimal point or extension character. (let ((first-ch (aref token 0))) (or (digit-char-p first-ch *read-base*) (find first-ch "+-.^_"))) ;; 2. The token contains at least one digit. (find-if (lambda (ch) (digit-char-p ch *read-base*)) token) ;; 1. The token consists entirely of digits, signs, ratio ;; markers, decimal points, extension characters, and ;; number markers. (loop :for prevch = #\0 :then ch :for ch :across token :always (or (digit-char-p ch *read-base*) (find ch "+-.^_") (find ch ratio-markers) (and (alpha-char-p ch) (not (alpha-char-p prevch))))))))) (defmacro WITH-STANDARD-IO-SYNTAX (&body body) `(let ((*package* (find-package "COMMON-LISP-USER")) (*print-array* t) (*print-base* 10) (*print-case* :upcase) (*print-circle* nil) (*print-escape* t) (*print-gensym* t) (*print-length* nil) (*print-level* nil) (*print-lines* nil) (*print-miser-width* nil) (*print-pprint-dispatch* nil #|implementation dependant|#) (*print-pretty* nil) (*print-radix* nil) (*print-readably* t) (*print-right-margin* nil) (*read-base* 10) (*read-default-float-format* 'single-float) (*read-eval* t) (*read-suppress* nil) (*readtable* (make-instance 'readtable))) ,@body)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; The End ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
96,102
Common Lisp
.lisp
2,007
37.077728
123
0.564549
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
5d80bbf4c3d792380a43f09cb1bca9f1d94afb8e3ae24341c6c8e38cdf894cf4
5,059
[ -1 ]
5,060
package-test.lisp
informatimago_lisp/common-lisp/lisp-reader/package-test.lisp
(eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.PACKAGE.TEST" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SIMPLE-TEST" ;; "COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.PACKAGE" ) (:import-from "COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.PACKAGE" "CHECK-DISJOINTS" "DECLARATIONS" "BODY") (:export "TEST/ALL")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.PACKAGE.TEST") (define-test test/check-disjoints () (assert-true (null (check-disjoints (list "S1" "S2" "S3") (list (list "P1" (list "P1A" "P1B" "P1C")) (list "P2" (list "P2A" "P2B" "P2C"))) (list (list "P3" (list "I1A" "I1B" "I1C")) (list "P4" (list "I2A" "I2B" "I2C"))) (list "I1" "I2" "I3") (list "E1" "E2" "E3")))) (assert-true (null (check-disjoints (list "S1" "S2" "S3") '() (list (list "P3" (list "I1A" "I1B" "I1C")) (list "P4" (list "I2A" "I2B" "I2C"))) '() (list "E1" "E2" "E3")))) (assert-true (nth-value 1 (ignore-errors (check-disjoints (list "S1" "S2" "S3") (list (list "P1" (list "P1A" "P1B" "P1C")) (list "P2" (list "P2A" "P2B" "P2C" "S3"))) (list (list "P3" (list "I1A" "I1B" "I1C")) (list "P4" (list "I2A" "I2B" "I2C"))) (list "I1" "I2" "I3") (list "E1" "E2" "E3"))))) (assert-true (null (check-disjoints (list "S1" "S2" "S3") (list (list "P1" (list "P1A" "P1B" "P1C")) (list "P2" (list "P2A" "P2B" "P2C"))) (list (list "P3" (list "I1A" "I1B" "I1C")) (list "P4" (list "I2A" "I2B" "I2C"))) (list "I1" "I2" "I3") (list "E1" "E2" "E3" "S2"))))) (define-test test/declarations/body () (assert-true (equal (mapcar (lambda (body) (list (declarations body) (body body))) '(() ((declare (ignore x))) ((declare (ignore x)) (declare (ignore y))) ((print w) (print z)) ((declare (ignore x)) (print w) (print z)) ((declare (ignore x)) (declare (ignore y)) (print w) (print z)))) '((nil nil) (((declare (ignore x))) nil) (((declare (ignore x)) (declare (ignore y))) nil) (nil ((print w) (print z))) (((declare (ignore x))) ((print w) (print z))) (((declare (ignore x)) (declare (ignore y))) ((print w) (print z))))))) (define-test test/all () (test/check-disjoints) (test/declarations/body)) ;;;; THE END ;;;;
3,668
Common Lisp
.lisp
57
37.45614
108
0.37441
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
951c9f5e29077255f90c09a67f47801f8240a6180219dca9f54083f00949b210
5,060
[ -1 ]
5,061
package-fun.lisp
informatimago_lisp/common-lisp/lisp-reader/package-fun.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: package.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; See defpackage documentation string. ;;;; ;;;;AUTHORS ;;;; <XACH> Zachary Beane <[email protected]>, ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2012-04-03 <PJB> Completed corrections to pass package ansi-tests. ;;;; 2012-03-30 <PJB> Added checks, made the API conforming to CL. ;;;; 2012-03-30 <PJB> Added this header; Removed "Z" prefix to CL ;;;; symbol names; shadowed and exported them. ;;;;BUGS ;;;; ;;;; make-load-form for packages should probably return two forms, since ;;;; packages can have circular dependencies. ;;;; ;;;; Are missing some standard restarts to correct ;;;; conflicts. (choosing one or the other symbol, doing the same ;;;; for all conflicts, etc). ;;;; ;;;;LEGAL ;;;; Copyright (c) 2012 Zachary Beane <[email protected]>, All Rights Reserved ;;;; Copyright (c) 2012 Pascal J. Bourguignon <[email protected]>, All Rights Reserved ;;;; ;;;; Redistribution and use in source and binary forms, with or without ;;;; modification, are permitted provided that the following conditions ;;;; are met: ;;;; ;;;; * Redistributions of source code must retain the above copyright ;;;; notice, this list of conditions and the following disclaimer. ;;;; ;;;; * Redistributions in binary form must reproduce the above ;;;; copyright notice, this list of conditions and the following ;;;; disclaimer in the documentation and/or other materials ;;;; provided with the distribution. ;;;; ;;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED ;;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ;;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ;;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ;;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ;;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ;;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (cl:in-package "COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.PACKAGE") ;;; Symbol internal management (defgeneric sym-pack (sym)) (defgeneric (setf sym-pack) (pack sym)) (defgeneric make-constant (symbol value)) ;;; Sym tables (defgeneric make-sym-table ()) (defgeneric tget (sym-name table)) (defgeneric tput (sym table)) (defgeneric tremove (sym table)) (defgeneric tmember (sym table)) (defgeneric tmap-syms (fun table)) (defgeneric tmembers (table)) ;;; Pack management (defgeneric present-table (pack)) (defgeneric shadowing-table (pack)) (defgeneric external-table (pack)) (defgeneric accessiblep (sym pack)) (defgeneric externalp (sym pack)) (defgeneric shadowingp (sym pack)) (defgeneric presentp (sym pack)) (defgeneric check-import-conflict (sym pack)) (defgeneric check-inherit-conflict (used-pack using-pack)) (defgeneric check-export-conflict (sym pack)) (defgeneric check-unintern-conflict (sym-name pack)) (defgeneric zimport-without-checks (sym pack)) (defgeneric zunintern-without-checks (sym pack)) (defgeneric (setf used-packs) (used-packs pack)) (defgeneric (setf used-by-packs) (used-by-packs pack)) ;;; Clone of the CL symbol/package interface (defgeneric make-symbol (sym-name) (:documentation " DO: Make a new symbol URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_mk_sym.htm> ")) (defgeneric symbol-name (sym) (:documentation " RETURN: the name of the symbol. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_symb_2.htm> ")) (defgeneric symbol-package (sym) (:documentation " RETURN: the home package of the symbol. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_symb_3.htm> ")) (defgeneric make-package (pack-name &key nicknames use) (:documentation " DO: Make a new package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_mk_pkg.htm> ")) (defgeneric find-package (pack-name) (:documentation " RETURN: The package designated by PACK-NAME, or NIL if none. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_find_p.htm> ")) (defgeneric delete-package (pack-name) (:documentation " DO: Delete the package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_del_pk.htm> ")) (defgeneric find-symbol (sym-name &optional pack) (:documentation " RETURN: the symbol named SYM-NAME in the package PACK, if found and a status keyword. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_find_s.htm> ")) (defgeneric import (symbols &optional pack) (:documentation " DO: Import the symbols into the package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_import.htm> ")) (defgeneric intern (sym-name &optional pack) (:documentation " DO: Intern the symbol name in the package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_intern.htm> ")) (defgeneric shadow (symbol-names &optional pack) (:documentation " DO: Shadow the designated symbols. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_shadow.htm> ")) (defgeneric shadowing-import (symbols &optional pack) (:documentation " DO: Shadow and import the designated symbols. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_shdw_i.htm> ")) (defgeneric export (sym &optional pack) (:documentation " DO: Export the designated symbols from the package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_export.htm> ")) (defgeneric unexport (sym &optional pack) (:documentation " DO: Unexport the designated symbols from the package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_unexpo.htm> ")) (defgeneric unintern (sym &optional pack) (:documentation " DO: Unintern the designated symbols from the package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_uninte.htm> ")) (defgeneric use-package (pack &optional using-pack) (:documentation " DO: Make the USING-PACK use the package PACK. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_use_pk.htm> ")) (defgeneric unuse-package (pack &optional using-pack) (:documentation " DO: Make the USING-PACK unuse the package PACK URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_unuse_.htm> ")) (defgeneric package-name (pack) (:documentation " RETURN: The package name. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_pkg_na.htm> ")) (defgeneric package-use-list (pack) (:documentation " RETURN: The list of packages used by PACK. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_pkg_us.htm> ")) (defgeneric package-used-by-list (pack) (:documentation " RETURN: The list of packages that use PACK. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_pkg__1.htm> ")) (defgeneric package-shadowing-symbols (pack) (:documentation " RETURN: The list of shadowing symbols of the package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_pkg_sh.htm> ")) (defgeneric find-all-symbols (name) (:documentation " RETURN: The list of all symbols named NAME in all packages. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_find_a.htm> ")) (defgeneric rename-package (package new-name &optional new-nicknames) (:documentation " DO: Rename the package giving it the NEW-NAME and NEW-NICKNAMES. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_rn_pkg.htm> ")) ;;; Variables (defparameter *keyword-package* nil) (defparameter *common-lisp-package* nil) (defparameter *common-lisp-user-package* nil) (defvar *package* nil " The current package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/v_pkg.htm> ") ;;; Conditions (define-condition simple-error-mixin (condition) ((format-control :initarg :format-control :reader format-control :initform "Simple error.") (format-arguments :initarg :format-arguments :reader format-arguments :initform '())) (:report (lambda (condition stream) (format stream "~?" (format-control condition) (format-arguments condition))))) (define-condition simple-program-error (simple-error-mixin program-error) ()) (define-condition simple-type-error (simple-error-mixin type-error) ()) (define-condition print-not-readable (error) ((object :initarg :object :reader print-not-readable-object :initform (error "Missing :object initarg."))) (:report (lambda (condition stream) (let ((*print-readably* nil) (*print-circle* t) (*print-length* 4) (*print-level* 4)) (format stream "The object ~S is not printable readably." (print-not-readable-object condition)))))) (defgeneric package-error-package (package-error) (:documentation " RETURN: The package in error. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_pkg_er.htm> ")) (define-condition package-error (error) ((package :initarg :package :reader package-error-package)) (:report (lambda (condition stream) (format stream "Package error with ~A" (package-error-package condition)))) (:documentation " The type package-error consists of error conditions related to operations on packages. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/e_pkg_er.htm> ")) (define-condition simple-package-error (package-error simple-error-mixin) ()) (define-condition package-exists-error (simple-package-error) () (:documentation "The error condition signaling that a package with the same name already exists.")) (define-condition package-does-not-exist-error (simple-package-error) () (:documentation "The error condition signaling that no package with that name exists.")) (defgeneric symbol-conflict-existing-symbol (error) (:documentation "RETURN: The existing symbol in conflict.")) (defgeneric symbol-conflict-imported-symbol (error) (:documentation "RETURN: The imported symbol in conflict.")) (define-condition symbol-conflict-error (simple-package-error) ((existing-symbol :initarg :existing-symbol :reader symbol-conflict-existing-symbol) (imported-symbol :initarg :imported-symbol :reader symbol-conflict-imported-symbol)) (:report (lambda (condition stream) (format stream "The would-be imported symbol ~S conflicts with the existing symbol ~S in the package ~S" (symbol-conflict-imported-symbol condition) (symbol-conflict-existing-symbol condition) (package-name (package-error-package condition))))) (:documentation "The error condition signaling a symbol conflict.")) (define-condition symbol-does-not-exist-error (simple-package-error) ((symbol-name :initarg :symbol-name :reader symbol-does-not-exist-symbol-name)) (:report (lambda (condition stream) (format stream "There exists no symbol named ~S in the package ~S" (symbol-does-not-exist-symbol-name condition) (package-name (package-error-package condition)))))) (define-condition symbol-inaccessible-error (simple-package-error) ((symbol :initarg :symbol :reader symbol-inaccessible-symbol)) (:report (lambda (condition stream) (format stream "~S is not accessible in ~S" (symbol-inaccessible-symbol condition) (package-name (package-error-package condition)))))) (defun query-string () (format *query-io* "Enter a new string: ") (finish-output *query-io*) (list (read-line *query-io*))) (defun query-symbol () (list (loop :for sym = (progn (format *query-io* "Enter a new symbol (current package is ~A): " (package-name *package*)) (finish-output *query-io*) (read *query-io*)) :until (symbolp sym) :finally (return sym)))) (defun query-package-name () (format *query-io* "Enter a package name (string or symbol): ") (finish-output *query-io*) (list (read *query-io*))) (defun query-package-nickname () (format *query-io* "Enter a package nickname (string or symbol): ") (finish-output *query-io*) (list (read *query-io*))) ;;; Implementation of syms (defgeneric symbol-plist (symbol) (:documentation " RETURN: The plist of the symbol. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_symb_4.htm> ")) (defgeneric symbol-value (symbol) (:documentation " RETURN: The value of the symbol. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_symb_5.htm> ")) (defgeneric symbol-function (symbol) (:documentation " RETURN: The function of the symbol. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_symb_1.htm> ")) (defclass symbol () ((name :initarg :name :reader symbol-name) (pack :initarg :pack :reader symbol-package :accessor sym-pack) (plist :initarg :plist :initform nil :accessor symbol-plist) (value :initarg :value :accessor symbol-value) (function :initarg :function :accessor symbol-function) (constantp :initarg :constantp :initform nil :accessor symbol-constantp)) (:default-initargs :pack nil) (:documentation " The symbol class. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/t_symbol.htm> ")) (defgeneric symbolp (object) (:method ((object t)) nil) (:method ((object symbol)) t) (:documentation " RETURN: Whether the object is a symbol. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_symbol.htm> ")) (defgeneric boundp (object) (:method ((object t)) (error 'type-error :datum object :expected-type 'symbol)) (:method ((object symbol)) (slot-boundp object 'value)) (:documentation " RETURN: Whether the symbol is bound to a value. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_boundp.htm> ")) (defgeneric fboundp (object) (:method ((object t)) (error 'type-error :datum object :expected-type 'symbol)) (:method ((object symbol)) (slot-boundp object 'function)) (:documentation " RETURN: Whether the symbol is fbound to a function. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_fbound.htm> ")) (defclass keyword (symbol) () (:documentation " The keyword class. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/t_kwd.htm> ")) (defgeneric keywordp (object) (:method ((object t)) nil) (:method ((object keyword)) t) (:documentation " RETURN: Whether the object is a keyword. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_kwdp.htm> ")) (defmethod make-symbol (sym-name) (make-instance 'symbol :name (copy-seq sym-name))) (defmethod make-load-form ((sym symbol) &optional environment) (declare (ignore environment)) `(intern ,(symbol-name sym) ,(package-name (symbol-package sym)))) (defun constituentp (ch first-character-p &optional (readtable *readtable*)) (multiple-value-bind (macro-character-p non-terminating-p) (get-macro-character ch readtable) (or (not macro-character-p) (and (not first-character-p) non-terminating-p)))) (defun specialp (ch &optional (readtable *readtable*)) (declare (ignore readtable)) (find ch #(#\Space #\: #\| #\\ #\Newline #\Tab #\Linefeed #\Return #\Page))) (defun parses-as-a-number-p (string &key (start 0) (end nil) (base *read-base*)) ;; integer ::= [sign] digit+ ;; integer ::= [sign] decimal-digit+ decimal-point ;; ratio ::= [sign] {decimal-digit}+ '/' {decimal-digit}+ ;; float ::= [sign] {decimal-digit}* decimal-point {decimal-digit}+ exponent ;; float ::= [sign] {decimal-digit}* decimal-point {decimal-digit}+ ;; float ::= [sign] {decimal-digit}+ exponent ;; float ::= [sign] {decimal-digit}+ decimal-point {decimal-digit}* exponent ;; exponent ::= exponent-marker [sign] {digit}+ ;; We may ignore ratio starting with #\# since that's excluded by constituentp. ;; ratio ::= [#b|#o|#x|#{decimal-digit}+r] [sign] digit+ '/' digit+ (loop :with end = (or end (length string)) :with i = start :with state = :opt-sign :for ch = (and (< i end) (aref string i)) :while (< i end) :do (ecase state (:opt-sign (case ch ((#\+ #\-) (incf i))) (setf state :unknown0)) (:unknown0 (if (<= base 10) (cond ((digit-char-p ch base) (incf i) (setf state :unknown1)) ((digit-char-p ch 10) (incf i) (setf state :decimal)) (t (case ch ((#\.) (incf i) (setf state :float0)) (otherwise (return nil))))) (cond ((digit-char-p ch 10) (incf i) (setf state :unknown1)) ((digit-char-p ch base) (incf i) (setf state :integer)) (t (case ch ((#\.) (incf i) (setf state :float0)) (otherwise (return nil))))))) (:unknown1 (if (<= base 10) (cond ((digit-char-p ch base) (incf i) (setf state :unknown1)) ((digit-char-p ch 10) (incf i) (setf state :decimal)) (t (case ch ((#\/) (incf i) (setf state :ratio0)) ((#\.) (incf i) (setf state :dot)) ((#\D #\d #\E #\e #\F #\f #\L #\l #\S #\s) (incf i) (setf state :float-expo/opt-sign)) (otherwise (return nil))))) (cond ((digit-char-p ch 10) (incf i) (setf state :unknown1)) ((digit-char-p ch base) (incf i) (setf state :integer)) (t (case ch ((#\/) (incf i) (setf state :ratio0)) ((#\.) (incf i) (setf state :dot)) ((#\D #\d #\E #\e #\F #\f #\L #\l #\S #\s) (incf i) (setf state :float-expo/opt-sign)) (otherwise (return nil))))))) (:integer (if (digit-char-p ch base) (incf i) (return nil))) (:decimal (if (digit-char-p ch 10) (incf i) (case ch ((#\/) (incf i) (setf state :ratio0)) ((#\.) (incf i) (setf state :dot)) ((#\D #\d #\E #\e #\F #\f #\L #\l #\S #\s) (incf i) (setf state :float-expo/opt-sign)) (otherwise (return nil))))) (:dot (if (digit-char-p ch 10) (progn (incf i) (setf state :float)) (case ch ((#\D #\d #\E #\e #\F #\f #\L #\l #\S #\s) (incf i) (setf state :float-expo/opt-sign)) (otherwise (return nil))))) (:ratio0 (if (digit-char-p ch 10) (progn (incf i) (setf state :ratio)) (return nil))) (:ratio (if (digit-char-p ch 10) (incf i) (return nil))) (:float0 (if (digit-char-p ch 10) (progn (incf i) (setf state :float)) (return nil))) (:float (if (digit-char-p ch 10) (incf i) (case ch ((#\D #\d #\E #\e #\F #\f #\L #\l #\S #\s) (incf i) (setf state :float-expo/opt-sign)) (otherwise (return nil))))) (:float-expo/opt-sign (case ch ((#\+ #\-) (incf i))) (setf state :float-expo0)) (:float-expo0 (if (digit-char-p ch 10) (progn (incf i) (setf state :float-expo)) (return nil))) (:float-expo (if (digit-char-p ch 10) (incf i) (return nil)))) :finally (return (case state ((:unknown1 :integer :dot :ratio :float :float-expo) t) (otherwise nil))))) (defun needs-escape-p (symbol-name) "Whether the symbol name needs to be escaped." (cond ((string= "" symbol-name) t) ((or *print-readably* *print-escape*) (or (notevery (let ((first-character-p t)) (lambda (ch) (prog1 (and (not (specialp ch)) (constituentp ch first-character-p)) (setf first-character-p nil)))) symbol-name) ;; Parses as a number integer, decimal, ratio or float. (parses-as-a-number-p symbol-name :base *print-base*))) (t nil))) (defun mixed-case-p (string) "Whether the string contains both lower case and upper case letters." (and (some (lambda (ch) (and (alpha-char-p ch) (upper-case-p ch))) string) (some (lambda (ch) (and (alpha-char-p ch) (lower-case-p ch))) string))) (defun prepare-symbol-name (sname) (cond ((needs-escape-p sname) (with-output-to-string (*standard-output*) (loop :for ch :across sname :initially (princ "|") :do (if (char= #\| ch) (princ "\\|") (princ ch)) :finally (princ "|")))) (t (let ((transform (if *print-escape* (ecase (readtable-case *readtable*) (:upcase (lambda (ch) (if (both-case-p ch) (if (lower-case-p ch) (format nil "\\~C" ch) ch) ch))) (:downcase (lambda (ch) (if (both-case-p ch) (if (upper-case-p ch) (format nil "\\~C" ch) ch)))) (:preserve (function identity)) (:invert (function identity))) (ecase (readtable-case *readtable*) (:upcase (let ((start-word t)) (lambda (ch) (prog1 (if (both-case-p ch) (if (upper-case-p ch) (ecase *print-case* (:upcase ch) (:downcase (char-downcase ch)) (:capitalize (if start-word (char-upcase ch) (char-downcase ch)))) ch) ch) (if (alphanumericp ch) (setf start-word nil) (setf start-word t)))))) (:downcase (let ((start-word t)) (lambda (ch) (prog1 (if (both-case-p ch) (if (lower-case-p ch) (ecase *print-case* (:upcase (char-upcase ch)) (:downcase ch) (:capitalize (if start-word (char-upcase ch) (char-downcase ch)))) ch) ch) (if (alphanumericp ch) (setf start-word nil) (setf start-word t)))))) (:preserve (function identity)) (:invert (if (mixed-case-p sname) (function identity) (lambda (ch) (cond ((not (both-case-p ch)) ch) ((upper-case-p ch) (char-downcase ch)) ((lower-case-p ch) (char-upcase ch)) (t ch))))))))) (with-output-to-string (*standard-output*) (loop :for ch :across sname :do (princ (funcall transform ch)))))))) (defmethod print-object ((sym symbol) stream) (let ((*print-readably* t)) (flet ((print-it () (let ((pack (symbol-package sym))) (cond ((null pack) (format stream "~:[~;#:~]~A" (or *print-readably* (and *print-escape* *print-gensym*)) (prepare-symbol-name (symbol-name sym)))) ((eql pack *keyword-package*) (format stream ":~A" (prepare-symbol-name (symbol-name sym)))) ((or (eq pack *package*) (eq sym (find-symbol (symbol-name sym) *package*))) (format stream "~A" (prepare-symbol-name (symbol-name sym)))) (t (format stream "~A~:[::~;:~]~A" (prepare-symbol-name (package-name pack)) (externalp sym pack) (prepare-symbol-name (symbol-name sym)))))))) (if *print-readably* (print-it) (progn (format stream "#<~S " 'symbol) (print-it) (format stream ">"))))) sym) (defmethod make-constant (symbol value) (declare (ignorable value)) (setf (symbol-value symbol) value (symbol-constantp symbol) t) symbol) ;;; Implementation of sym-tables (defclass sym-table () ((name-table :initarg :name-table :reader name-table)) (:default-initargs :name-table (make-hash-table :test 'equal))) (defmethod make-sym-table () (make-instance 'sym-table)) (defmethod tget (sym-name table) (values (gethash sym-name (name-table table)))) (defmethod tmember (sym table) (let ((entry (tget (symbol-name sym) table))) (eq entry sym))) (defmethod tput (sym table) (setf (gethash (symbol-name sym) (name-table table)) sym)) (defmethod tremove (sym table) (remhash (symbol-name sym) (name-table table))) (defmethod tmap-syms (fun table) (maphash (lambda (sym-name sym) (declare (ignore sym-name)) (funcall fun sym)) (name-table table))) (defmethod tmembers (table) (let ((members '())) (tmap-syms (lambda (sym) (push sym members)) table) members)) ;;; Implementation of packs & CL clone interface (defparameter *packs* (make-hash-table :test 'equal)) (defun list-all-packages () " RETURN: A fresh list of all registered packages. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_list_a.htm> " (let ((packages '())) (maphash (lambda (k v) (declare (ignore k)) (pushnew v packages)) *packs*) packages)) (defgeneric package-documentation (package) (:documentation "RETURN: The documentation string of the package.")) (defgeneric package-nicknames (package) (:documentation "RETURN: The list of nicknames of the package.")) (defclass package () ((name :initarg :name :reader package-name :writer (setf name)) (external-table :initarg :external-table :reader external-table) (present-table :initarg :present-table :reader present-table) (shadowing-table :initarg :shadowing-table :reader shadowing-table) (used-packs :initarg :used-packs :reader package-use-list :writer (setf used-packs)) (used-by-packs :initarg :used-by-packs :reader package-used-by-list :writer (setf used-by-packs)) (nicknames :initarg :nicknames :reader package-nicknames :writer (setf nicknames)) (documentation :initarg :documentation :initform nil :accessor package-documentation)) (:default-initargs :name (error "A package name is required") :external-table (make-sym-table) :present-table (make-sym-table) :shadowing-table (make-sym-table) :used-packs nil :used-by-packs nil) (:documentation " The package class. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/t_pkg.htm> ")) (defmacro define-normalize-package-methods (name &key (if-package-does-not-exist :replace) (type-error nil)) `(progn ,@ (when type-error `((defmethod ,name ((name t)) (error 'simple-type-error :datum name :expected-type 'package-designator :format-control "~S called with a non ~S: ~S" :format-arguments (list ',name 'package-designator name))))) (defmethod ,name ((name string)) (,name (normalize-package-designator name :if-package-does-not-exist ,if-package-does-not-exist))) (defmethod ,name ((name character)) (,name (normalize-package-designator name :if-package-does-not-exist ,if-package-does-not-exist))) (defmethod ,name ((name cl:symbol)) (,name (normalize-package-designator name :if-package-does-not-exist ,if-package-does-not-exist))) (defmethod ,name ((name symbol)) (,name (normalize-package-designator (symbol-name name) :if-package-does-not-exist ,if-package-does-not-exist))))) (define-normalize-package-methods package-name :type-error t) (define-normalize-package-methods package-use-list :type-error t) (define-normalize-package-methods package-used-by-list :type-error t) (define-normalize-package-methods package-nicknames :type-error t) (define-normalize-package-methods package-shadowing-symbols) (defgeneric packagep (package) (:method ((object t)) nil) (:method ((package package)) t) (:documentation " RETURN: Whether the object is a package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_pkgp.htm> ")) (defmethod print-object ((pack package) stream) (if *print-readably* (error 'print-not-readable :object pack) (format stream "#<~S ~S>" 'package (package-name pack))) pack) (defmethod package-shadowing-symbols (pack) (tmembers (shadowing-table pack))) (defmethod accessiblep (sym pack) (let ((existing-sym (find-symbol (symbol-name sym) pack))) (eq existing-sym sym))) (defmethod externalp (sym pack) (tmember sym (external-table pack))) (defmethod shadowingp (sym pack) (tmember sym (shadowing-table pack))) (defmethod presentp (sym pack) (tmember sym (present-table pack))) (defun ensure-list (object) (if (listp object) object (list object))) (deftype string-designator () '(or string character symbol cl:symbol)) (defun normalize-string-designator (object &key (if-not-a-string-designator :error)) (check-type if-not-a-string-designator (member nil :error :ignore :replace :ignore-or-replace)) (typecase object (string object) (character (string object)) (cl:symbol (string object)) (symbol (symbol-name object)) (otherwise (case if-not-a-string-designator ((:error) (error 'type-error :datum object :expected-type 'string-designator)) ((nil) nil) ((:ignore :replace :ignore-or-replace) (restart-case (error 'type-error :datum object :expected-type 'string-designator) (ignore () :test (lambda (condition) (declare (ignore condition)) (member if-not-a-string-designator '(:ignore :ignore-or-replace))) :report "Ignore it." nil) (read-a-new-string-designator (new-string) :test (lambda (condition) (declare (ignore condition)) (member if-not-a-string-designator '(:replace :ignore-or-replace))) :interactive query-string :report "Enter a string" (normalize-string-designator new-string :if-not-a-string-designator if-not-a-string-designator)))))))) (defun normalize-weak-designator-of-list-of-string-designator (object) (mapcan (lambda (nickname) (ensure-list (normalize-string-designator nickname :if-not-a-string-designator :ignore-or-replace))) (ensure-list object))) (deftype package-designator () '(or package string-designator)) (defun normalize-package-designator (object &key (if-package-does-not-exist :string) (if-package-exists :package) (if-not-a-package-designator :error)) " Normalize the given PACKAGE-DESIGNATOR. Objects of type PACKAGE-DESIGNATOR are either PACKAGE or objects of type STRING-DESIGNATOR. RETURN: either NIL, a STRING designating a non-existent package, or an existing PACKAGE. IF-NOT-A-PACKAGE-DESIGNATOR The default is :ERROR. NIL If the OBJECT is not a PACKAGE-DESIGNATOR then return NIL. :ERROR If the OBJECT is not a PACKAGE-DESIGNATOR then signal a TYPE-ERROR. :IGNORE If the OBJECT is not a PACKAGE-DESIGNATOR then signal a TYPE-ERROR, with an IGNORE restart that when chosen returns NIL. :REPLACE If the OBJECT is not a PACKAGE-DESIGNATOR then signal a TYPE-ERROR, with a replace restart that when chosen let the user input another PACKAGE-DESIGNATOR. :IGNORE-OR-REPLACE If the OBJECT is not a PACKAGE-DESIGNATOR then signal a TYPE-ERROR, with the two previous restarts. If the object is a PACKAGE-DESIGNATOR, then the results depends on the following parameters and whether the designated package exists or not. IF-PACKAGE-DOES-NOT-EXIST The default is :STRING NIL If the OBJECT designates a PACKAGE that doesn't exist then return NIL. :STRING If the OBJECT designates a PACKAGE that doesn't exist then (it would be a STRING-DESIGNATOR) return the designated STRING. :ERROR If the OBJECT designates a PACKAGE that doesn't exist then signal a PACKAGE-DOES-NOT-EXIST-ERROR. :IGNORE If the OBJECT designates a PACKAGE that doesn't exist then signal a PACKAGE-DOES-NOT-EXIST-ERROR with an IGNORE restart that when chosen returns NIL. :REPLACE If the OBJECT designates a PACKAGE that doesn't exist then signal a PACKAGE-DOES-NOT-EXIST-ERROR with a replace restart that when chosen let the user input another PACKAGE-DESIGNATOR. :IGNORE-OR-REPLACE If the OBJECT designates a PACKAGE that doesn't exist then signal a PACKAGE-DOES-NOT-EXIST-ERROR with the two previous restarts. IF-PACKAGE-EXISTS The default is :PACKAGE :PACKAGE If the OBJECT designates a PACKAGE that does exist then return the designated PACKAGE. :STRING If the OBJECT designates a PACKAGE that does exist then return the designated package name. :ERROR If the OBJECT designates a PACKAGE that does exist then signal a PACKAGE-EXISTS-ERROR. :IGNORE If the OBJECT designates a PACKAGE that does exist then signal a PACKAGE-EXISTS-ERROR with an IGNORE restart that when chosen returns NIL. :REPLACE If the OBJECT designates a PACKAGE that does exist then signal a PACKAGE-EXISTS-ERROR with a replace restart that when chosen let the user input another PACKAGE-DESIGNATOR. :IGNORE-OR-REPLACE If the OBJECT designates a PACKAGE that does exist then signal a PACKAGE-EXISTS-ERROR with the two previous restarts. " (check-type if-not-a-package-designator (member :error :ignore :replace :ignore-or-replace nil)) (check-type if-package-does-not-exist (member :error :ignore :replace :ignore-or-replace :string nil)) (check-type if-package-exists (member :error :ignore :replace :ignore-or-replace :string :package)) (flet ((retry-string-designator (restarts condition &rest arguments) (check-type restarts (member :ignore :replace :ignore-or-replace)) (restart-case (apply (function error) condition arguments) (ignore () :test (lambda (condition) (declare (ignore condition)) (member restarts '(:ignore :ignore-or-replace))) :report "Ignore it." nil) (read-a-new-package-designator (new-package) :test (lambda (condition) (declare (ignore condition)) (member restarts '(:replace :ignore-or-replace))) :interactive query-package-name :report "Enter a package name" (normalize-package-designator new-package :if-not-a-package-designator if-not-a-package-designator :if-package-does-not-exist if-package-does-not-exist :if-package-exists if-package-exists)))) (retry-package-designator (restarts condition &rest arguments) (check-type restarts (member :ignore :replace :ignore-or-replace)) (restart-case (apply (function error) condition arguments) (ignore () :test (lambda (condition) (declare (ignore condition)) (member restarts '(:ignore :ignore-or-replace))) :report "Ignore it." nil) (read-a-new-package-designator (new-package) :test (lambda (condition) (declare (ignore condition)) (member restarts '(:replace :ignore-or-replace))) :interactive query-package-name :report "Enter a package name" (normalize-package-designator new-package :if-not-a-package-designator if-not-a-package-designator :if-package-does-not-exist if-package-does-not-exist :if-package-exists if-package-exists))))) (typecase object (string-designator (let* ((normalized (normalize-string-designator object)) (package (find-package normalized))) (if package (normalize-package-designator package :if-package-exists if-package-exists) (case if-package-does-not-exist ((nil) nil) ((:string) normalized) ((:error) (error 'package-does-not-exist-error :package normalized :format-control "There is no package named ~S" :format-arguments (list normalized))) ((:ignore :replace :ignore-or-replace) (retry-package-designator if-package-does-not-exist 'package-does-not-exist-error :package normalized :format-control "There is no package named ~S" :format-arguments (list normalized))))))) (package (case if-package-exists ((:package) object) ((:string) (package-name object)) ((:error) (error 'package-exists-error :package object :format-control "There is already a package named ~S" :format-arguments (list (package-name object)))) ((:ignore :replace :ignore-or-replace) (retry-package-designator if-package-exists 'package-exists-error :package object :format-control "There is already a package named ~S" :format-arguments (list (package-name object)))))) (otherwise (case if-not-a-package-designator ((nil) nil) ((:error) (error 'type-error :datum object :expected-type 'package-designator)) ((:ignore :replace :ignore-or-replace) (retry-string-designator if-not-a-package-designator 'type-error :datum object :expected-type 'package-designator))))))) (defun make-package-iterator (packages symbol-types) (let ((packages (mapcan (lambda (package-designator) (list (normalize-package-designator package-designator :if-package-does-not-exist :ignore-or-replace))) (ensure-list packages))) (package nil) (stypes nil) (stype nil) (symbols '())) (labels ((iterator () (cond (symbols (let ((sym (pop symbols))) (values t sym (cond ((externalp sym package) :external) ((eq stype :inherited) stype) (t :internal)) package))) (stypes (setf stype (pop stypes)) (ecase stype ((:internal) (tmap-syms (lambda (sym) (unless (externalp sym package) (push sym symbols))) (present-table package))) ((:external) (tmap-syms (lambda (sym) (push sym symbols)) (external-table package))) ((:inherited) (dolist (pack (package-use-list package)) (tmap-syms (lambda (sym) (let ((shadow (find-symbol (symbol-name sym) package))) (unless (and shadow (shadowingp shadow package) (not (eq sym shadow))) (push sym symbols)))) (external-table (find-package pack))))) ((:present) (tmap-syms (lambda (sym) (push sym symbols)) (present-table package))) ((:shadowing) (tmap-syms (lambda (sym) (push sym symbols)) (shadowing-table package)))) (iterator)) (packages (setf package (pop packages) stypes symbol-types) (iterator)) (t nil)))) (function iterator)))) (defmethod check-import-conflict (sym pack) (let ((existing-sym (find-symbol (symbol-name sym) pack))) (if (and existing-sym (not (eq existing-sym sym))) (restart-case (error 'symbol-conflict-error :package pack :format-control "Conflict: importing ~A into ~A conflicts with ~A" :format-arguments (list sym pack existing-sym) :existing-symbol existing-sym :imported-symbol sym) (enter-new-name (new-symbol) :interactive query-symbol :report "Enter a new symbol, instead" (check-import-conflict new-symbol pack)) (ignore-symbol () :report (lambda (stream) (format stream "Ignore the symbol ~S" sym)) (values nil nil))) (values sym t)))) (defmacro zdo-external-symbols ((var pack) &body body) `(tmap-syms (lambda (,var) ,@body) (external-table ,pack))) (defmethod check-inherit-conflict (used-pack using-pack) (zdo-external-symbols (inherited-sym used-pack) (let ((existing-sym (find-symbol (symbol-name inherited-sym) using-pack))) (when (and existing-sym (not (eq inherited-sym existing-sym)) (not (shadowingp existing-sym using-pack))) (error "Conflict: Inheriting ~A from ~A conflicts with ~A in ~A" inherited-sym used-pack existing-sym using-pack))))) (defmethod check-export-conflict (sym pack) (let ((sym-name (symbol-name sym))) (dolist (using-pack (package-used-by-list pack)) (let ((existing-sym (find-symbol sym-name using-pack))) (when (and existing-sym (not (member existing-sym (package-shadowing-symbols using-pack)))) (unless (eq existing-sym sym) (error "Conflict: exporting ~A conflicts with ~A in ~A" sym existing-sym using-pack))))))) (defmethod check-unintern-conflict (sym pack) (let ((sym-name (symbol-name sym)) (first-existing-sym nil)) (dolist (used-pack (package-use-list pack)) (let ((existing-sym (find-symbol sym-name used-pack))) (when existing-sym (if first-existing-sym (unless (eq existing-sym first-existing-sym) (error "Conflict: uninterning ~A would lead to conflict ~ between ~A and ~A" sym first-existing-sym existing-sym)) (setf first-existing-sym existing-sym))))))) (defmethod zimport-without-checks (sym pack) (tput sym (present-table pack)) (unless (symbol-package sym) (setf (sym-pack sym) pack))) (defmethod zunintern-without-checks (sym pack) (tremove sym (external-table pack)) (tremove sym (shadowing-table pack)) (tremove sym (present-table pack)) (when (eq (symbol-package sym) pack) (setf (sym-pack sym) nil))) (defun check-new-names (pack-name nicknames &key renaming-package) (loop :with result = '() :for name :in (cons pack-name nicknames) :do (loop :for pack = (find-package name) :while (if renaming-package (and pack (not (eq pack renaming-package))) pack) :do (restart-case (error 'package-exists-error :package name :format-control "A package named ~S already exists" :format-arguments (list name)) (enter-new-name (new-name) :test (lambda (condition) (declare (ignore condition)) (eq name pack-name)) :interactive query-package-name :report "Enter a new package name, instead" (setf name new-name)) (enter-new-name (new-name) :test (lambda (condition) (declare (ignore condition)) (not (eq name pack-name))) :report "Enter a new package nickname, instead" :interactive query-package-nickname (setf name new-name)) (ignore-nickname () :test (lambda (condition) (declare (ignore condition)) (not (eq name pack-name))) :report (lambda (stream) (format stream "Ignore the nickname ~S" name)) (return))) :finally (push name result)) :finally (let ((result (nreverse result))) (return (values (car result) (cdr result)))))) (defmethod make-package (pack-name &key (nicknames '()) (use '())) (let ((pack-name (normalize-string-designator pack-name :if-not-a-string-designator :replace)) (nicknames (normalize-weak-designator-of-list-of-string-designator nicknames)) (use (mapcan (lambda (package-designator) (list (normalize-package-designator package-designator :if-package-does-not-exist :ignore-or-replace))) use))) (multiple-value-setq (pack-name nicknames) (check-new-names pack-name nicknames)) (let ((package (make-instance 'package :name (copy-seq pack-name) :nicknames (mapcar (function copy-seq) nicknames)))) (dolist (upack use) (use-package upack package)) (dolist (name (cons pack-name nicknames) package) (setf (gethash name *packs*) package))))) (defmethod find-package (pack-name) (etypecase pack-name (string-designator (values (gethash (normalize-string-designator pack-name) *packs*))) (package pack-name))) (defmethod delete-package (pack) (let ((pack (normalize-package-designator pack :if-package-does-not-exist :replace))) (when (and pack (package-name pack)) (dolist (used (package-used-by-list pack)) (unuse-package pack used)) (dolist (puse (package-use-list pack)) (unuse-package puse pack)) (do-symbols (sym pack) (when (eq (symbol-package sym) pack) (zunintern-without-checks sym pack))) (dolist (name (cons (package-name pack) (package-nicknames pack))) (remhash name *packs*)) (setf (name pack) nil) pack))) (defmethod find-symbol (sym-name &optional (pack *package*)) (let ((pack (normalize-package-designator pack :if-package-does-not-exist :replace)) sym) (cond ((setf sym (tget sym-name (external-table pack))) (values sym :external)) ((setf sym (tget sym-name (shadowing-table pack))) (values sym :internal)) ((setf sym (some (lambda (used-pack) (tget sym-name (external-table used-pack))) (package-use-list pack))) (values sym :inherited)) ((setf sym (tget sym-name (present-table pack))) (values sym :internal)) (t (values nil nil))))) (defmethod import (symbols &optional (pack *package*)) (let ((pack (normalize-package-designator pack :if-package-does-not-exist :error))) (flet ((do-import (sym) (check-type sym symbol) (multiple-value-bind (sym good) (check-import-conflict sym pack) (when (and good (not (presentp sym pack))) (if (and (null (symbol-package sym)) (eql pack *keyword-package*)) (progn (zimport-without-checks sym pack) (change-class sym 'keyword) (make-constant sym sym) (export sym pack)) (zimport-without-checks sym pack)))))) (mapc (function do-import) (ensure-list symbols))) t)) (defmethod intern (sym-name &optional (pack *package*)) (check-type sym-name string) (let ((pack (normalize-package-designator pack :if-package-does-not-exist :error))) (multiple-value-bind (sym status) (find-symbol sym-name pack) (if status (values sym status) (values (let ((sym (make-symbol sym-name))) (import sym pack) (when (eql pack *keyword-package*) (change-class sym 'keyword) (make-constant sym sym) (export sym pack)) sym) nil))))) (defmethod shadow (symbol-names &optional (pack *package*)) (let ((pack (normalize-package-designator pack :if-package-does-not-exist :error))) (flet ((do-shadow (sym-name) (let ((sym (tget sym-name (present-table pack)))) (unless sym (setf sym (make-symbol sym-name)) (zimport-without-checks sym pack)) (tput sym (shadowing-table pack))))) (mapc (function do-shadow) (normalize-weak-designator-of-list-of-string-designator symbol-names))) t)) (defmethod shadowing-import (symbols &optional (pack *package*)) (let ((pack (normalize-package-designator pack :if-package-does-not-exist :error))) (flet ((do-shadowing-import (sym) (check-type sym symbol) (let ((sym-name (symbol-name sym))) (multiple-value-bind (existing-sym type) (find-symbol sym-name pack) (case type ((nil :inherited) (zimport-without-checks sym pack)) ((:external :internal) (unless (eq existing-sym sym) (zunintern-without-checks existing-sym pack) (import sym pack)))) (tput sym (shadowing-table pack)))))) (mapc (function do-shadowing-import) (ensure-list symbols)) t))) (defmethod export (symbols &optional (pack *package*)) (let ((pack (normalize-package-designator pack :if-package-does-not-exist :error))) (flet ((do-export (sym) (check-type sym symbol) (unless (accessiblep sym pack) (error 'symbol-inaccessible-error :package pack :symbol sym)) (check-export-conflict sym pack) (unless (presentp sym pack) (import sym pack)) (tput sym (external-table pack)))) (mapc (function do-export) (ensure-list symbols)) t))) (defmethod unexport (symbols &optional (pack *package*)) (let ((pack (normalize-package-designator pack :if-package-does-not-exist :error))) (flet ((do-unexport (sym) (check-type sym symbol) (unless (accessiblep sym pack) (error 'symbol-inaccessible-error :package pack :symbol sym)) (tremove sym (external-table pack)))) (mapc (function do-unexport) (ensure-list symbols)) t))) (defmethod unintern (sym &optional (pack *package*)) (let ((pack (normalize-package-designator pack :if-package-does-not-exist :error))) (when (accessiblep sym pack) (check-unintern-conflict sym pack) (zunintern-without-checks sym pack) t))) (defmethod use-package (packs &optional (using-pack *package*)) (let ((using-pack (normalize-package-designator using-pack :if-package-does-not-exist :error))) (dolist (pack (ensure-list packs) t) (let* ((pack (normalize-package-designator pack :if-package-does-not-exist :error)) (use-list (package-use-list using-pack))) (unless (member pack use-list) (check-inherit-conflict pack using-pack) (setf (used-packs using-pack) (cons pack use-list)) (setf (used-by-packs pack) (cons using-pack (package-used-by-list pack)))))))) (defmethod unuse-package (packs &optional (using-pack *package*)) (let ((using-pack (normalize-package-designator using-pack :if-package-does-not-exist :error))) (dolist (pack (ensure-list packs) t) (let ((pack (normalize-package-designator pack :if-package-does-not-exist :error))) (setf (used-packs using-pack) (remove pack (package-use-list using-pack))) (setf (used-by-packs pack) (remove using-pack (package-used-by-list pack))))))) (defmethod find-all-symbols (name) (let ((name (normalize-string-designator name)) (symbols '())) (dolist (pack (list-all-packages) (delete-duplicates symbols)) (multiple-value-bind (sym found) (find-symbol name pack) (when found (push sym symbols)))))) (defmethod rename-package (package new-name &optional new-nicknames) (let ((package (normalize-package-designator package :if-package-does-not-exist :error)) (new-name (normalize-string-designator new-name)) (new-nicknames (normalize-weak-designator-of-list-of-string-designator new-nicknames))) (multiple-value-setq (new-name new-nicknames) (check-new-names new-name new-nicknames :renaming-package package)) ;; remove old names: (dolist (name (cons (package-name package) (package-nicknames package))) (remhash name *packs*)) ;; set new names: (setf (name package) (copy-seq new-name) (nicknames package) (mapcar (function copy-seq) new-nicknames)) (dolist (name (cons new-name new-nicknames) package) (setf (gethash name *packs*) package)))) (defun check-disjoints (shadows shadowing-import-froms import-froms interns exports) (loop :for sets :in (list (append (list shadows interns) (mapcar (function second) import-froms) (mapcar (function second) shadowing-import-froms)) (list interns exports)) :do (loop :for lefts :on sets :for left = (first lefts) :while (rest lefts) :do (loop :for rights :on (rest lefts) :for right = (first rights) :for inter = (intersection left right :test (function string=)) :do (when inter (flet ((set-name (set) (let ((name (cdr (assoc set (list (cons shadows :shadow) (cons interns :intern) (cons exports :export)))))) (or name (let ((name (first (find set shadowing-import-froms :key (function rest))))) (when name (list :shadowing-import-from name))) (let ((name (first (find set import-froms :key (function rest))))) (when name (list :import-from name))))))) (error 'simple-program-error :format-control "Symbol names in common between ~S and ~S: ~S" :format-arguments (list (set-name left) (set-name right) inter))))))) nil) (defun %define-package (name shadows shadowing-imports uses imports interns exports documentation nicknames) (flet ((find-symbols (import-package names option) (mapcan (lambda (name) (multiple-value-bind (symbol status) (find-symbol name import-package) (if (null status) (progn (cerror (format nil "Ignore (~S ~~*~~S ~~*~~S)" option) 'symbol-does-not-exist-error :package import-package :symbol-name name) '()) (list symbol)))) names))) (let ((package (find-package name))) (if package (let ((unuse-list (set-difference (mapcar (lambda (np) (if (stringp np) np (package-name np))) (package-use-list package)) uses :test (function string=)))) (rename-package package name nicknames) (unuse-package unuse-list package)) (setf package (make-package name :nicknames nicknames :use '()))) (setf (package-documentation package) documentation) ;; 1. :shadow and :shadowing-import-from. (shadow shadows package) (loop :for (import-package symbols) :in shadowing-imports :do (shadowing-import (find-symbols import-package symbols :shadowing-import-from) package)) ;; 2. :use. (use-package uses package) ;; 3. :import-from and :intern. (loop :for (import-package symbols) :in imports :do (import (find-symbols import-package symbols :import-from) package)) (dolist (name interns) (intern name package)) ;; 4. :export. (export (mapcar (lambda (name) (intern name package)) exports) package) package))) (defun classify-per-package (symbols) (let ((table (make-hash-table)) (result '())) (dolist (sym symbols) (push (symbol-name sym) (gethash (symbol-package sym) table '()))) ;; should do the same as defpackage/extract-from above. (maphash (lambda (k v) (push (list k v) result)) table) result)) ;; (set-equal (package-shadowing-symbols p) ;; (reduce 'union (cons (package-shadow-list p) ;; (mapcar 'rest (package-shadowing-import-list p))))) (defgeneric package-shadow-list (package)) (defmethod package-shadow-list (package) "Return the list of shadowed symbols (but not shadowing-imported ones)" (remove package (package-shadowing-symbols package) :test-not (function eql) :key (function symbol-package))) (defgeneric package-shadowing-import-list (package)) (defmethod package-shadowing-import-list (package) "Return a list of lists of shadowing-imports. Each sublist contains the package followed by its imported symbols." (classify-per-package (remove package (package-shadowing-symbols package) :key (function symbol-package)))) ;; NOTE: we don't know where the imported symbols were taken from, we ;; only know their home package. If they were imported from a ;; package that used them, or that imported them, then we won't ;; remember it, and will import them directly from their home. ;; This is probably not good. (defgeneric package-import-from-list (package)) (defmethod package-import-from-list (package) (let ((symbols '())) (with-package-iterator (it package :present) (loop (multiple-value-bind (got-it symbol kind home) (it) (declare (ignore kind)) (if got-it (unless (eq home package) (push symbol symbols)) (return (classify-per-package symbols)))))))) (defgeneric package-symbols (package)) (defmethod package-symbols (package) (let ((result '())) (with-package-iterator (it package :present) (loop (multiple-value-bind (got-it symbol kind home) (it) (declare (ignore kind)) (if got-it (when (eq home package) (push symbol result)) (return result))))))) (defgeneric package-export-list (package)) (defmethod package-export-list (package) (let ((result '())) (with-package-iterator (it package :external) (loop (multiple-value-bind (got-it symbol kind home) (it) (declare (ignore kind home)) (if got-it (push symbol result) (return result))))))) (defmethod make-load-form ((pack package) &optional environment) (declare (ignore environment)) `(%define-package ',(package-name pack) ',(mapcar (function symbol-name) (package-shadow-list pack)) ',(package-shadowing-import-list pack) ',(mapcar (function package-name) (package-use-list pack)) ',(package-import-from-list pack) ',(mapcar (function symbol-name) (package-symbols pack)) ',(mapcar (function symbol-name) (package-export-list pack)) ',(package-documentation pack) ',(package-nicknames pack))) (defmacro in-package (name) " DO: Sets the current *package* to the package designated by NAME. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/m_in_pkg.htm> " (let ((name (normalize-string-designator name))) `(eval-when (:compile-toplevel :load-toplevel :execute) (let ((new-package (normalize-package-designator ,name :if-package-does-not-exist :ignore-or-replace))) (when new-package (setf *package* new-package)))))) ;; To test: ;; (cl-user::cd #P"~/src/lisp/implementations/ansi-tests/") (mapc 'delete-file (directory "*.lx*")) (load "zpack-load.lsp") ;;;; THE END ;;;;
68,246
Common Lisp
.lisp
1,421
35.409571
158
0.555647
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
5de012a31c88d66e79281f6ce235511cde63686745c75d47aa8f49dc78da0fec
5,061
[ -1 ]
5,062
package-mac.lisp
informatimago_lisp/common-lisp/lisp-reader/package-mac.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: package-mac.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; This file contains the macros. ;;;; ;;;; ;;;; Implements the Common Lisp package system. ;;;; ;;;; <Xach> The basic idea of that file is that the semantics of the CL ;;;; package system can be implemented by an object with three special ;;;; kinds of tables (present-table, shadowing-table, external-table) ;;;; and two lists (used-packs, used-by-packs). The rest is ;;;; implementation. ;;;; ;;;;AUTHORS ;;;; <XACH> Zachary Beane <[email protected]>, ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2012-04-03 <PJB> Completed corrections to pass package ansi-tests. ;;;; 2012-03-30 <PJB> Added checks, made the API conforming to CL. ;;;; 2012-03-30 <PJB> Added this header; Removed "Z" prefix to CL ;;;; symbol names; shadowed and exported them. ;;;;BUGS ;;;; ;;;; make-load-form for packages should probably return two forms, since ;;;; packages can have circular dependencies. ;;;; ;;;; Are missing some standard restarts to correct ;;;; conflicts. (choosing one or the other symbol, doing the same ;;;; for all conflicts, etc). ;;;; ;;;;LEGAL ;;;; Copyright (c) 2012 Zachary Beane <[email protected]>, All Rights Reserved ;;;; Copyright (c) 2012 Pascal J. Bourguignon <[email protected]>, All Rights Reserved ;;;; ;;;; Redistribution and use in source and binary forms, with or without ;;;; modification, are permitted provided that the following conditions ;;;; are met: ;;;; ;;;; * Redistributions of source code must retain the above copyright ;;;; notice, this list of conditions and the following disclaimer. ;;;; ;;;; * Redistributions in binary form must reproduce the above ;;;; copyright notice, this list of conditions and the following ;;;; disclaimer in the documentation and/or other materials ;;;; provided with the distribution. ;;;; ;;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED ;;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ;;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ;;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ;;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ;;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ;;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (cl:in-package "COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.PACKAGE") (define-modify-macro appendf (&rest args) append "Append onto list") (defmacro with-package-iterator ((name package-list-form &rest symbol-types) &body declarations-body) " DO: Within the lexical scope of the body forms, the name is defined via macrolet such that successive invocations of (name) will return the symbols, one by one, from the packages in package-list. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/m_w_pkg_.htm> " (flet ((valid-symbol-type-p (object) (member object '(:internal :external :inherited ;; extensions: :present :shadowing)))) (cond ((null symbol-types) (error 'simple-program-error :format-control "Missing at least one symbol-type")) ((every (function valid-symbol-type-p) symbol-types)) (t (error 'simple-program-error :format-control "Invalid symbol-type: ~S" :format-arguments (list (find-if-not (function valid-symbol-type-p) symbol-types)))))) (let ((viterator (gensym "ITERATOR"))) `(let ((,viterator (make-package-iterator ,package-list-form ',symbol-types))) (macrolet ((,name () '(funcall ,viterator))) ,@declarations-body)))) (eval-when (:compile-toplevel :load-toplevel :execute) (defun declarations (body) (loop :for item :in body :while (and (listp item) (eql 'declare (car item))) :collect item)) (defun body (body) (loop :for items :on body :for item = (car items) :while (and (listp item) (eql 'declare (car item))) :finally (return items))) (defun generate-do-symbols-loop (var package result-form body symbol-types) (let ((iter (gensym "ITERATOR")) (got-it (gensym "GOT-IT")) (symbol (gensym "SYMBOL")) (vpack (gensym "PACKAGE"))) `(let ((,vpack (or ,package *package*))) (with-package-iterator (,iter ,vpack ,@symbol-types) (let (,var) ,@(declarations body) (loop (multiple-value-bind (,got-it ,symbol) (,iter) (if ,got-it (tagbody (setf ,var ,symbol) ,@(body body)) (progn (setf ,var nil) (return ,result-form)))))))))) );;eval-when (defmacro do-symbols ((var &optional package result-form) &body body) " DO: Iterate over all the symbols of the package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/m_do_sym.htm> " (generate-do-symbols-loop var package result-form body '(:internal :external :inherited))) (defmacro do-external-symbols ((var &optional package result-form) &body body) " DO: Iterate over all the external symbols of the package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/m_do_sym.htm> " (generate-do-symbols-loop var package result-form body '(:external))) (defmacro do-all-symbols ((var &optional result-form) &body body) " DO: Iterate over all the symbols of all the packages. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/m_do_sym.htm> " (generate-do-symbols-loop var '(list-all-packages) result-form body '(:internal :external :inherited))) (defmacro defpackage (defined-package-name &rest options) " DO: Define a new package. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/m_defpkg.htm> " ;; option::= (:nicknames nickname*)* | ;; (:documentation string) | ;; (:use package-name*)* | ;; (:shadow {symbol-name}*)* | ;; (:shadowing-import-from package-name {symbol-name}*)* | ;; (:import-from package-name {symbol-name}*)* | ;; (:export {symbol-name}*)* | ;; (:intern {symbol-name}*)* | ;; (:size integer) (dolist (option options) (unless (typep option 'list) (error 'simple-type-error :datum option :expected-type 'list :format-control "This implementation doesn't support any non-standard option such as ~S" :format-arguments (list option))) (unless (typep (car option) '(member :nicknames :documentation :use :shadow :shadowing-import-from :import-from :export :intern :size)) (error 'simple-type-error :datum (car option) :expected-type '(member :nicknames :documentation :use :shadow :shadowing-import-from :import-from :export :intern :size) :format-control "This implementation doesn't support any non-standard option such as ~S" :format-arguments (list option)))) (dolist (key '(:documentation :size)) (unless (<= (count key options :key (function first)) 1) (cerror "Ignore all but the first" 'simple-program-error :format-control "Too many ~S options given: ~S" :format-arguments (list key (remove key options :test-not (function eql) :key (function first)))))) (labels ((extract-strings (key) (delete-duplicates (normalize-weak-designator-of-list-of-string-designator (reduce (function append) (mapcar (function rest) (remove key options :key (function first) :test-not (function eql))))))) (extract-packages (key) (delete-duplicates (mapcan (lambda (package) (list (normalize-package-designator package :if-package-does-not-exist :ignore-or-replace :if-package-exists :string))) (reduce (function append) (mapcar (function rest) (remove key options :key (function first) :test-not (function eql))))))) (extract-from (key) (let ((table (make-hash-table)) (result '())) (dolist (entry (remove key options :key (function first) :test-not (function eql))) (let ((entry (rest entry))) (appendf (gethash (normalize-package-designator (first entry) :if-package-does-not-exist :error) table) (normalize-weak-designator-of-list-of-string-designator (rest entry))))) ;; should do the same as in classify-per-package below. (maphash (lambda (k v) (push (list k v) result)) table) result)) (check-string (object) (check-type object string) object) (extract-one-string (key) (let ((entries (remove key options :key (function first) :test-not (function eql)))) (let ((entry (first entries))) (when (rest entry) (assert (null (cddr entry)) () "Invalid :DOCUMENTATION option: it should contain only one string.") (check-string (second entry))))))) (let* ((shadows (extract-strings :shadow)) (shadowing-imports (extract-from :shadowing-import-from)) (import-froms (extract-from :import-from)) (interns (extract-strings :intern)) (exports (extract-strings :export))) (check-disjoints shadows shadowing-imports import-froms interns exports) `(eval-when (:execute :load-toplevel #-mocl :compile-toplevel) (%define-package ',(normalize-string-designator defined-package-name :if-not-a-string-designator :replace) ',shadows ',shadowing-imports ',(extract-packages :use) ',import-froms ',interns ',exports ',(extract-one-string :documentation) ',(extract-strings :nicknames)))))) ;;;; THE END ;;;;
11,908
Common Lisp
.lisp
241
39.029046
115
0.56456
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
8e8a91e539dd86903c89aa67d2fc81a898f6fce681a60ff3be8c098decaccc69
5,062
[ -1 ]
5,063
com.informatimago.common-lisp.lisp-reader.test.asd
informatimago_lisp/common-lisp/lisp-reader/com.informatimago.common-lisp.lisp-reader.test.asd
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: com.informatimago.common-lisp.lisp-reader.test.asd ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; ASD file to test the com.informatimago.common-lisp.lisp-reader library. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2015-01-25 <PJB> Created this .asd file. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see http://www.gnu.org/licenses/ ;;;;************************************************************************** (asdf:defsystem "com.informatimago.common-lisp.lisp-reader.test" ;; system attributes: :description "Tests the lisp-reader library." :author "Pascal J. Bourguignon <[email protected]>" :maintainer "Pascal J. Bourguignon <[email protected]>" :licence "AGPL3" ;; component attributes: :version "1.2.0" :properties ((#:author-email . "[email protected]") (#:date . "Winter 2015") ((#:albert #:output-dir) . "/tmp/documentation/com.informatimago.common-lisp.lisp-reader-test/") ((#:albert #:formats) . ("docbook")) ((#:albert #:docbook #:template) . "book") ((#:albert #:docbook #:bgcolor) . "white") ((#:albert #:docbook #:textcolor) . "black")) #+asdf-unicode :encoding #+asdf-unicode :utf-8 :depends-on ("com.informatimago.common-lisp.cesarum" "com.informatimago.common-lisp.lisp-reader") :components ((:file "reader-test" :depends-on ()) (:file "package-test" :depends-on ())) #+asdf3 :perform #+asdf3 (asdf:test-op (o s) (dolist (p '("COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.READER.TEST" "COM.INFORMATIMAGO.COMMON-LISP.LISP-READER.PACKAGE.TEST")) (let ((*package* (find-package p))) (uiop:symbol-call p "TEST/ALL"))))) ;;;; THE END ;;;;
2,964
Common Lisp
.lisp
60
43.3
120
0.563254
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
141a40b834c26d860b4cab693edd30b7a027fbcd2d81b52e0d62c7a30b6986d4
5,063
[ -1 ]
5,064
com.informatimago.common-lisp.lisp-reader.asd
informatimago_lisp/common-lisp/lisp-reader/com.informatimago.common-lisp.lisp-reader.asd
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: com.informatimago.common-lisp.lisp-reader.asd ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; ASD file to load the com.informatimago.common-lisp.lisp-reader library. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2012-04-03 <PJB> Added package.lisp (improved version of Xach Beane's zpack). ;;;; 2010-10-31 <PJB> Created this .asd file. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2010 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see http://www.gnu.org/licenses/ ;;;;************************************************************************** (asdf:defsystem "com.informatimago.common-lisp.lisp-reader" :description "Informatimago Common Lisp Reader -- A standard portable Common Lisp reader." :long-description " A customizable standard Common Lisp reader. We provide also an implementation of the Common Lisp package system (based on Xach Beane's zpack.lisp). " :author "Pascal J. Bourguignon <[email protected]>" :maintainer "Pascal J. Bourguignon <[email protected]>" :licence "AGPL3" ;; component attributes :version "1.4.0" :properties ((#:author-email . "[email protected]") (#:date . "Spring 2012") ((#:albert #:output-dir) . "/tmp/documentation/com.informatimago.common-lisp.lisp-reader/") ((#:albert #:formats) . ("docbook")) ((#:albert #:docbook #:template) . "book") ((#:albert #:docbook #:bgcolor) . "white") ((#:albert #:docbook #:textcolor) . "black")) #+asdf-unicode :encoding #+asdf-unicode :utf-8 :depends-on ("com.informatimago.common-lisp.lisp-sexp") :components ((:file "reader" :depends-on ()) (:file "package-pac" :depends-on ()) (:file "package-mac" :depends-on ("package-pac")) (:file "package-fun" :depends-on ("package-pac" "package-mac")) #-mocl (:file "package-def" :depends-on ("package-pac" "package-mac" "package-fun")) ) #+adsf3 :in-order-to #+adsf3 ((asdf:test-op (asdf:test-op "com.informatimago.common-lisp.lisp-reader.test")))) ;;;; THE END ;;;;
3,153
Common Lisp
.lisp
63
45.984127
115
0.594945
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
05aa818b389bbcdbce0a75db9e21d854d51098fd87bffc0e19f3097071fe0ad2
5,064
[ -1 ]
5,065
picture.lisp
informatimago_lisp/common-lisp/picture/picture.lisp
;;;; -*- coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: picture.lisp ;;;;LANGUAGE: common-lisp ;;;;SYSTEM: UNIX ;;;;USER-INTERFACE: UNIX ;;;;DESCRIPTION ;;;; ;;;; See defpackage documentation string. ;;;; ;;;;USAGE ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2004-08-13 <PJB> Removed the PICTURE- interface. ;;;; 2004-08-13 <PJB> Added multiline string support to DRAW-STRING. ;;;; 2003-01-08 <PJB> Added SPRITE and PICTURE classes. ;;;; 2002-11-16 <PJB> Created. ;;;;BUGS ;;;; - In sprites there should be one spot per frame. ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2002 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.PICTURE.PICTURE" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STRING") (:export "DRAW-ON-PICTURE" "SET-SPRITE-DATA" "FRAMES" "HEIGHT" "WIDTH" "SPRITE-TRANSPARENT-CHARACTER" "SPRITE-SPOT-Y" "SPRITE-SPOT-X" "SPRITE-DATA" "SPRITE-NAME" "SPRITE" "TO-STRING" "FRAME-RECT" "ERASE-RECT" "FILL-RECT" "DRAW-ARROW" "DRAW-LINE" "DRAW-STRING" "SIZE-STRING" "DRAW-POINT" "POINT-AT" "HEIGHT" "WIDTH" "PICTURE" "PICTURE-DATA" "PICTURE-BACKGROUND") (:documentation " This package exports functions to draw ASCII-ART pictures. ASCII-ART primitives. A picture is a matrix of characters. There are primitives to draw points, lines, rectangles, circles and ellipses, and strings. The coordinate system is the direct one: - x increases toward the right, - y increases toward the top. Bottom left is (0,0). License: AGPL3 Copyright Pascal J. Bourguignon 2002 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.PICTURE.PICTURE") (defgeneric to-string (pict) (:documentation " RETURN: A string containing the picture characters, (pict height) lines of (pict width) characters. ")) (defgeneric point-at (pict x y) (:documentation " PRE: inside = (AND (<= 0 X) (< X (WIDTH PICT)) (<= 0 Y) (< Y (HEIGHT PICT))) RETURN: inside ==> The character at coordinate (X,Y). (NOT inside) ==> (PICTURE-BACKGROUND PICT) ")) (defgeneric draw-point (pict x y foreground) (:documentation " PRE: inside = (AND (<= 0 X) (<= 0 Y) (< Y (HEIGHT PICT)) (< X (WIDTH PICT))) old-point = (POINT-AT PICT X Y) POST: inside ==> (EQ FOREGROUND (POINT-AT PICT X Y)) (NOT inside) ==> (EQ old-point (POINT-AT PICT X Y)) RETURN: PICT ")) (defgeneric size-string (pict string &key direction) (:documentation " RETURN: left bottom width height of the rectangle in which the STRING will be drawn by DRAW-STRING, relative to the point where it'll drawn. ")) (defgeneric draw-string (pict x y string &key direction) (:documentation " PRE: (MEMBER DIRECTION '(:E :W :N :S :NE :NW :SE :SW :NNE :NNW :SSE :SSW :ENE :ESE :WNW :WSW :LEFT :RIGHT :UP :DOWN NIL) :TEST (FUNCTION 'EQ)) DO: Draws the STRING in the given DIRECTION (default :RIGHT = :E). STRING may be anything, it will be formated with ~A. If it contains *NEW-LINE* characters then it's split and each line is written ''under'' the other, according to the DIRECTION. RETURN: PICT ")) (defgeneric draw-line (pict x y w h &key foreground) (:documentation " DO: Draw a line between (x,y) and (x+w-1,y+h-1) with the foreground character. RETURN: PICT ")) (defgeneric draw-arrow (pict x y w h &key tail) (:documentation " DO: Draw a line between (x,y) and (x+w-1,y+h-1) and end it with with an arrow tip. If TAIL is specified, draw it at the start. RETURN: PICT ")) (defgeneric fill-rect (pict x y w h &key foreground) (:documentation " DO: Fills the specified rectangle with FOREGROUND. RETURN: PICT ")) (defgeneric erase-rect (pict x y w h) (:documentation " DO: Fills the specified rectangle with (PICTURE-BACKGROUND PICT). RETURN: PICT ")) (defgeneric frame-rect (pict x y w h &key top-left top-right bottom-left bottom-right top bottom left right) (:documentation " DO: Draws the frame of a rect parallel to the axis whose diagonal is [(x,y),(x+w-1,y+h-1)]. RETURN: PICT ")) (defgeneric width (object) (:documentation " RETURN: The width of the object. ")) (defgeneric height (object) (:documentation " RETURN: The height of the object. ")) (defgeneric frames (sprite) (:documentation " RETURN: The number of frames in the SPRITE. ")) (defgeneric set-sprite-data (sprite data) (:documentation " DATA may be either: - a single string with frames separated by FF and lines separated by LF, - a list of string frames with lines separated by LF, - a list of list of string lines. - a list of list of list of single character strings or symbols or characters or character codes. - a tri-dimentional array of characters. RETURN: SPRITE ")) (defgeneric (setf sprite-data) (data sprite) (:method (data sprite) (set-sprite-data sprite data))) (defgeneric draw-on-picture (sprite pict x y &optional frame) (:documentation " DO: Draws the frame FRAME of the SPRITE on the picture PICT, placing the spot of the sprite at coordinates (X,Y). Transparent pixels are not drawn. ")) (defvar *form-feed* (string #\Page) "A string containing a single *form-feed* character.") (defvar *new-line* (string #\Newline) "A string containing a single *new-line* character.") ;; ------------------------------------------------------------------------ ;; PICTURE ;; ------------------------------------------------------------------------ (defgeneric picture-background (picture) (:documentation "The background character of the picture.")) (defgeneric picture-data (picture)) (pjb-defclass picture nil (:att picture-data (array character 2) "Picture data.") (:att picture-background character (character " ") "The background character.") (:doc "A picture is a bi-dimentional (y,x) array of characters.")) (defun to-char (stuff) (cond ((characterp stuff) stuff) ((stringp stuff) (aref stuff 0)) ((symbolp stuff) (aref (symbol-name stuff) 0)) ((numberp stuff) (code-char stuff)) (t (error "~S IS AN INVALID CHARACTER!" stuff)))) (defmethod initialize-instance ((self picture) &key (width 72) (height 24) (background " ")) " RETURN: SELF POST: for all X in [0..WIDTH-1], for all Y in [0..HEIGHT-1], (EQ (to-char background) (point-at self x y)) " (setf width (truncate width) height (truncate height) (picture-background self) (to-char background) (picture-data self) (make-array (list (truncate height) (truncate width)) :element-type 'character :initial-element (picture-background self))) self) (defmethod to-string ((self picture)) " RETURN: A string containing the picture character (pict height) lines of (pict width) characters, separated by a *new-line*. " (loop :with str = (make-string (* (height self) (1+ (width self)))) :with data = (picture-data self) :with i = 0 :with nl = (to-char *new-line*) :for y :from (1- (height self)) :downto 0 :do (progn (loop for x from 0 below (width self) do (setf (aref str i) (aref data y x)) (setf i (1+ i))) (setf (aref str i) nl) (setf i (1+ i))) :finally (return str))) (defmethod print-object ((self picture) stream) (princ (to-string self) stream) self) (defmethod width ((self picture)) " RETURN: The width of the picture. " (array-dimension (picture-data self) 1)) (defmethod height ((self picture)) " RETURN: The height of the picture. " (array-dimension (picture-data self) 0)) (defmethod point-at ((self picture) (x number) (y number)) " PRE: inside = (AND (<= 0 X) (< X (WIDTH SELF)) (<= 0 Y) (< Y (HEIGHT SELF))) RETURN: inside ==> The character at coordinate (X,Y). (NOT inside) ==> (PICTURE-BACKGROUND SELF) " (setq x (truncate x) y (truncate y)) (if (and (<= 0 x) (<= 0 y) (< y (height self)) (< x (width self))) (aref (picture-data self) y x) (picture-background self))) (defmethod draw-point ((self picture) (x number) (y number) foreground) " PRE: inside = (AND (<= 0 X) (<= 0 Y) (< Y (HEIGHT SELF)) (< X (WIDTH SELF))) old-point = (POINT-AT SELF X Y) POST: inside ==> (EQ FOREGROUND (POINT-AT SELF X Y)) (NOT inside) ==> (EQ old-point (POINT-AT SELF X Y)) RETURN: SELF " (setq x (truncate x) y (truncate y)) (setq foreground (to-char foreground)) (when (and (<= 0 x) (<= 0 y) (< y (height self)) (< x (width self))) (setf (aref (picture-data self) y x) foreground)) self) (defstruct (deplacement (:type list)) name dx dy line-dx line-dy) (defvar +deplacements+ '((:e 1 0 0 -1) (:right 1 0 0 -1) (:w -1 0 0 1) (:left -1 0 0 1) (:n 0 1 1 0) (:up 0 1 1 0) (:s 0 -1 -1 0) (:down 0 -1 -1 0) (:ne 1 1 1 -1) (:nw -1 1 1 1) (:se 1 -1 -1 -1) (:sw -1 -1 -1 1) (:nne 1 2 2 -1) (:nnw -1 2 2 1) (:sse 1 -2 -2 -1) (:ssw -1 -2 -1 2) (:ene 2 1 1 -2) (:ese 2 -1 -1 -2) (:wnw -2 1 1 2) (:wsw -2 -1 -1 2))) (defvar *string-cache* nil "PRIVATE") (defun string-cache-split (string separator) "PRIVATE" (unless (and (eq string (first *string-cache*)) (eq separator (second *string-cache*))) (setf *string-cache* (list string separator (split-string string separator)))) (third *string-cache*)) (defmethod size-string ((self picture) string &key (direction :e)) " RETURN: left bottom width height of the rectangle in which the STRING will be drawn by DRAW-STRING, relative to the point where it'll drawn. " (declare (ignore self)) (labels ( ;; (sign (mag) (cond ((= 0 mag) 0) ((< mag 0) -1) (t +1))) (off (amp dep) (* (1- amp) dep))) (let* ((depl (assoc direction +deplacements+)) (lines (string-cache-split string *new-line*)) (width (reduce (function max) lines :key (function length) :initial-value 0)) (height (length lines)) (lb-x 0) (lb-y 0) (lt-x (off height (deplacement-line-dx depl))) (lt-y (off height (deplacement-line-dy depl))) (rb-x (off width (deplacement-dx depl))) (rb-y (off width (deplacement-dy depl))) (rt-x (+ rb-x lt-x)) (rt-y (+ rb-y lt-y)) (left (min lb-x lt-x rb-x rt-x)) (bottom (min lb-y lt-y rb-y rt-y)) (right (max lb-x lt-x rb-x rt-x)) (top (max lb-y lt-y rb-y rt-y))) (values left bottom (- right left -1) (- top bottom -1))))) (defmethod draw-string ((self picture) (x number) (y number) string &key (direction :e)) " PRE: (MEMBER DIRECTION '(:E :W :N :S :NE :NW :SE :SW :NNE :NNW :SSE :SSW :ENE :ESE :WNW :WSW :LEFT :RIGHT :UP :DOWN NIL) :TEST (FUNCTION 'EQ)) DO: Draws the STRING in the given DIRECTION (default :RIGHT = :E). STRING may be anything, it will be formated with ~A. If it contains *NEW-LINE* characters then it's split and each line is written ''under'' the other, according to the DIRECTION. RETURN: SELF NOTE: A future implementation won't use DRAW-POINT for performance. " (setq x (truncate x) y (truncate y)) (unless (stringp string) (setq string (format nil "~A" string))) (let ((lines (string-cache-split string *new-line*)) (depl (assoc direction +deplacements+))) (if (cdr lines) (do ((dlx (deplacement-line-dx depl)) (dly (deplacement-line-dy depl)) (x x (+ x dlx)) (y y (+ y dly)) (lines lines (cdr lines))) ((null lines) self) (draw-string self x y (car lines) :direction direction)) (do ((dx (deplacement-dx depl)) (dy (deplacement-dy depl)) (i 0 (1+ i)) (x x (+ x dx)) (y y (+ y dy))) ((>= i (length string)) self) (draw-point self x y (aref string i)))))) ;;DRAW-STRING (defmethod draw-line ((self picture) (x number) (y number) (w number) (h number) &key (foreground "*")) " DO: Draw a line between (x,y) and (x+w-1,y+h-1) with the foreground character. RETURN: SELF NOTE: A future implementation won't use DRAW-POINT for performance. " (setq x (truncate x) y (truncate y) w (truncate w) h (truncate h)) (setq foreground (to-char foreground)) ;; We should compute the clipping here. (let ((dx (abs w)) (dy (abs h)) (xinc (if (> w 0) 1 -1)) (yinc (if (> h 0) 1 -1)) cumul) (when (/= 0 dx) (setq dx (1- dx))) (when (/= 0 dy) (setq dy (1- dy))) (draw-point self x y foreground) (if (> dx dy) (progn (setq cumul (floor (/ dx 2))) (loop for i from 1 to dx do (setq x (+ x xinc) cumul (+ cumul dy)) (when (>= cumul dx) (setq cumul (- cumul dx) y (+ y yinc))) (draw-point self x y foreground) )) (progn (setq cumul (floor (/ dy 2))) (loop for i from 1 to dy do (setq y (+ y yinc) cumul (+ cumul dx)) (when (>= cumul dy) (setq cumul (- cumul dy) x (+ x xinc))) (draw-point self x y foreground) )))) self) (defmethod draw-arrow ((pict picture) (x number) (y number) (w number) (h number) &key tail) (draw-line pict x y w h :foreground (if (= 0 w) "|" "-")) (draw-point pict (+ x w) (+ y h) (if (= 0 w) (if (< 0 h) "^" "v") (if (< 0 w) ">" "<"))) (when tail (draw-point pict x y tail)) pict) (defmethod fill-rect ((self picture) (x number) (y number) (w number) (h number) &key (foreground "*")) " DO: Fills the specified rectangle with FOREGROUND. RETURN: SELF " (setf x (truncate x) y (truncate y) w (truncate w) h (truncate h) foreground (to-char foreground)) (dotimes (i (1- h)) (draw-line self x y w 0 :foreground foreground) (incf y)) self) (defmethod erase-rect ((self picture) (x number) (y number) (w number) (h number)) " DO: Fills the specified rectangle with (PICTURE-BACKGROUND SELF). RETURN: SELF " (fill-rect self x y w h :foreground (picture-background self))) (defmethod frame-rect ((self picture) (x number) (y number) (w number) (h number) &key (top-left "+") (top-right "+") (bottom-left "+") (bottom-right "+") (top "-") (bottom "-") (left "|") (right "|")) " DO: Draws the frame of a rect parallel to the axis whose diagonal is [(x,y),(x+w-1,y+h-1)]. RETURN: SELF NOTE: A future implementation won't use DRAW-POINT for performance. " (setf x (truncate x) y (truncate y) w (1- (truncate w)) h (1- (truncate h)) top-left (to-char top-left) top (to-char top) top-right (to-char top-right) left (to-char left) right (to-char right) bottom-left (to-char bottom-left) bottom (to-char bottom) bottom-right (to-char bottom-right)) (draw-line self x y w 0 :foreground bottom) (draw-line self x (+ y h) w 0 :foreground top) (draw-line self x y 0 h :foreground left) (draw-line self (+ x w) y 0 h :foreground right) (draw-point self x y bottom-left) (draw-point self (+ x w) y bottom-right) (draw-point self x (+ y h) top-left) (draw-point self (+ x w) (+ y h) top-right) self) ;;FRAME-RECT ;; ------------------------------------------------------------------------ ;; SPRITE ;; ------------------------------------------------------------------------ (defgeneric sprite-name (sprite) (:documentation "Name of this sprite.")) (defgeneric sprite-spot-x (sprite) (:documentation "X coordinate of the spot of the sprite.")) (defgeneric sprite-spot-y (sprite) (:documentation "Y coordinate of the spot of the sprite")) (defgeneric sprite-transparent-character (sprite) (:documentation "The transparent character of the sprite.")) (pjb-defclass sprite nil (:att sprite-name string "sprite" "Name of this sprite.") (:att sprite-data (array character 3) "Sprite data.") (:att sprite-spot-x fixnum 0 "X coordinate of spot.") (:att sprite-spot-y fixnum 0 "Y coordinate of spot.") (:att sprite-transparent-character character (character " ") "The transparent character.") (:doc "A sprite is a tri-dimentional (time,y,x) array of characters.")) (defmethod width ((self sprite)) " RETURN: The width of the sprite. " (array-dimension (sprite-data self) 2)) (defmethod height ((self sprite)) " RETURN: The height of the sprite. " (array-dimension (sprite-data self) 1)) (defmethod frames ((self sprite)) " RETURN: The number of frames of the sprite. " (array-dimension (sprite-data self) 0)) (defmethod set-sprite-data ((self sprite) sprite-data) " SPRITE-DATA may be either: - a single string with frames separated by FF and lines separated by LF, - a list of string frames with lines separated by LF, - a list of list of string lines. - a list of list of list of single character strings or symbols or characters or character codes. - a tri-dimentional array of characters. RETURN: SELF " (cond ((stringp sprite-data) (set-sprite-data self (mapcar (lambda (frame) (split-string frame *new-line*)) (split-string sprite-data *form-feed*)))) ((and (consp sprite-data) (stringp (car sprite-data))) (set-sprite-data self (mapcar (lambda (frame) (split-string frame *new-line*)) sprite-data))) ((and (consp sprite-data) (consp (car sprite-data)) (or (stringp (caar sprite-data)) (consp (caar sprite-data)))) (let ((new-data (make-array (list (length sprite-data) (apply (function max) (mapcar (function length) sprite-data)) (apply (function max) (apply (function append) (mapcar (lambda (l) (mapcar (function length) l)) sprite-data)))) :element-type 'character)) (transparent (sprite-transparent-character self))) (loop for f from 0 below (array-dimension new-data 0) for frames = sprite-data then (cdr frames) do (loop for y from (1- (array-dimension new-data 1)) downto 0 for lines = (car frames) then (cdr lines) do (if (stringp (car lines)) (loop for x from 0 below (array-dimension new-data 2) for cur-char = (if (< x (length (car lines))) (aref (car lines) x) transparent) do (setf (aref new-data f y x) (cond ((null cur-char) transparent) ((characterp cur-char) cur-char) ((stringp cur-char) (aref cur-char 0)) ((numberp cur-char) (code-char cur-char)) ((symbolp cur-char) (aref (sprite-name cur-char) 0)) (t (error "~S is not a character!" cur-char)) ))) (loop for x from 0 below (array-dimension new-data 2) for characters = (car lines) then (cdr characters) for cur-char = (car characters) then (car characters) do (setf (aref new-data f y x) (cond ((null cur-char) transparent) ((characterp cur-char) cur-char) ((stringp cur-char) (aref cur-char 0)) ((numberp cur-char) (code-char cur-char)) ((symbolp cur-char) (aref (sprite-name cur-char) 0)) (t (error "~S is not a character!" cur-char)) )))))) (setf (sprite-data self) new-data))) ((arrayp sprite-data) (setf (sprite-data self) sprite-data))) self) (defmethod draw-on-picture ((self sprite) (pict picture) (x number) (y number) &optional (frame 0)) " DO: Draws the frame FRAME of the sprite on the picture PICT, placing the spot of the sprite at coordinates (X,Y). Sprite-Transparent pixels are not drawn. " (setf x (truncate x) y (truncate y) frame (truncate frame)) (setf x (- x (sprite-spot-x self)) y (- y (sprite-spot-y self))) (loop :with sprite-data := (sprite-data self) :with transparent := (sprite-transparent-character self) :for j :from 0 :below (height self) :for yj = (+ y j) :then (+ y j) :do (loop :for i :from 0 :below (width self) :for pixel := (aref sprite-data frame j i) then (aref sprite-data frame j i) :unless (eq pixel transparent) :do (draw-point pict (+ x i) yj pixel))) self) ;;;; THE END ;;;;
25,247
Common Lisp
.lisp
588
33.843537
108
0.542478
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
d1c8abba41e6b07b121c3a664a6cc209ee42e29a214dd3b78cffa485c6309d28
5,065
[ -1 ]
5,066
picture-test.lisp
informatimago_lisp/common-lisp/picture/picture-test.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: picture-test.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Test picture.lisp. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2015-02-25 <PJB> Extracted from picture.lisp ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.PICTURE.PICTURE.TEST" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SIMPLE-TEST" "COM.INFORMATIMAGO.COMMON-LISP.PICTURE.PICTURE") (:export "TEST/ALL")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.PICTURE.PICTURE.TEST") (defun test-picture-object () " DO: Creates a test picture. RETURN: the picture string. " (let ((p (make-instance 'picture :width 40 :height 20 :background "."))) (frame-rect p 0 0 39 19) (draw-string p 21 10 "East") (draw-string p 19 10 "West" :direction :w) (draw-string p 20 11 "North" :direction :n) (draw-string p 20 9 "South" :direction :s) (draw-string p 21 11 "North-East" :direction :ene) (draw-string p 19 11 "North-West" :direction :wnw) (draw-string p 21 9 "South-East" :direction :ese) (draw-string p 19 9 "South-West" :direction :wsw) (erase-rect p 2 10 5 3) (fill-rect p 30 10 6 4 :foreground ":") (frame-rect p 30 10 6 4 :top-left "/" :top-right "\\" :bottom-left "\\" :bottom-right "/" :left "<" :top "^" :bottom "v" :right ">") (draw-line p 0 0 40 20 :foreground "$") (draw-point p 20 10 "*") (prin1-to-string p))) (define-test test/picture-object () (assert-true (string= (test-picture-object) "...s.................................s$$ +----e-----------------------------a$$+. |......W.........................E$$..|. |........-.....................-$$....|. |..........h........h........h$$......|. |............t......t......t$$........|. |..............r....r....r$$../^^^^\\..|. |................o..o..o$$....<::::>..|. |..................NNN$$......<::::>..|. |...............tseW*$ast.....\\vvvv/..|. |.................$$SS................|. |...............$$..o..o..............|. |.............$$....u....u............|. |...........$$......t......t..........|. |.........$$........h........h........|. |.......$$.....................-......|. |.....$$.........................E....|. |...$$.............................a..|. |.$$.................................s|. $$------------------------------------+t "))) (define-test test/all () (test/picture-object)) ;;;; THE END ;;;;
3,694
Common Lisp
.lisp
90
38.3
83
0.483709
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
ab8e83fd2017ded5376456dcfaacc9c128e9c3eda6c4598e07d7b46ba6e93bfe
5,066
[ -1 ]
5,067
cons-to-ascii.lisp
informatimago_lisp/common-lisp/picture/cons-to-ascii.lisp
;;; -*- coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: cons-to-ascii.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; This packages draws ASCII art cons cell diagrams. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2005-08-19 <PJB> Added PRINT-CONS and PRINT-IDENTIFIED-CONS. ;;;; 2004-09-24 <PJB> Corrected DRAW-LISP. ;;;; 2004-08-14 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2004 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.PICTURE.CONS-TO-ASCII" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STRING" "COM.INFORMATIMAGO.COMMON-LISP.PICTURE.PICTURE") (:export "PRINT-IDENTIFIED-CONSES" "PRINT-CONSES" "DRAW-CELL" "DRAW-LIST") (:documentation " This packages draws ASCII art cons cell diagrams. License: AGPL3 Copyright Pascal J. Bourguignon 2004 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.PICTURE.CONS-TO-ASCII") (defgeneric size-cell (pict cell &optional max-width)) (defgeneric draw-cons (pict x y cell)) (defgeneric draw-cell (pict x y cell) (:documentation "Draws the CELL in the picture PICT, at coordinates X,Y")) (defgeneric draw-decorated-cell (pict x y dec)) (defvar +cell-width+ 12 "+---+---+") (defmethod size-cell ((pict picture) cell &optional (max-width (width pict))) (cond ((null cell) (values :absent 0 0)) ((atom cell) (let ((rep (format nil "~S" cell))) (multiple-value-bind (l b w h) (size-string pict rep) (declare (ignore l b)) (values :horizontal (+ w 4) (+ h 2))))) (t ;; first compute horizontal layout ;; if too large, then compute a vertical layout (could still be too large). (let ((width 0) (height 0) (dispo)) (when (<= (length cell) (truncate max-width +cell-width+)) ;; horizontal (setf dispo :horizontal) (do ((items cell (cdr items)) (i 0 (1+ i))) ((null items)) (multiple-value-bind (d w h) (size-cell pict (car items)) (declare (ignore d)) (setf width (max width (+ w (* i +cell-width+)))) (setf height (max height (+ h 5)))))) (when (<= (width pict) width) ;; vertical ;; (setf dispo :vertical) ) (values dispo width height))))) ;;SIZE-CELL (defvar +none+ (cons nil nil)) (defclass decoration () ((w :accessor w :initarg :w :initform 0 :type integer) (h :accessor h :initarg :h :initform 0 :type integer) (x :accessor x :initarg :x :initform 0 :type integer) (y :accessor y :initarg :y :initform 0 :type integer))) ;;DECORATION (defclass cons-decoration (decoration) ((cell :accessor cell-value :initarg :cell :initform +none+ :type cons) (car :accessor car-deco :initarg :car :initform nil :type (or null decoration)) (cdr :accessor cdr-deco :initarg :cdr :initform nil :type (or null decoration)))) ;;CONS-DECORATION (defmethod print-object ((self cons-decoration) stream) (print (list :cons-decoration (cell-value self) :car (car-deco self) :cdr (cdr-deco self) :w (w self) :h (h self) :x (x self) :y (y self)) stream)) (defclass atom-decoration (decoration) ((atom :accessor atom-value :initarg :atom :initform nil :type atom))) (defmethod print-object ((self atom-decoration) stream) (print (list :atom-decoration (atom-value self) :w (w self) :h (h self) :x (x self) :y (y self)) stream)) (defvar +picture-instance+ (make-instance 'picture :width 1 :height 1)) (defvar +nil-decoration+ (make-instance 'atom-decoration)) (defmethod initialize-instance ((self atom-decoration) &rest args) (declare (ignore args)) (call-next-method) (multiple-value-bind (d w h) (size-cell +picture-instance+ (atom-value self)) (declare (ignore d)) (setf (w self) w (h self) h)) self) ;;INITIALIZE-INSTANCE (defun decorate (cell) " DOES: Converts the list CELL to a decorated list. The building of the decoration is done by the make-decoration function. RETURN: The decorated list. " (cond ((null cell) +nil-decoration+) ((consp cell) (let ((dec (make-instance 'cons-decoration :cell cell :car (decorate (car cell)) :cdr (decorate (cdr cell))))) ;; Coordinates: ;; #---+---+ ;; $NIL| * |--> # = (0,0) ; $ = (0,-1) ;; +---+---+ (when (cdr cell) ;; let's compute relative coordinates of (cdr cell) (setf (x (cdr-deco dec)) 12 (y (cdr-deco dec)) 0)) (when (car cell) ;; slightly more complex: if width of (car cell) is > 12 ;; then move it down under the (cdr cell), unless it's null. (if (or (null (cdr cell)) (<= (w (car-deco dec)) 12)) ;; no problem: (setf (x (car-deco dec)) 0 (y (car-deco dec)) -5) (setf (x (car-deco dec)) 0 (y (car-deco dec)) (min -5 (- (y (cdr-deco dec)) (h (cdr-deco dec)) 1))))) (setf (w dec) (if (null (cdr cell)) (max (+ (x (car-deco dec)) (w (car-deco dec))) 9) (max (+ (x (car-deco dec)) (w (car-deco dec))) (+ (x (cdr-deco dec)) (w (cdr-deco dec))))) (h dec) (if (null (car cell)) (max (- (h (cdr-deco dec)) (y (cdr-deco dec))) 3) (max (- (h (car-deco dec)) (y (car-deco dec))) (- (h (cdr-deco dec)) (y (cdr-deco dec)))))) dec)) (t (make-instance 'atom-decoration :atom cell)))) ;;DECORATE (defmethod draw-cons ((pict picture) x y cell) ;; @---+---+ ;; | * |NIL| @ = (0,0) ;; +---+---+ (frame-rect pict x (- y 2) 5 3) (frame-rect pict (+ x 4) (- y 2) 5 3) (draw-string pict (+ x 1) (1- y) (if (car cell) " * " "NIL")) (draw-string pict (+ x 5) (1- y) (if (cdr cell) " * " "NIL")) pict) ;;DRAW-CONS (defmethod draw-cell ((pict picture) x y cell) (draw-decorated-cell pict x y (decorate cell))) (defmethod draw-decorated-cell ((pict picture) x y (dec atom-decoration)) (let ((rep (format nil "~S" (atom-value dec)))) (frame-rect pict x (- y (h dec) -1) (w dec) (h dec)) (draw-string pict (+ x 2) (- y 1) rep))) (defmethod draw-decorated-cell ((pict picture) x y (dec cons-decoration)) ;; +---+---+ +---+---+ +---+---+ +---+---+ ;; | * | * |-->| * | * |-->| * | * |-->| * |NIL| ;; +---+---+ +---+---+ +---+---+ +---+---+ ;; | | | | ;; V V | V ;; +---+ +----+ | +---+---+ +------+ ;; | A | | 42 | | |NIL| * |-->| :FIN | ;; +---+ +----+ | +---+---+ +------+ ;; V ;; +--------------------+ ;; | "Es una cabronada" | ;; +--------------------+ ;;(if (<= (length cell) (truncate (width pict) +cell-width+)) ;; horizontal (draw-cons pict x y (cell-value dec)) (when (cdr (cell-value dec)) (draw-arrow pict (+ x 9) (- y 1) 2 0) (draw-decorated-cell pict (+ x (x (cdr-deco dec))) (+ y (y (cdr-deco dec))) (cdr-deco dec))) (when (car (cell-value dec)) (draw-arrow pict (+ x 2) (- y 3) 0 (+ (y (car-deco dec)) 4)) (draw-decorated-cell pict (+ x (x (car-deco dec))) (+ y (y (car-deco dec))) (car-deco dec))) ) ;;DRAW-DECORATED-CELL (defun draw-list (list &key (title (format nil "~(~S~)" list))) " DO: Draws the LIST structure. TITLE: An alternative title. RETURN: A string containing the drawing. EXAMPLE: (draw-list '(if (< a b) (decf b a) (decf a b))) returns: \"+-----------------------------------------------------------------------+ | (if (< a b) (decf b a) (decf a b)) | | | | +---+---+ +---+---+ +---+---+ +---+---+ | | | * | * |-->| * | * |-->| * | * |-->| * |NIL| | | +---+---+ +---+---+ +---+---+ +---+---+ | | | | | | | | v | | v | | +----+ | | +---+---+ +---+---+ +---+---+ | | | if | | | | * | * |-->| * | * |-->| * |NIL| | | +----+ | | +---+---+ +---+---+ +---+---+ | | | | | | | | | | | v v v | | | | +------+ +---+ +---+ | | | | | decf | | a | | b | | | | | +------+ +---+ +---+ | | | v | | | +---+---+ +---+---+ +---+---+ | | | | * | * |-->| * | * |-->| * |NIL| | | | +---+---+ +---+---+ +---+---+ | | | | | | | | | v v v | | | +------+ +---+ +---+ | | | | decf | | b | | a | | | | +------+ +---+ +---+ | | v | | +---+---+ +---+---+ +---+---+ | | | * | * |-->| * | * |-->| * |NIL| | | +---+---+ +---+---+ +---+---+ | | | | | | | v v v | | +---+ +---+ +---+ | | | < | | a | | b | | | +---+ +---+ +---+ | +-----------------------------------------------------------------------+\" " (let* ((dec (decorate list)) (tw 0) (th 0) (pic)) (multiple-value-setq (tw th) (size-string +picture-instance+ title)) (setf th (abs th)) (setf pic (make-instance 'picture :width (+ 4 (max tw (w dec))) :height (+ 4 th (h dec)))) (frame-rect pic 0 0 (width pic) (height pic)) (when title (draw-string pic 2 (- (height pic) 2) title)) (draw-decorated-cell pic 2 (- (height pic) 4 th) dec) pic)) ;;DRAW-LIST (defun transpose-tree (tree) (if (atom tree) tree (cons (transpose-tree (cdr tree)) (transpose-tree (car tree))))) #|| (load "~/src/common/common-lisp/picture.lisp") (use-package "COM.INFORMATIMAGO.COMMON-LISP.PICTURE.PICTURE") (SETQ P (MAKE-instance 'PICTURE :width 72 :height 20 :background " ")) (frame-rect p 0 0 72 20) (draw-string p 30 10 (format nil "Hello~%world~%howdy?")) (dolist (dir '(:E :ENE :NE :NNE :N :NNW :NW :WNW :W :WSW :SW :SSW :S :SSE :SE :ESE)) (progn (SETQ P (frame-rect (MAKE-instance 'PICTURE :width 72 :height 30 :background " ") 0 0 72 30)) (draw-string p (setq x 30) (setq y 15) (setq s (format nil "Hello.~%world~%howdy?")) :direction dir) (multiple-value-bind (l b w h) (size-string p s :direction dir) (frame-rect p (+ x l -1) (+ y b -1) (+ w 2) (+ h 2)) (draw-string p 1 1 (list :l l :b b :w w :h h)) (draw-string p 1 2 (list :x (+ x l) :y (+ y b) :w w :h h)) (draw-line p 3 15 4 0) (fill-rect p 3 8 4 4 :foreground "*") (frame-rect p 1 6 8 8) (frame-rect p 10 8 4 4)(print p)))) (progn (SETQ P (frame-rect (MAKE-instance 'PICTURE :width 72 :height 30 :background " ") 0 0 72 30)) (draw-arrow p 14 4 -10 0) (draw-arrow p 15 4 0 -2 :tail "*") (draw-arrow p 20 10 10 0 ) (draw-arrow p 20 10 0 8 :tail "+") p) (decorate '((a b) (42 "hello" (:a b)) #(1 2 3 4 5 6))) (draw-list '((a b) (42 "hello" (:a b)) #(1 2 3 4 5 6)) "Sample") (progn (SETQ P (frame-rect (MAKE-instance 'PICTURE :width 72 :height 30 :background " ") 0 0 72 30)) (draw-cell p 2 25 '((a b) (42 "hello" (:a b)) #(1 2 3 4 5 6))) p) (draw-list #1='((a b) (42 "hello" (:a b)) #(1 2 3 4 5 6)) :title (format nil "~S" #1#)) (draw-list #1='(defun fact (n) (if (< 1 n) (* n (fact (1- n))) 1)) :title (format nil "~S" #1#)) (draw-list #1='(defun square (n) (* n n)) :title (format nil "~S" #1#)) ||# (defun print-tree (tree &optional (stream *standard-output*)) ;; WARNING: doesn't handle circles nor identify EQ subtrees. (cond ((null tree) (princ "()")) ((atom tree) (princ tree stream)) (t (princ "(" stream) (dolist (item (butlast tree)) (print-tree item stream) (princ " " stream)) (print-tree (car (last tree)) stream) (princ ")" stream))) tree) (defun print-conses (tree &optional (stream *standard-output*)) " DO: Print the TREE with all cons cells as dotted pairs. TREE: A sexp. STREAM: The output stream (default: *STANDARD-OUTPUT*) WARNING: doesn't handle circles nor identify EQ subtrees. EXAMPLE: (print-conses '(a b c d)) prints: (a . (b . (c . (d . ())))) " (cond ((null tree) (princ "()")) ((atom tree) (princ tree stream) (princ " " stream)) (t (princ "(" stream) (print-conses (car tree) stream) (princ " . " stream) (print-conses (cdr tree) stream) (princ ")" stream))) tree) #|| [31]> (print-conses '(a b c)) (A . (B . (C . ()))) (A B C) [32]> (print-conses '((a) (b) (c))) ((A . ()) . ((B . ()) . ((C . ()) . ()))) ((A) (B) (C)) ||# (defun find-nodes (tree table) (cond ((null tree) table) ((gethash tree table) (incf (gethash tree table)) table) ((atom tree) (incf (gethash tree table 0)) table) (t (incf (gethash tree table 0)) (find-nodes (cdr tree) (find-nodes (car tree) table))))) (defun print-identified-conses (tree &optional (stream *standard-output*)) " DO: Print the TREE with all cons cells identified with a #n= notation. TREE: A sexp. STREAM: The output stream (default: *STANDARD-OUTPUT*) NOTE: Handles circles in the cons structure, but not thru the other atoms (vectors, structures, objects). EXAMPLE: (print-identified-conses '((a . b) #1=(c . d) (e . #1#))) prints: ((a . b) . (#1=(c . d) . ((e . #1# ) . ()))) " (let ((table (find-nodes tree (make-hash-table :test (function eq)))) (index 0)) (maphash (lambda (k v) (if (= 1 v) (remhash k table) (setf (gethash k table) (- (incf index))))) table) (labels ((print-node (node) (if (null node) (princ "()") (let ((index (gethash node table))) (if (and index (plusp index)) (format stream "#~A# " index) (progn (when index (setf (gethash node table) (- index)) (format stream "#~A=" (- index))) (if (atom node) (princ node stream) (progn (princ "(" stream) (print-node (car node)) (princ " . " stream) (print-node (cdr node)) (princ ")" stream))))))))) (print-node tree) tree))) #|| (defparameter tree '#2=(#1=(a) (b c a #1# #2#) . #2#)) (setf *print-circles* t) (print-identified-conses tree) #3=(#2=(#1=A . ()) . ((B . (C . (#1# . (#2# . (#3# . ()))))) . #3# )) #1=(#2=(A) (B C A #2# #1#) . #1#) ||# ;;;; THE END ;;;;
18,703
Common Lisp
.lisp
388
40.510309
634
0.449493
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
231ea52c1cea28df31c85e48c292678aaeb9d0aa375ab86cfe36463e0d359dea
5,067
[ -1 ]
5,068
tree-to-ascii.lisp
informatimago_lisp/common-lisp/picture/tree-to-ascii.lisp
;;;; -*- coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: tree-to-ascii.lisp ;;;;LANGUAGE: common-lisp ;;;;SYSTEM: common-lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; See defpackage documentation string. ;;;; ;;;;USAGE ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2002-11-16 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2002 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.PICTURE.TREE-TO-ASCII" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.PICTURE.PICTURE") (:export "TREE-TO-ASCII-DRAW-TO-PICT" "TREE-DECORATE" "TREE-TO-ASCII") (:documentation " This package draws a tree onto an ASCII-ART picture The tree drawn is a list whose car is the node displayed, and whose cdr is the list of children. License: AGPL3 Copyright Pascal J. Bourguignon 2002 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.PICTURE.TREE-TO-ASCII") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; tree (list based) ;; ----------------- ;; Each node is a consp whose car is the node value, ;; and whose cdr is the list of children. ;; (defun tree-decorate (tree make-decoration) " DO: Converts the list based tree to a decorated tree. The building of the decoration is done by the make-decoration function. RETURN: The decorated tree. " (declare (type (function (list list) list) make-decoration)) (if (consp tree) (funcall make-decoration (car tree) (loop for sub-tree in (cdr tree) collect (tree-decorate sub-tree make-decoration) into decorated finally (return decorated))) (funcall make-decoration tree nil))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; tree-to-ascci decorated tree ;; ---------------------------- ;; Each node is an array of 4 entries: ;; node, children list, formated string, and box array ;; (defstruct tree-to-ascii (node nil) (children nil) (formated nil) (box nil)) (defstruct tree-to-ascii-box (width 0) (height 0) (base 0)) ;;; (DEFMACRO TREE-TO-ASCII-NODE (R) `(AREF ,R 0)) ;;; (DEFMACRO TREE-TO-ASCII-CHILDREN (R) `(AREF ,R 1)) ;;; (DEFMACRO TREE-TO-ASCII-FORMATED (R) `(AREF ,R 2)) ;;; (DEFMACRO TREE-TO-ASCII-BOX (R) `(AREF ,R 3)) ;;; (DEFMACRO TREE-TO-ASCII-NODE-SET (R VAL) `(SETF (AREF ,R 0) ,VAL)) ;;; (DEFMACRO TREE-TO-ASCII-CHILDREN-SET (R VAL) `(SETF (AREF ,R 1) ,VAL)) ;;; (DEFMACRO TREE-TO-ASCII-FORMATED-SET (R VAL) `(SETF (AREF ,R 2) ,VAL)) ;;; (DEFMACRO TREE-TO-ASCII-BOX-SET (R VAL) `(SETF (AREF ,R 3) ,VAL)) ;;; (DEFSETF TREE-TO-ASCII-NODE TREE-TO-ASCII-NODE-SET) ;;; (DEFSETF TREE-TO-ASCII-CHILDREN TREE-TO-ASCII-CHILDREN-SET) ;;; (DEFSETF TREE-TO-ASCII-FORMATED TREE-TO-ASCII-FORMATED-SET) ;;; (DEFSETF TREE-TO-ASCII-BOX TREE-TO-ASCII-BOX-SET) (defun tree-to-ascii-make-decoration (node children) " DO: Builds a new decorated node: an array of 4 entries: node, children list, formated string, and box array RETURN: The decorated node. " (make-tree-to-ascii :node node :children children) ;; (LET ((DECORATION (MAKE-ARRAY '(4)))) ;; (SETF (TREE-TO-ASCII-NODE DECORATION) NODE) ;; (SETF (TREE-TO-ASCII-CHILDREN DECORATION) CHILDREN) ;; DECORATION) ) ;;; (DEFMACRO TREE-TO-ASCII-BOX-WIDTH (B) `(AREF ,B 0)) ;;; (DEFMACRO TREE-TO-ASCII-BOX-HEIGHT (B) `(AREF ,B 1)) ;;; (DEFMACRO TREE-TO-ASCII-BOX-BASE (B) `(AREF ,B 2)) ;;; (DEFMACRO TREE-TO-ASCII-BOX-WIDTH-SET (B VAL) `(SETF (AREF ,B 0) ,VAL)) ;;; (DEFMACRO TREE-TO-ASCII-BOX-HEIGHT-SET (B VAL) `(SETF (AREF ,B 1) ,VAL)) ;;; (DEFMACRO TREE-TO-ASCII-BOX-BASE-SET (B VAL) `(SETF (AREF ,B 2) ,VAL)) ;;; (DEFSETF TREE-TO-ASCII-BOX-WIDTH TREE-TO-ASCII-BOX-WIDTH-SET) ;;; (DEFSETF TREE-TO-ASCII-BOX-HEIGHT TREE-TO-ASCII-BOX-HEIGHT-SET) ;;; (DEFSETF TREE-TO-ASCII-BOX-BASE TREE-TO-ASCII-BOX-BASE-SET) (defun tree-to-ascii-compute-boxes (tree &key boxed format-fun from-length to-length base) " DO: Compute the boxes and formated strings and store them in the decorated tree. FROM-LENGTH: The length of the stem from the child box (default = 2). TO-LENGTH: The length of the stem to the parent box (default = 2). BASE: (member :top :centered :bottom) RETURN: (tree-to-ascii-box tree) NOTE: TO-LENGTH FROM-LENGTH |<--------->|<----------->| --- +---------+ ^ +-------------| Child 3 | | base | +---------+ v | --- +--------+ | +---------+ | Parent |-----------+-------------| Child 2 | +--------+ | +---------+ | | +---------+ +-------------| Child 3 | +---------+ " (check-type format-fun (or null function)) (let ((children (tree-to-ascii-children tree)) (children-box (make-tree-to-ascii-box)) (node-box (make-tree-to-ascii-box))) (setf (tree-to-ascii-formated tree) (if format-fun (funcall format-fun (tree-to-ascii-node tree)) (format nil "~S" (tree-to-ascii-node tree)))) (if boxed (setf (tree-to-ascii-box-width node-box) (+ 2 (length (tree-to-ascii-formated tree))) (tree-to-ascii-box-height node-box) 3 (tree-to-ascii-box-base node-box) 1) (setf (tree-to-ascii-box-width node-box) (length (tree-to-ascii-formated tree)) (tree-to-ascii-box-height node-box) 1 (tree-to-ascii-box-base node-box) 0)) (when children (loop :for child :in children :for child-box := (tree-to-ascii-compute-boxes child :boxed boxed :format-fun format-fun :to-length to-length :from-length from-length :base base) :maximize (tree-to-ascii-box-width child-box) :into width :sum (1+ (tree-to-ascii-box-height child-box)) :into height :finally (setf (tree-to-ascii-box-width children-box) width (tree-to-ascii-box-height children-box) (1- height) (tree-to-ascii-box-base children-box) (ecase base (:top (- height 1 (tree-to-ascii-box-height node-box))) (:centered (floor (/ (1- height) 2))) (:bottom (tree-to-ascii-box-base node-box))))) (setf (tree-to-ascii-box-width node-box) (+ (tree-to-ascii-box-width node-box) ;; TODO: WE COULD USE (MAX TO-LENGTH FROM-LENGTH) WITH 1 CHILD (if (cdr children) (+ to-length 1 from-length) from-length) (tree-to-ascii-box-width children-box))) (setf (tree-to-ascii-box-height node-box) (max (tree-to-ascii-box-height node-box) (tree-to-ascii-box-height children-box))) (setf (tree-to-ascii-box-base node-box) (tree-to-ascii-box-base children-box))) (setf (tree-to-ascii-box tree) node-box) node-box)) (defun tree-to-ascii-draw-to-pict (tree pict left bottom &key boxed to-length from-length) " DO: Draw the decorated TREE into the PICT. " (let ((box (tree-to-ascii-box tree)) (str (tree-to-ascii-formated tree)) (children (reverse (tree-to-ascii-children tree)))) ;; draw the node: (if boxed (progn (draw-string pict (1+ left) (+ bottom (tree-to-ascii-box-base box)) str) (frame-rect pict left (+ bottom (tree-to-ascii-box-base box) -1) (+ 2 (length str)) 3) (setq left (+ left 2 (length str)))) (progn (draw-string pict left (+ bottom (tree-to-ascii-box-base box)) str) (setq left (+ left (length str))))) (when children ;; draw the childen: (if (cdr children) (let* ( ;; more than one child (child-box (tree-to-ascii-box (car (last children)))) (min (tree-to-ascii-box-base (tree-to-ascii-box (car children)))) (max (- (+ (tree-to-ascii-box-height box) (tree-to-ascii-box-base child-box)) (tree-to-ascii-box-height child-box))) (y bottom) ) ;; draw the vertical line: (draw-line pict (+ left to-length) (+ bottom min) 0 (1+ (- max min)) :foreground (character "|")) ;; draw the stem from the node: (draw-line pict left (+ bottom (tree-to-ascii-box-base box)) to-length 0 :foreground (character "-")) (draw-point pict (+ left to-length) (+ bottom (tree-to-ascii-box-base box)) (character "+")) (dolist (child children) (setq child-box (tree-to-ascii-box child)) ;; draw the subnode: (tree-to-ascii-draw-to-pict child pict (+ left to-length 1 from-length) y :boxed boxed :to-length to-length :from-length from-length) ;; draw the stem to the subnode: (draw-line pict (+ left to-length 1) (+ y (tree-to-ascii-box-base child-box)) from-length 0 :foreground (character "-")) (draw-point pict (+ left to-length) (+ y (tree-to-ascii-box-base child-box)) (character "+")) (setq y (+ y 1 (tree-to-ascii-box-height child-box))) ) ;;dolist ) ;;left* (progn ;; only one child ;; draw the stem from the node: ;; TODO: WE COULD USE (MAX TO-LENGTH FROM-LENGTH) (draw-line pict left (+ bottom (tree-to-ascii-box-base box)) from-length 0 :foreground (character "-")) (tree-to-ascii-draw-to-pict (car children) pict (+ left from-length) bottom :boxed boxed :to-length to-length :from-length from-length)))))) (defun tree-to-ascii (tlee &key boxed format-fun background to-length from-length (base :centered)) " tlee: is a list-based tree, whose car is a \"node\", and whose cdr is the list of children. boxed: t if boxes should be drawn around the nodes. format-fun: a function taking a node (one of the car's) and returning a string to be displayed as the node. Defaults merely use (format nil \"~S\" node). background: is a character used as background. Default: space. DO: Draw the tree onto an ASCII-art picture. RETURNS: The string containing the ASCII-ART tree. EXAMPLE: (tree-to-ascii '(if (= a b) (decf b a) (decf a b))) --> \" +--a +--=--+ | +--b | | +--b if--+--decf--+ | +--a | | +--a +--decf--+ +--b \" " (unless from-length (setq from-length 2)) (unless to-length (setq to-length 2)) (unless background (setq background (character " "))) (let* ((tree (tree-decorate tlee (function tree-to-ascii-make-decoration))) (box (tree-to-ascii-compute-boxes tree :boxed boxed :format-fun format-fun :to-length to-length :from-length from-length :base base)) (pict (make-instance 'picture :width (tree-to-ascii-box-width box) :height (tree-to-ascii-box-height box) :background background))) (tree-to-ascii-draw-to-pict tree pict 0 0 :boxed boxed :to-length to-length :from-length from-length) (to-string pict))) ;;;; THE END ;;;;
14,529
Common Lisp
.lisp
307
37.732899
85
0.531437
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
a6937a1e4e9cc2949890f6c64ea58f2c6a48200f92db39acf1e28254f3c22610
5,068
[ -1 ]
5,069
com.informatimago.common-lisp.picture.asd
informatimago_lisp/common-lisp/picture/com.informatimago.common-lisp.picture.asd
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: com.informatimago.common-lisp.picture.asd ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; ASD file to load the com.informatimago.common-lisp.picture library. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2010-10-31 <PJB> Created this .asd file. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2010 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see http://www.gnu.org/licenses/ ;;;;************************************************************************** (asdf:defsystem "com.informatimago.common-lisp.picture" ;; system attributes: :description "Informatimago Common Lisp ASCII-Art Picture" :author "Pascal J. Bourguignon <[email protected]>" :maintainer "Pascal J. Bourguignon <[email protected]>" :licence "AGPL3" ;; component attributes: :version "1.4.0" :properties ((#:author-email . "[email protected]") (#:date . "Autumn 2010") ((#:albert #:output-dir) . "/tmp/documentation/com.informatimago.common-lisp.picture/") ((#:albert #:formats) . ("docbook")) ((#:albert #:docbook #:template) . "book") ((#:albert #:docbook #:bgcolor) . "white") ((#:albert #:docbook #:textcolor) . "black")) #+asdf-unicode :encoding #+asdf-unicode :utf-8 :depends-on ("com.informatimago.common-lisp.cesarum") :components ((:file "picture" :depends-on ()) (:file "cons-to-ascii" :depends-on ("picture")) (:file "tree-to-ascii" :depends-on ("picture"))) #+adsf3 :in-order-to #+adsf3 ((asdf:test-op (asdf:test-op "com.informatimago.common-lisp.picture.test")))) ;;;; THE END ;;;;
2,659
Common Lisp
.lisp
55
44.690909
111
0.586088
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
4c1ef28a9a19a10dad49f07e1d19ebe5b22062c6149bd0be91294e38c0937c94
5,069
[ -1 ]
5,070
com.informatimago.common-lisp.picture.test.asd
informatimago_lisp/common-lisp/picture/com.informatimago.common-lisp.picture.test.asd
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;*************************************************************************** ;;;;FILE: com.informatimago.common-lisp.picture.test.asd ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: None ;;;;USER-INTERFACE: None ;;;;DESCRIPTION: ;;;; ;;;; This file defines the com.informatimago.common-lisp.picture.test system. ;;;; Tests the com.informatimago.common-lisp.picture system. ;;;; ;;;;USAGE: ;;;; ;;;;AUTHORS: ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS: ;;;; 2015-02-23 <PJB> Created. ;;;;BUGS: ;;;; ;;;;LEGAL: ;;;; ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;; ;;;;*************************************************************************** (asdf:defsystem "com.informatimago.common-lisp.picture.test" ;; system attributes: :description "Tests the com.informatimago.common-lisp.picture system." :author "Pascal J. Bourguignon <[email protected]>" :maintainer "Pascal J. Bourguignon <[email protected]>" :licence "AGPL3" ;; component attributes: :version "1.2.0" :properties ((#:author-email . "[email protected]") (#:date . "Winter 2015") ((#:albert #:output-dir) . "/tmp/documentation/com.informatimago.common-lisp.picture.test/") ((#:albert #:formats) "docbook") ((#:albert #:docbook #:template) . "book") ((#:albert #:docbook #:bgcolor) . "white") ((#:albert #:docbook #:textcolor) . "black")) #+asdf-unicode :encoding #+asdf-unicode :utf-8 :depends-on ("com.informatimago.common-lisp.cesarum" "com.informatimago.common-lisp.picture") :components ((:file "picture-test" :depends-on nil)) #+asdf3 :perform #+asdf3 (asdf:test-op (operation system) (declare (ignore operation system)) (dolist (p '("COM.INFORMATIMAGO.COMMON-LISP.PICTURE.PICTURE.TEST")) (let ((*package* (find-package p))) (uiop:symbol-call p "TEST/ALL"))))) ;;;; THE END ;;;;
2,991
Common Lisp
.lisp
66
39.393939
95
0.565515
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
c980128ab9047752afca1d95afe032db3110d89288799db66fb2dc79d428c035
5,070
[ -1 ]
5,071
com.informatimago.common-lisp.heap.test.asd
informatimago_lisp/common-lisp/heap/com.informatimago.common-lisp.heap.test.asd
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;*************************************************************************** ;;;;FILE: com.informatimago.common-lisp.heap.test.asd ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: None ;;;;USER-INTERFACE: None ;;;;DESCRIPTION: ;;;; ;;;; This file defines the com.informatimago.common-lisp.heap.test system. ;;;; Tests the com.informatimago.common-lisp.heap system. ;;;; ;;;;USAGE: ;;;; ;;;;AUTHORS: ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS: ;;;; 2015-02-23 <PJB> Created. ;;;;BUGS: ;;;; ;;;;LEGAL: ;;;; ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;; ;;;;*************************************************************************** (asdf:defsystem "com.informatimago.common-lisp.heap.test" ;; system attributes: :description "Tests the com.informatimago.common-lisp.heap system." :author "Pascal J. Bourguignon <[email protected]>" :maintainer "Pascal J. Bourguignon <[email protected]>" :licence "AGPL3" ;; component attributes: :version "1.2.0" :properties ((#:author-email . "[email protected]") (#:date . "Winter 2015") ((#:albert #:output-dir) . "/tmp/documentation/com.informatimago.common-lisp.heap.test/") ((#:albert #:formats) "docbook") ((#:albert #:docbook #:template) . "book") ((#:albert #:docbook #:bgcolor) . "white") ((#:albert #:docbook #:textcolor) . "black")) #+asdf-unicode :encoding #+asdf-unicode :utf-8 :depends-on ("com.informatimago.common-lisp.cesarum" "com.informatimago.common-lisp.heap") :components () #+asdf3 :perform #+asdf3 (asdf:test-op (operation system) (declare (ignore operation system)) ;; (let ((*package* (find-package "TESTED-PACKAGE"))) ;; (uiop:symbol-call "TESTED-PACKAGE" ;; "TEST/ALL")) )) ;;;; THE END ;;;;
2,955
Common Lisp
.lisp
67
37.925373
84
0.546778
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
97ef3a240273314b1088f54403b7c7e9e954fdac045fd42bab4c540f3644386a
5,071
[ -1 ]
5,072
demo.lisp
informatimago_lisp/common-lisp/heap/demo.lisp
(defpackage "DEMO" (:use "CL" "COM.INFORMATIMAGO.COMMON-LISP.HEAP.MEMORY" "COM.INFORMATIMAGO.COMMON-LISP.HEAP.HEAP")) (in-package "DEMO") (defparameter *mem* (make-instance 'memory-vector-64 :base 0 :size 32768)) (common-initialize *mem*) (defcommon *fruits*) (setf *fruits* '((2 apple) (3 orange) (18 cherry))) (setf *fruits* '((10 apple) (2 orange) (19 cherry))) *fruits* ; -> ((10 apple) (2 orange) (19 cherry)) (macroexpand '*fruits*) ; -> (get-common '*fruits*) ; t com.informatimago.common-lisp.heap.heap::*defined-common-variables* ; -> (*fruits* *common-variables*) (subseq (com.informatimago.common-lisp.heap.memory::bytes *mem*) 0 8) ; -> #(4597283572347515282 0 2305843009213693960 72057594037927942 2594073385365405895 1008806316530995200 2594073385365405706 2594073385365405953) (dump *mem* 0 80 :stream *standard-output* :margin "" :byte-size 8)
878
Common Lisp
.lisp
15
56.333333
217
0.719583
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
1a7ac73c24d07989ae471fb8b83f10a4a46b372223e9cf2a12a760c34ad67adc
5,072
[ -1 ]
5,073
memory.lisp
informatimago_lisp/common-lisp/heap/memory.lisp
;;;; -*- coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: memory.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; This packages exports a memory abstract class ;;;; and a concrete subclass implemented as a lisp array of unsigned bytes. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2012-10-26 <PJB> Added memory-operate. ;;;; 2004-12-22 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2004 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.HEAP.MEMORY" (:use "COMMON-LISP") (:export "MEMORY-EPILOG" "MEMORY-PROLOG" "MEMORY-OPERATE" "DUMP" "VALID-ADDRESS-P" "WITH-MEMORY" "POKE-UINT64" "POKE-UINT32" "POKE-UINT16" "POKE-UINT8" "PEEK-UINT64" "PEEK-UINT32" "PEEK-UINT16" "PEEK-UINT8" "SIZE" "BASE" "MEMORY-VECTOR-64" "MEMORY") (:documentation " This packages exports a memory abstract class and a concrete subclass implemented as a lisp array of unsigned bytes. License: AGPL3 Copyright Pascal J. Bourguignon 2004 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.HEAP.MEMORY") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; MEMORY ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defgeneric base (memory) (:documentation "Minimum value for an address in the given memory.")) (defgeneric size (memory) (:documentation "Number of bytes this memory holds.")) (defclass memory () ((base :reader base :initarg :base :type (integer 0) :documentation "Minimum value for an address.") (size :reader size :initarg :size :type (integer 0) :documentation "Number of bytes this memory holds.")) (:documentation "An abstract memory.")) (defmethod initialize-instance :before ((self memory) &key (base 0) (size nil)) (assert (typep size '(integer 1)) (size) "SIZE must be specified as a positive integer, not ~S" size) (assert (typep base '(integer 0)) (base) "BASE must be specified as a positive integer, not ~S" base) self) (defgeneric peek-uint8 (memory address) (:documentation "RETURN: The 8-bit byte at the given ADDRESS of the MEMORY.")) (defgeneric peek-uint16 (memory address) (:documentation "RETURN: The 16-bit byte at the given ADDRESS of the MEMORY.")) (defgeneric peek-uint32 (memory address) (:documentation "RETURN: The 32-bit byte at the given ADDRESS of the MEMORY.")) (defgeneric peek-uint64 (memory address) (:documentation "RETURN: The 64-bit byte at the given ADDRESS of the MEMORY.")) (defgeneric poke-uint8 (memory address value) (:documentation "DO: Store the 8-bit VALUE into the given ADDRESS of the MEMORY.")) (defgeneric poke-uint16 (memory address value) (:documentation "DO: Store the 16-bit VALUE into the given ADDRESS of the MEMORY.")) (defgeneric poke-uint32 (memory address value) (:documentation "DO: Store the 32-bit VALUE into the given ADDRESS of the MEMORY.")) (defgeneric poke-uint64 (memory address value) (:documentation "DO: Store the 64-bit VALUE into the given ADDRESS of the MEMORY.")) (defgeneric valid-address-p (memory address) (:documentation "RETURN: Whether ADDRESS is a valid address of the MEMORY.")) (defgeneric memory-prolog (memory) (:documentation " This function is called before accessing the memory, so that any locking for shared memories may be implemented. An alternative is to override MEMORY-OPERATE. ")) (defgeneric memory-operate (memory thunk) (:documentation " This function is called to access the memory, so that any locking/unlocking for shared memories may be implemented. The default method just calls the THUNK. Any specialization of this function must funcall THUNK or CALL-NEXT-METHOD. An alternative is to override MEMORY-PROLOG and MEMORY-EPILOG. ")) (defgeneric memory-epilog (memory) (:documentation " This function is called after accessing the memory, so that any unlocking for shared memories may be implemented. An alternative is to override MEMORY-OPERATE. ")) (defgeneric dump (memory address length &key byte-size stream margin) (:documentation "Print on the STREAM the contents of the MEMORY from the ADDRESS for LENGTH bytes of bit size BYTE-SIZE.")) (defmethod memory-prolog ((self memory)) (declare (ignorable self)) (values)) (defmethod memory-operate ((self memory) thunk) (declare (ignorable self)) (funcall thunk)) (defmethod memory-epilog ((self memory)) (declare (ignorable self)) (values)) (defmacro with-memory (memory &body body) " Protects access to the memory, giving the memory object a chance to set signal handler, or to acquire locks, and then release them. " (let ((vmemory (gensym))) `(let ((,vmemory ,memory)) (memory-prolog ,vmemory) (unwind-protect (memory-operate ,vmemory (lambda () ,@body)) (memory-epilog ,vmemory))))) (defmethod valid-address-p ((self memory) address) (<= (base self) address (+ (base self) (size self) -1))) (defmethod dump ((self memory) address length &key (byte-size 1) (stream *standard-output*) (margin "")) (let ((peek (case byte-size ((1) (function peek-uint8)) ((2) (function peek-uint16)) ((4) (function peek-uint32)) ((8) (function peek-uint64)) (otherwise (error "BYTE-SIZE must be either 1, 2, 4 or 8."))))) (do ((address address (+ byte-size address)) (i 0 (+ byte-size i))) ((>= i length) (format stream "~&") (values)) (when (zerop (mod i 16)) (format stream "~&~A~8,'0X: " margin address)) (format stream "~V,'0X " (* 2 byte-size) (funcall peek self address))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; MEMORY-VECTOR-64 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defclass memory-vector-64 (memory) ((bytes :accessor bytes :type (vector (unsigned-byte 64)))) (:documentation "A 64-bit memory.")) (defmethod initialize-instance :after ((self memory-vector-64) &key (base 0) (size nil)) (assert (and (typep size '(integer 8)) (zerop (mod size 8))) (size) "SIZE must congruent to 0 modulo 8 and must be greater than 8") (assert (zerop (mod base 8)) (base) "BASE must be congruent to 0 modulo 8, not ~S" base) (setf (bytes self) (make-array (list (truncate size 8)) :element-type '(unsigned-byte 64) :initial-element 0)) self) (defmethod peek-uint8 ((self memory-vector-64) address) (decf address (base self)) (let ((high (truncate address 8)) (low (mod address 8))) (ldb (byte 8 (* low 8)) (aref (bytes self) high)))) (defmethod peek-uint16 ((self memory-vector-64) address) (decf address (base self)) (unless (zerop (mod address 2)) (error "Misaligned 16-bit address ~8,'0X" address)) (let ((high (truncate address 8)) (low (mod address 8))) (ldb (byte 16 (* low 4)) (aref (bytes self) high)))) (defmethod peek-uint32 ((self memory-vector-64) address) (decf address (base self)) (unless (zerop (mod address 4)) (error "Misaligned 32-bit address ~8,'0X" address)) (let ((high (truncate address 8)) (low (mod address 8))) (ldb (byte 32 (* low 2)) (aref (bytes self) high)))) (defmethod peek-uint64 ((self memory-vector-64) address) (decf address (base self)) (unless (zerop (mod address 8)) (error "Misaligned 64-bit address ~8,'0X" address)) (aref (bytes self) (truncate address 8))) (defmethod poke-uint8 ((self memory-vector-64) address value) (assert (typep value '(integer 0 #.(1- (expt 2 8))))) (decf address (base self)) (let ((high (truncate address 8)) (low (mod address 8))) (setf (aref (bytes self) high) (dpb value (byte 8 (* low 8)) (aref (bytes self) high))))) (defmethod poke-uint16 ((self memory-vector-64) address value) (assert (typep value '(integer 0 #.(1- (expt 2 16))))) (decf address (base self)) (unless (zerop (mod address 2)) (error "Misaligned 16-bit address ~8,'0X" address)) (let ((high (truncate address 8)) (low (mod address 8))) (setf (aref (bytes self) high) (dpb value (byte 16 (* low 4)) (aref (bytes self) high))))) (defmethod poke-uint32 ((self memory-vector-64) address value) (assert (typep value '(integer 0 #.(1- (expt 2 32))))) (decf address (base self)) (unless (zerop (mod address 4)) (error "Misaligned 32-bit address ~8,'0X" address)) (let ((high (truncate address 8)) (low (mod address 8))) (setf (aref (bytes self) high) (dpb value (byte 32 (* low 2)) (aref (bytes self) high))))) (defmethod poke-uint64 ((self memory-vector-64) address value) (assert (typep value '(integer 0 #.(1- (expt 2 64))))) (decf address (base self)) (unless (zerop (mod address 8)) (error "Misaligned 64-bit address ~8,'0X" address)) (setf (aref (bytes self) (truncate address 8)) value)) ;;;; memory.lisp -- -- ;;;;
10,999
Common Lisp
.lisp
231
43.095238
91
0.642664
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
cc6f94891a12073ce1d6952ccfd689f6d4f3f43546608410615dcc5b743ad9c1
5,073
[ -1 ]
5,074
heap.lisp
informatimago_lisp/common-lisp/heap/heap.lisp
;;;; -*- coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: heap.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; This package implements a heap for "common" data ;;;; in shared memory segments. ;;;; There is a garbage collector, and lisp data types. ;;;; ;;;;SEE ;;;; "COMMON USER-LEVEL API" bellow. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2012-10-26 <PJB> Corrected gc-store and gc-load, added ;;;; docstrings. (Thanks to Dan Lentz for the bug ;;;; report). ;;;; 2005-08-10 <PJB> Added some EVAL-WHEN needed for macros. ;;;; 2004-12-18 <PJB> Reached usable state. ;;;; 2004-12-02 <PJB> Created. ;;;;BUGS ;;;; Copying of some important types is not implemented yet: ;;;; double-float, vectors, arrays, structures (unfortunately, ;;;; structures will need either a define-common-structure, or ;;;; MOP or implementation specific API to get the list of slots). ;;;; ;;;; with-common-lock mutex is too wide. With smarter treatment of ;;;; new-generation, and possibly ad hoc mutexes, it should be ;;;; possible to mutex only gc-allocate. ;;;; ;;;; The number of different cell types should be reduced, ;;;; and the set of cell types should be distinct from the ;;;; set of types of array elements. ;;;; ;;;; The size and encoding of cells should be parameterizable, ;;;; and a 32-bit version should be available on "legacy" systems. ;;;; ;;;; ;;;; ;; We need a WITH-COMMON macro such as: ;;;; ;;;; (defcommon head nil) ;;;; (defcommon tail nil) ;;;; ;;;; (defun insert (item) ;;;; (with-common ;;;; (with-common-lock ;;;; (if (null head) ;;;; (setf head (list item) ;;;; tail head) ;;;; (setf (cdr tail) (list item) ;;;; tail (cdr tail)))))) ;;;; ;;;; ;; would be generated as: ;;;; ;;;; (defun insert (item) ;;;; (with-common-lock ;;;; (let ((phead (cfi-copy-to-common 'head)) ;;;; (ptail (cfi-copy-to-common 'tail))) ;;;; (if (cvm-null head) ;;;; (progn ;;;; (cvm-symbol-set-value phead (cfi-copy-to-common (list item))) ;;;; (cvm-symbol-set-value ptail (cfi-symbol-value phead))) ;;;; (progn ;;;; (cvm-setcdr ptail (cfi-copy-to-common (list item))) ;;;; (cvm-symbol-set-value ptail (cvm-cdr ptail))))))) ;;;; ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2004 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.HEAP.HEAP" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.HEAP.MEMORY" "COM.INFORMATIMAGO.COMMON-LISP.DATA-ENCODING.IEEE-754") #+mocl (:shadowing-import-from "COM.INFORMATIMAGO.MOCL.KLUDGES.MISSING" "*TRACE-OUTPUT*" "*LOAD-VERBOSE*" "*LOAD-PRINT*" "ARRAY-DISPLACEMENT" "CHANGE-CLASS" "COMPILE" ;; "COMPLEX" "ENSURE-DIRECTORIES-EXIST" "FILE-WRITE-DATE" "INVOKE-DEBUGGER" "*DEBUGGER-HOOK*" "LOAD" "LOGICAL-PATHNAME-TRANSLATIONS" "MACHINE-INSTANCE" "MACHINE-VERSION" "NSET-DIFFERENCE" "RENAME-FILE" "SUBSTITUTE-IF" "TRANSLATE-LOGICAL-PATHNAME" "PRINT-NOT-READABLE" "PRINT-NOT-READABLE-OBJECT") (:import-from "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY" "WSIOSBP" "DEFENUM") (:export "SET-COMMON" "GET-COMMON" "WITH-COMMON-LOCK" "*COMMON-VARIABLES*" "DEFCOMMON" "COMMON-INITIALIZE") (:documentation " This package implements a heap for 'common' data in shared memory segments. There is a garbage collector, and lisp data types. See also: COM.INFORMATIMAGO.COMMON-LISP.HEAP.MEMORY License: AGPL3 Copyright Pascal J. Bourguignon 2004 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.HEAP.HEAP") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; DEBUGGING FLAGS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar *check-args* '(:dump-bitmap t :dump-header t :dump-free t :dump-allocated t) "See the keyword arguments of gc-check") (eval-when (:compile-toplevel :load-toplevel :execute) (unless (boundp '+debug+) (defconstant +debug+ '(:*debug*) "Possible items: :*debug* check *DEBUG* at run-time. :range check gc-address range. :check check heap invariants. :ng trace the new-generation stack. :ld trace circle detection (calls to ld-put and ld-get). :objects trace object allocations. :gc debugging garbage collector. :allocate debugging allocator. :gcct debugging checking code. :bitmap debugging debugging code. :emulated-shared-memory Don't use shm, use a lisp vector for common memory. (Use it only in +DEBUG+, not in *DEBUG*). "))) (defvar *debug* nil) (defmacro when-debug (what &body body) (cond ((intersection what +debug+) `(let ((*standard-output* *trace-output*)) ,@body)) ((member :*debug* +debug+) `(when (intersection ',what *debug*) (let ((*standard-output* *trace-output*)) ,@body))))) (defmacro unless-debug (what &body body) (unless (intersection what +debug+) `(let ((*standard-output* *trace-output*)) ,@body))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; COMMON HEAP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; heap: ;; ---- ----- --- ----------------- ;; addr ofset siz description ;; ---- ----- --- ----------------- ;; 0 0: 8 magic-cookie | signature header ;; 1 8: 8 key | semaphore-number | ;; -------------- heap-header \ ;; 2 16: 8 ct-structure 8 | heap root: heap-header structure ;; 3 24: 8 ct-t 6 | + free-blocks array ;; 4 32: 8 class | [ct-address SYSTEM:HEAP-HEADER] ;; 5 40: 8 size | ;; 6 48: 8 free-blocks | [ct-address 10] ;; 7 56: 8 root | [ct-nil] initially. ;; 8 64: 8 new-generation | (cons nil nil) initially. ;; 9 72: 8 reserved / [ct-nil] ;; -------------- free-blocks \ ;; 10 80: 8 ct-vector 34 | ;; 11 88: 8 ct-t 32 | ;; 12 96: 8 free-blocks[0] (size=16) | [ct-address 42] initially. ;; 13 104: 8 free-blocks[1] (size=24) | [ct-nil] initially. ;; 14 112: 8 free-blocks[2] (size=32) | [ct-nil] initially. ;; .... .... | .... ;; 42 320: 8 free-blocks[30] (size=256) | [ct-nil] initially. ;; 43 328: 8 free-blocks[31] (size>256) / [ct-address 128] initially. ;; -------------- first free cons initially ---- from here down: gc managed. ;; 44 336: 16 20 initially free cons cells. [ct-free-block 2|43] initally. ;; .... .... ;; 63 504: 16 last initially free cons cell [ct-free-block 2|0] intially. ;; 64 512: 512 first free big block initially [ct-free-block 64|128] ;; -------------- second free big block initially. ;; 128 1024: 1 big block to the end of [ct-free-block nnn|0] initially. ;; the segment. ;; ffff: last byte ;; -------------- ----------------- ;; variable is a cvm-list of cvm-symbols. ;; ;; Addresses in shared segment are offset from the beginning of the segment. ;; We don't keep the segment key with the offset because we won't be using ;; normally intersegment addresses. However, only the ct-address ;; and ct-readable cell types would have to be changed if we used ;; segmented addresses to allow growing the common-space in ;; multi-segment fashion. ;; common::gc global variables: ;; (These variables could go into an object as slots ;; if multiple common heaps were needed). (defvar *gc-memory* nil) ; MEMORY instance. (defvar *gc-heap-base* 0) ; (base *gc-memory*) (defvar *gc-heap-size* 0) ; (size *gc-memory*) 8) (defvar *gc-magic-cookie* (+ 1 (random (expt 2 63)))) ; /= 0 (defvar *gc-symbol* 0) ; cvm-address of COMMON-LISP:SYMBOL (defvar *gc-package* 0) ; cvm-address of COMMON-LISP:PACKAGE (defmacro with-common-lock (&body body) "Execute the BODY with the *GC-MEMORY* locked with the WITH-MEMORY macro." `(with-memory *gc-memory* ,@body)) (defmacro with-gc-lock (&body body) `(progn ,@body)) ;;-------------------------- ;; cell access / raw-memory ;;-------------------------- ;; CVM Memory is organized as an array of 64-byte cells; ;; CVM Memory addresses (gc-addresses) are indices into this array. ;; valid gc-addresses are from 1 to (1- size). ;; ;; NOTE: MEMORY objects are byte-addressed, however the various sized ;; operations are only called on naturally aligned addresses: a ;; PEEK-UINT64 will be called only with addresses multiple of 8. ;; (However, this heap usually addresses 64-bit words, GC-STORE ;; and GC-LOAD convert the heap addresses into the memory byte ;; addresses, and CVM-SVOPERATE does similarly, but may address ;; into MEMORY 8-bit, 16-bit, 32-bit or 64-bit words depending ;; on the size of the data type). (declaim (inline gc-store gc-load)) (defun gc-signature () (peek-uint64 *gc-memory* *gc-heap-base*)) (defun gc-sign (signature) (poke-uint64 *gc-memory* *gc-heap-base* signature)) (defun gc-store (gc-address object) (let ((address (* 8 gc-address))) (assert (< 0 address (size *gc-memory*))) (poke-uint64 *gc-memory* (+ *gc-heap-base* address) object))) (defun gc-load (gc-address) (let ((address (* 8 gc-address))) (assert (< 0 address (size *gc-memory*))) (peek-uint64 *gc-memory* (+ *gc-heap-base* address)))) (defun gc-peek-function (bit-size) (case bit-size (( 8) (values (lambda (address) (peek-uint8 *gc-memory* address)) 1)) ((16) (values (lambda (address) (peek-uint16 *gc-memory* address)) 2)) ((32) (values (lambda (address) (peek-uint32 *gc-memory* address)) 4)) ((64) (values (lambda (address) (peek-uint64 *gc-memory* address)) 8)) (otherwise (error "No peek function defined for bit field of width ~D" bit-size)))) (defun gc-poke-function (bit-size) (case bit-size (( 8) (values (lambda (address object) (poke-uint8 *gc-memory* address object)) 1)) ((16) (values (lambda (address object) (poke-uint16 *gc-memory* address object)) 2)) ((32) (values (lambda (address object) (poke-uint32 *gc-memory* address object)) 4)) ((64) (values (lambda (address object) (poke-uint64 *gc-memory* address object)) 8)) (otherwise (error "No poke function defined for bit field of width ~D" bit-size)))) (defun gc-dump-block (gc-address size stream &key (margin "")) (let ((address (* 8 gc-address))) (dump *gc-memory* (+ *gc-heap-base* address) (* 8 size) :stream stream :margin margin :byte-size 8))) ;;---------------------------------------- ;; cell-type: tags ;;---------------------------------------- (eval-when (:compile-toplevel :load-toplevel :execute) (defenum cell-type "Some types are used for memory cells (ie. boxed values), but some types are used only for array cells (ie. unboxed values)." ct-nil ct-t ct-unbound ct-bit ; boolean ct-character-8 ; --> char-code / code-char, no encoding! ct-character-16 ct-character-24 ct-character-32 ; character ct-signed-byte-8 ct-signed-byte-16 ct-signed-byte-24 ct-signed-byte-32 ct-signed-byte-40 ct-signed-byte-48 ct-signed-byte-56 ; fixnum ct-signed-byte-64 ct-unsigned-byte-8 ct-unsigned-byte-16 ct-unsigned-byte-24 ct-unsigned-byte-32 ct-unsigned-byte-40 ct-unsigned-byte-48 ct-unsigned-byte-56 ct-unsigned-byte-64 ct-float-8 ct-float-16 ct-float-24 ct-float-32 ; single-float ct-float-40 ct-float-48 ct-float-56 ct-float-64 ; double-float ct-structure ct-vector ct-vector-fp ct-array ct-address ct-readable ct-free-block) (defconstant ct-cons 64) (defconstant ct-mark 128)) ;;-------------------------- ;; structures ;;-------------------------- (defmacro cvm-define-structure (name type &rest fields) ;; TODO: we could do without the defconstant for structure fields... (wsiosbp `(progn (defun ,(intern (format nil "CVM-~A-P" name)) (self) (and (cvm-structure-p self) (= ,(1+ (length fields)) (cvm-length self)) (= ct-t (cvm-element-type self)) (= ,(cond ((eq 'symbol name) '*gc-symbol*) ((eq 'package name) '*gc-package*) (t `(cvm-find-symbol ,(car type) (cvm-find-package ,(cdr type))))) (cvm-structure-ref self 0)))) ,@(loop :for field :in fields :for index :from 1 :append (let ((cst (intern (format nil "+~A-~A+" name field))) (get (intern (format nil "CVM-~A-~A" name field))) (set (intern (format nil "CVM-~A-SET-~A" name field)))) (list `(defconstant ,cst ,index) `(defun ,get (self) (cvm-structure-ref self ,cst)) `(defun ,set (self value) (cvm-structure-store self ,cst value)) `(defsetf ,get ,set))))))) ;; Forward definitions because defsetf must be seen before use. (cvm-define-structure symbol ("SYMBOL" . "COMMON-LISP") package name value function plist) (cvm-define-structure package ("PACKAGE" . "COMMON-LISP") name nicknames symbols externals uses) ;;-------------------------- ;; heap header ;;-------------------------- (cvm-define-structure hh ;; the only instance of this structure is stored in the common heap. ("HEAP-HEADER" . "SYSTEM") size ; ct-fixnum free-blocks ; ct-vector of ct-free-block root ; ct-nil or ct-address to a ct-cons new-generation ; ct-nil or ct-address to a ct-vector-fp reserved) ;; We need to keep a new-generation list for partially allocated objects ;; until the value is stored in a symbol in a package in the root list. ;; ;; All blocks allocated by GC-ALLOCATE are pushed onto the new-generation ;; vector. new-generation is reset with GC-RESET-GENERATION. (eval-when (:compile-toplevel :load-toplevel :execute) (defconstant +ng-size+ 31 "Size of the new generation vector (max index = 30)") ;; free-blocks vector maximum: (defconstant +fb-big+ 31 "Index of big-block free-list (this is the max index for free-blocks).") ;; (aref free-blocks +fb-big+) == blocks of size > 256 ;; (aref free-blocks k) == blocks of size = (* 8 (+ 2 k)) (defconstant +gc-heap-header+ 2) ; cvm address (defconstant +gc-expected-free-block+ 10) ; cvm address (defconstant +gc-start+ 44) ; cvm address ;; cvm addresses are (integer 1 (1- *gc-heap-size*)) ;; indexing the 64-bit cells of the common heap. );;eval-when ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; COMMON VIRTUAL MACHINE MEMORY (CVM) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; - primitive functions to work with shared memory values. ;; : used by the shared memory garbage collector, and to manage the ;; shared memory data structures (header, list of common symbols). ;; ;; <typed-values> 64-bit ;; (free-block size) ;; null atom ;; cons --> <typed-value:address> ;; car cdr setcar setcdr ;; (make-vector element-type dimension) --> <typed-value:address> ;; (svref vector index) ;; (svset vector index value) ;; (make-structure class nbfields) --> <typed-value:address> ;; (structure-ref structure field-index) ;; (structure-store structure field-index value) ;; Simple values are cells of 8 bytes: ;; ;; [free-block s6 s5 s4 | s3 s2 s1 s0] ;; [NIL 0 0 0 | 0 0 0 0] ;; [T 0 0 0 | 0 0 0 1] ;; [bit 0 0 0 | 0 0 0 {0,1}] ;; [character-8 0 0 0 | 0 0 0 c0] ;; [character-16 0 0 0 | 0 0 c1 c0] ;; [character-24 0 0 0 | 0 c2 c1 c0] ;; [character-32 0 0 0 | c3 c2 c1 c0] ;; [{signed-byte,unsigned-byte,float}x[0,6] v6 v5 v4 | v3 v2 v1 v0] ;; ;; Reference values are addresses of the real value: ;; ;; [address o6 o5 o4 | o3 o2 o1 o0] --> vector|vector-fp|array|structure|cons ;; [readable o6 o5 o4 | o3 o2 o1 o0] --> string=(vector|vector-fp character) ;; ;; readable is a special kind of value used to transmit other random ;; lisp values that are printable readably. ;; ;; ;; Cons cells are 16-bytes double-cells. The type of the cons cell is ;; that of the cdr+128: ;; ;; [cons+ cdr-2 | car-2 ] ;; ;; Bigger values are greater multiples of 8-byte cells: ;; ;; [[vector-data|structure-data] size ;; | [ element-type (T, unboxed-type) dimensions-1 ] ;; | data ] ;; ;; first slot of structure is structure class (type of structure) ;; for symbols, the element-type is T and the structure class is NIL. ;; ;; [vector-fp-data size ;; | [ element-type (T, unboxed-type) dimensions-1 ] ;; | fill-pointer ;; | data ] ;; ;; [array-data size ;; | [ element-type (T, unboxed-type) ndimensions ] ;; | dimension_1 | ... | dimension_n ;; | data ] ;; ;; symbol: ;; [structure-data 15 | [T,6] |NIL| package | name | value |NIL| plist ] ;; ;; CL:SYMBOL: ;; [structure-data 15 | [T,6] |NIL| @'COMMON-LISP' | @'SYMBOL' |NIL|NIL|NIL] ;; ;; ;; cons+free-block ;; cons+nil ;; cons+t ;; cons+bit ;; cons+character-8 ;; ... ;; cons+address ;; cons+readable ;; (defenum cell-type ;; ct-address ;; ct-readable ;; ct-array ;; ct-free-block ;; ct-character ;; ct-fixnum ;; ct-float) ;; nil = (ct-address 0) ;; (defconstant ct-cons 128) (eval-when (:compile-toplevel :load-toplevel :execute) (defparameter +address-cell-types+ '(#.ct-address #.ct-readable)) (defparameter +complex-element-types+ '(#.ct-t #.ct-nil #.ct-address #.ct-readable) "array element types that are 'boxed'.") (defparameter +referenced-cell-types+ '(#.ct-cons #.ct-structure #.ct-vector #.ct-vector-fp #.ct-array) "Cell types that can be referenced by a ct-address or ct-readable.") (defparameter +character-types+ '(#.ct-character-8 #.ct-character-16 #.ct-character-24 #.ct-character-32)) (defparameter +simple-types+ '(#.ct-nil #.ct-t #.ct-bit #.ct-character-8 #.ct-character-16 #.ct-character-24 #.ct-character-32 #.ct-signed-byte-8 #.ct-signed-byte-16 #.ct-signed-byte-24 #.ct-signed-byte-32 #.ct-signed-byte-40 #.ct-signed-byte-48 #.ct-signed-byte-56 #.ct-signed-byte-64 #.ct-unsigned-byte-8 #.ct-unsigned-byte-16 #.ct-unsigned-byte-24 #.ct-unsigned-byte-32 #.ct-unsigned-byte-40 #.ct-unsigned-byte-48 #.ct-unsigned-byte-56 #.ct-unsigned-byte-64 #.ct-float-8 #.ct-float-16 #.ct-float-24 #.ct-float-32 #.ct-float-40 #.ct-float-48 #.ct-float-56 #.ct-float-64)) ) ;; Mark Cons Type ;; |MCTTTTTT|xxxxxxxx|xxxxxxxx|xxxxxxxx|xxxxxxxx|xxxxxxxx|xxxxxxxx|xxxxxxxx| ;; ;; ct-nil ;; |M0000000|00000000|00000000|00000000|00000000|00000000|00000000|00000000| ;; ;; ct-t ;; |M0000001|00000000|00000000|00000000|00000000|00000000|00000000|00000001| ;; ;; ct-free-block (next size) ;; |M0000010|nnnnnnnn|nnnnnnnn|nnnnnnnn|ssssssss|ssssssss|ssssssss|ssssssss| ;; ;; ct-bit (bit) ;; |M0000011|00000000|00000000|00000000|00000000|00000000|00000000|0000000b| ;; ;; ct-simples (value) ;; |M0TTTTTT|vvvvvvvv|vvvvvvvv|vvvvvvvv|vvvvvvvv|vvvvvvvv|vvvvvvvv|vvvvvvvv| ;; ;; ct-address, ct-readable (address) ;; |M0TTTTTT|aaaaaaaa|aaaaaaaa|aaaaaaaa|aaaaaaaa|aaaaaaaa|aaaaaaaa|aaaaaaaa| ;; ;; ct-cons (car cdr) ;; |M1TTTTTT|aaaaaaaa|aaaaaaaa|aaaaaaaa|aaaaaaaa|aaaaaaaa|aaaaaaaa|aaaaaaaa| ;; |M1TTTTTT|dddddddd|dddddddd|dddddddd|dddddddd|dddddddd|dddddddd|dddddddd| ;; ;; ct-structure, ct-vector, ct-vector-fp, ct-array (size element-type dimension) ;; |M0TTTTTT|00000000|00000000|00000000|ssssssss|ssssssss|ssssssss|ssssssss| ;; |00EEEEEE|dddddddd|dddddddd|dddddddd|dddddddd|dddddddd|dddddddd|dddddddd| ;; |eeeeeeee|eeeeeeee|eeeeeeee|eeeeeeee|eeeeeeee|eeeeeeee|eeeeeeee|eeeeeeee| ;; | ... ;; |eeeeeeee|eeeeeeee|eeeeeeee|eeeeeeee|eeeeeeee|eeeeeeee|eeeeeeee|eeeeeeee| (eval-when (:compile-toplevel :load-toplevel :execute) (defparameter +type-code+ (byte 6 56)) (defparameter +byte-56+ (byte 56 0)) (defparameter +byte-32+ (byte 32 0)) (defparameter +in-cons+ (byte 1 62)) (defparameter +ex-cons+ (byte 62 0)) (defparameter +in-mark+ (byte 1 63)) (defparameter +ex-mark+ (byte 63 0)) (defparameter +fb-size+ (byte 32 0)) (defparameter +fb-next+ (byte 24 32)) ) ;; the +type-code+ must be defined before reading the next s-expression. (eval-when (:compile-toplevel :load-toplevel :execute) (defconstant +cvm-nil+ #.(dpb ct-nil +type-code+ 0))) (defun gc-marked (object) (plusp (ldb +in-mark+ object))) (defun gc-set-mark (object) (dpb 1 +in-mark+ object)) (defun gc-clear-mark (object) (ldb +ex-mark+ object)) (defun gc-reset-generation () (let ((ng (cvm-hh-new-generation +gc-heap-header+))) (dotimes (i +ng-size+) (when-debug (:ng) (format t "ng:reset [~2D] ~16,'0X~%" i (cvm-svref ng i))) (cvm-svset ng i +cvm-nil+)) (cvm-set-fill-pointer ng 0))) (eval-when (:compile-toplevel :load-toplevel :execute) (defun gen-with-generation (bindings body) (let ((sp (gensym))) `(let* ((,sp (cvm-fill-pointer (cvm-hh-new-generation +gc-heap-header+))) ,@bindings) (unwind-protect (progn ,@body) (loop with generation = (cvm-hh-new-generation +gc-heap-header+) for fp from (1- (cvm-fill-pointer generation)) downto ,sp do (when-debug (:ng) (format t "ng:pop [~2D] ~16,'0X~%" fp (cvm-svref generation fp))) (cvm-svset generation fp +cvm-nil+) finally (cvm-set-fill-pointer generation ,sp))))))) (eval-when (:compile-toplevel :load-toplevel :execute) (defmacro with-generation (bindings &body body) (gen-with-generation bindings body))) (defun gc-push-root (sym) (with-generation ((sym sym)) (cvm-hh-set-root +gc-heap-header+ (cvm-make-cons sym (cvm-hh-root +gc-heap-header+))))) (defun gc-delete-from-root (item) (cvm-hh-set-root +gc-heap-header+ (cvm-list-delete-eq (cvm-hh-root +gc-heap-header+) item))) ;; cvm-make-* calls gc-allocate and return an address. ;; cvm-form-* formats and returns and immediate object. (defun cvm-eq (obj1 obj2) (= (ldb +ex-mark+ obj1) (ldb +ex-mark+ obj2))) (defun cvm-form-head (type size) (dpb type +type-code+ size)) (defun cvm-type-code (object) (ldb +type-code+ object)) (defun cvm-type-of (object) (if (zerop (ldb +in-cons+ object)) (ldb +type-code+ object) ct-cons)) (defun cvm-size-of (object) (case (cvm-type-of object) ((#.ct-free-block #.ct-vector #.ct-vector-fp #.ct-structure #.ct-array) (ldb +fb-size+ object)) ;; Warning: only 32-bit for size. ((#.ct-cons) 2) (otherwise 1))) ;;-------------------- ;; free blocks ;;-------------------- ;; [free-block n2 n1 n0 | s3 s2 s1 s0] (defun cvm-free-block-p (object) (eql (ldb +type-code+ object) ct-free-block)) (defun cvm-free-block-size (object) (ldb +fb-size+ object)) (defun cvm-free-block-next (object) (ldb +fb-next+ object)) (defun cvm-form-free-block (size next) (dpb ct-free-block +type-code+ (dpb next +fb-next+ (ldb +fb-size+ size)))) (defun cvm-free-block-set-next (address new-next) (setf address (cvm-deref address)) (gc-store address (cvm-form-free-block (cvm-free-block-size (gc-load address)) new-next))) (defun cvm-free-block-set-size (address new-size) (setf address (cvm-deref address)) (gc-store address (cvm-form-free-block new-size (cvm-free-block-next (gc-load address))))) ;;-------------------- ;; addresses ;;-------------------- ;; [address o6 o5 o4 | o3 o2 o1 o0 ] --> vector|vector-fp|array|structure|cons ;; [readable o6 o5 o4 | o3 o2 o1 o0 ] --> string=(vector|vector-fp character) (defun cvm-address-p (object) (= ct-address (ldb +type-code+ object))) (defun cvm-readable-p (object) (= ct-readable (ldb +type-code+ object))) (defun cvm-form-address (address) (dpb ct-address +type-code+ (ldb +byte-56+ address))) (defun cvm-form-readable (address) (dpb ct-readable +type-code+ (ldb +byte-56+ address))) (defun cvm-deref (object) (ldb +byte-56+ object)) ;;-------------------- ;; booleans ;;-------------------- ;; [NIL 0 0 0 | 0 0 0 0] (defun cvm-null (object) (eql (ldb +type-code+ object) ct-nil)) ;; [T 0 0 0 | 0 0 0 1] (eval-when (:compile-toplevel :load-toplevel :execute) (defconstant +cvm-t+ #.(dpb ct-t +type-code+ 1)) );;eval-when ;; [unbound 0 0 0 | 0 0 0 0] (defun cvm-unbound-p (object) (eql (ldb +type-code+ object) ct-unbound)) (eval-when (:compile-toplevel :load-toplevel :execute) (defconstant +cvm-unbound+ #.(dpb ct-unbound +type-code+ 0)) );;eval-when ;;-------------------- ;; bits ;;-------------------- ;; [bit 0 0 0 | 0 0 0 {0,1}] (defun cvm-bit-p (object) (eql (ldb +type-code+ object) ct-bit)) (defun cvm-form-bit (bit) (dpb ct-bit +type-code+ (ldb (byte 1 0) bit))) (defun cvm-bit-value (object) (ldb (byte 1 0) object)) ;;-------------------- ;; characters ;;-------------------- ;; [character-8 0 0 0 | 0 0 0 c0] ;; [character-16 0 0 0 | 0 0 c1 c0] ;; [character-24 0 0 0 | 0 c2 c1 c0] ;; [character-32 0 0 0 | c3 c2 c1 c0] (defun cvm-character-p (object) (<= ct-character-8 (ldb +type-code+ object) ct-character-32)) (defun cvm-form-character (code) (dpb ct-character-32 +type-code+ (ldb +byte-32+ code))) (defun cvm-character-code (object) (ldb +byte-32+ object)) ;;-------------------- ;; fixnums ;;-------------------- ;; [{signed-byte,unsigned-byte}x[0,6] v6 v5 v4 | v3 v2 v1 v0] (defun cvm-fixnum-p (object) (or (<= ct-signed-byte-8 (ldb +type-code+ object) ct-signed-byte-56) (<= ct-unsigned-byte-8 (ldb +type-code+ object) ct-unsigned-byte-48))) (defun cvm-form-fixnum (value) (unless (<= (- #.(expt 2 55)) value (1- #.(expt 2 55))) (error "Signed value too big.")) (dpb ct-signed-byte-56 +type-code+ (ldb +byte-56+ value))) (defun cvm-fixnum-value (object) (let ((value (ldb +byte-56+ object))) (if (< value #.(expt 2 55)) value (- value #.(expt 2 56))))) (defun cvm-single-float-p (object) (= ct-float-32 (ldb +type-code+ object))) (defun cvm-form-single-float (value) (dpb ct-float-32 +type-code+ (float-32-to-ieee-754 (coerce value 'single-float)))) (defun cvm-single-float-value (object) (ieee-754-to-float-32 (ldb +byte-32+ object))) ;; TODO: double-float ==> consing ;;-------------------- ;; conses ;;-------------------- ;; cons --> <typed-value:address> ;; car cdr setcar setcdr (defun cvm-cons-p (cons) ;; a ct-address to a ct-cons (and (cvm-address-p cons) (plusp (ldb +in-cons+ (gc-load (cvm-deref cons)))))) (defun cvm-make-cons (car-object cdr-object) (let* ((address (gc-allocate 2)) (gc-addr (cvm-deref address))) (gc-store gc-addr (dpb 1 +in-cons+ cdr-object)) (gc-store (1+ gc-addr) (dpb 1 +in-cons+ car-object)) (when-debug (:objects) (format t "~&object: ~16,'0X CONS~%" address)) address)) (defun cvm-car (cons) (cond ((cvm-null cons) ct-nil) ((cvm-cons-p cons) (ldb +ex-cons+ (gc-load (1+ (cvm-deref cons))))) (t (error "CVM-CAR of non-list object: ~A" (with-output-to-string (out) (gc-dump-object cons :stream out)))))) (defun cvm-cdr (cons) (cond ((cvm-null cons) ct-nil) ((cvm-cons-p cons) (ldb +ex-cons+ (gc-load (cvm-deref cons)))) (t (error "CVM-CDR of non-list object: ~A" (with-output-to-string (out) (gc-dump-object cons :stream out)))))) (defun cvm-setcar (cons value) (cond ((cvm-null cons) (error "CVM-SETCAR of NIL")) ((cvm-cons-p cons) (gc-store (1+ (cvm-deref cons)) (dpb 1 +in-cons+ value))) (t (error "CVM-SETCAR of non-list object: ~A" (with-output-to-string (out) (gc-dump-object cons :stream out)))))) (defun cvm-setcdr (cons value) (cond ((cvm-null cons) (error "CVM-SETCDR of NIL")) ((cvm-cons-p cons) (gc-store (cvm-deref cons) (dpb 1 +in-cons+ value))) (t (error "CVM-SETCDR of non-list object: ~A" (with-output-to-string (out) (gc-dump-object cons :stream out)))))) ;;-------------------- ;; lists ;;-------------------- (defun cvm-list-length (list) (loop for curr = list then (cvm-cdr curr) until (cvm-null curr) count 1)) (defun cvm-list-elt (list index) (loop :for curr = list :then (cvm-cdr curr) :repeat index :finally (return (cvm-car curr)))) (defun cvm-member-eq (item list) (loop :for curr = list :then (cvm-cdr curr) :until (or (cvm-null curr) (eql (cvm-car curr) item)) :finally (return curr))) (defun cvm-list-nreverse (list) (loop for prev = +cvm-nil+ then curr for curr = list then next for next = (cvm-cdr curr) until (cvm-null curr) do (cvm-setcdr curr prev) finally (return prev))) (defun cvm-list-delete-eq (list item) ;; list is a ct-nil or ct-address object. ;; item is a simple ct-* or a ct-address. (loop for prev = nil then curr for curr = list then (cvm-cdr curr) until (or (cvm-null curr) (eql (cvm-car curr) item)) finally (return (cond ((cvm-null curr) #| no item |# list #| unchanged |#) ((null prev) #| deleting the first item |# (cvm-cdr list)) (t (cvm-setcdr prev (cvm-cdr curr)) list))))) (defun cvm-make-list (&key length initial-element initial-contents) (setf length (or length (length initial-contents))) (cond ((zerop length) +cvm-nil+) (initial-contents (loop :with head = (cvm-make-cons (car initial-contents) +cvm-nil+) :with tail = head :with new = nil :for item in (cdr initial-contents) :repeat length :do (setf new (cvm-make-cons item +cvm-nil+)) (cvm-setcdr tail new) (setf tail new) :finally (return head))) (t (loop :with head = (cvm-make-cons initial-element +cvm-nil+) :with tail = head :with new = nil :repeat length :do (setf new (cvm-make-cons initial-element +cvm-nil+)) (cvm-setcdr tail new) (setf tail new) :finally (return head))))) ;; TODO: implement cvm-push and cvm-pop properly! (defmacro cvm-push (item list) (let ((vlist (gensym)) (vitem (gensym))) `(with-generation ((,vlist ,list) (,vitem ,item)) (setf ,list (cvm-make-cons ,vitem ,vlist))))) (defmacro cvm-pop (list) `(prog1 (cvm-car ,list) (setf ,list (cvm-cdr ,list)))) (defmacro cvm-dolist ((var list &optional (result nil)) &body body) (let ((vlist (gensym))) `(do* ((,vlist ,list (cvm-cdr ,vlist)) (,var (cvm-car ,vlist)(cvm-car ,vlist))) ((cvm-null ,vlist) ,result) ,@body))) ;;-------------------- ;; vector, vector-fp, structure, array: ;;-------------------- (defun bits-to-words (bits) "64 bit/word" (truncate (+ 63 bits) 64)) (defun cvm-bit-size-of-unboxed-type (typecode) (let ((size (if (<= ct-nil typecode ct-readable) (aref #( 0 ; ct-nil 64 ; ct-t 64 ; ct-free-block 1 ; ct-bit 8 ; ct-character-8 16 ; ct-character-16 32 ; ct-character-24 32 ; ct-character-32 8 ; ct-signed-byte-8 16 ; ct-signed-byte-16 32 ; ct-signed-byte-24 32 ; ct-signed-byte-32 64 ; ct-signed-byte-40 64 ; ct-signed-byte-48 64 ; ct-signed-byte-56 64 ; ct-signed-byte-64 8 ; ct-unsigned-byte-8 16 ; ct-unsigned-byte-16 32 ; ct-unsigned-byte-24 32 ; ct-unsigned-byte-32 64 ; ct-unsigned-byte-40 64 ; ct-unsigned-byte-48 64 ; ct-unsigned-byte-56 64 ; ct-unsigned-byte-64 8 ; ct-float-8 16 ; ct-float-16 32 ; ct-float-24 32 ; ct-float-32 64 ; ct-float-40 64 ; ct-float-48 64 ; ct-float-56 64 ; ct-float-64 -1 ; ct-structure -1 ; ct-vector -1 ; ct-vector-fp -1 ; ct-array 64 ; ct-address 64 ; ct-readable ) typecode) -1))) (when (minusp size) (error "CVM-BIT-SIZE-OF-UNBOXED-TYPE: invalid typecode ~D (~A)" typecode (cell-type-label typecode))) size)) ;; [ct-vector size ;; | [ element-type (T, unboxed-type) dimensions-1 ] ;; | data ] ;; ;; [ct-structure size ;; | ct-t dimensions-1 = nfields+1 ;; | class = field 0 ;; | data ] = field 1 .. nfields ;; ;; [ct-vector-fp size ;; | element-type (T, unboxed-type) dimensions-1 ;; | fill-pointer ;; | data ] ;; ;; [ct-array size ;; | element-type (T, unboxed-type) ndimensions ;; | dimension_1 | ... | dimension_n ;; | data ] ;; ;; symbol: ;; [structure-data 15 | [T,6] |NIL| package | name | value |NIL| plist ] ;; ;; CL:SYMBOL: ;; [structure-data 15 | [T,6] |NIL| @'COMMON-LISP' | @'SYMBOL' |NIL|NIL|NIL] (defun cvm-initialize-vector (address cell-type element-type dimension &key fill-pointer class) (let* ((address (cvm-deref address)) (ptr address)) (gc-store ptr (cvm-form-head cell-type (cvm-free-block-size (gc-load address)))) (gc-store (incf ptr) (cvm-form-head element-type dimension)) (when fill-pointer (gc-store (incf ptr) fill-pointer)) (when class (gc-store (incf ptr) class)) (dotimes (i (- (cvm-size-of (gc-load address)) (- ptr address) 1)) (gc-store (incf ptr) +cvm-nil+))) address) (defun cvm-vector-p (address) (and (not (cvm-null address)) (= (ldb +type-code+ (gc-load (cvm-deref address))) ct-vector))) (defun cvm-vector-fp-p (address) (and (not (cvm-null address)) (= (ldb +type-code+ (gc-load (cvm-deref address))) ct-vector-fp))) (defun cvm-structure-p (address) (and (not (cvm-null address)) (= (ldb +type-code+ (gc-load (cvm-deref address))) ct-structure))) (defun cvm-array-p (address) (and (not (cvm-null address)) (= (ldb +type-code+ (gc-load (cvm-deref address))) ct-array))) (defun cvm-element-type (address) (cvm-type-of (gc-load (1+ (cvm-deref address))))) (defun cvm-length (address) (cvm-fixnum-value (gc-load (1+ (cvm-deref address))))) (defun cvm-rows (address) (let ((address (cvm-deref address))) (case (cvm-type-of (gc-load address)) ((#.ct-vector #.ct-structure) (values (cvm-fixnum-value (gc-load (incf address))) (incf address))) ((#.ct-vector-fp) (values (cvm-fixnum-value (gc-load (incf address))) (incf address 2))) ((#.ct-array) (values (loop :for row-dimension = 1 :then (* row-dimension (cvm-fixnum-value (gc-load (incf address)))) :repeat (cvm-fixnum-value (gc-load (incf address))) :finally (return row-dimension)) (incf address))) (otherwise (error "CVM-ROWS: bad argument type ~A (~D)" (cell-type-label (cvm-type-code (gc-load address))) (cvm-type-code (gc-load address))))))) (defun cvm-set-fill-pointer (address fill-pointer) (setf address (cvm-deref address)) (assert (= ct-vector-fp (cvm-type-of (gc-load address)))) (gc-store (+ 2 address) (cvm-form-fixnum fill-pointer))) (defun cvm-fill-pointer (address) (setf address (cvm-deref address)) (assert (= ct-vector-fp (cvm-type-of (gc-load address)))) (cvm-fixnum-value (gc-load (+ 2 address)))) (defsetf cvm-fill-pointer cvm-set-fill-pointer) (defun cvm-make-vector (element-type dimension) (let ((address (gc-allocate (+ 2 (bits-to-words (* (cvm-bit-size-of-unboxed-type element-type) dimension)))))) (cvm-initialize-vector address ct-vector element-type dimension) (when-debug (:objects) (format t "~&object: ~16,'0X VECTOR~%" address)) address)) (defun cvm-make-vector-fp (element-type dimension &key (fill-pointer +cvm-nil+)) (let ((address (gc-allocate (+ 3 (bits-to-words (* (cvm-bit-size-of-unboxed-type element-type) dimension)))))) (cvm-initialize-vector address ct-vector-fp element-type dimension :fill-pointer fill-pointer) (when-debug (:objects) (format t "~&object: ~16,'0X VECTOR+FP~%" address)) address)) (defun cvm-vector-push (new-element vector) (unless (cvm-vector-fp-p vector) (error 'type-error :datum vector :expected-type 'ct-vector-fp)) (let ((fill-pointer (cvm-fill-pointer vector))) (when (< fill-pointer (cvm-length vector)) (progn (cvm-svset vector fill-pointer new-element) (cvm-set-fill-pointer vector (1+ fill-pointer)) new-element)))) (defun cvm-vector-pop (vector) (let ((fill-pointer (cvm-fill-pointer vector))) (when (zerop fill-pointer) (error "CVM-VECTOR-POP: the fill pointer of the vector ~X is 0." vector)) (cvm-svref vector fill-pointer))) (defun cvm-make-structure (class nbfields) (let ((address (gc-allocate (+ 3 nbfields)))) (cvm-initialize-vector address ct-structure ct-t (1+ nbfields) :class class) (when-debug (:objects) (format t "~&object: ~16,'0X STRUCTURE~%" address)) address)) ;; symbol: ;; [structure-data 15 | [T,6] |NIL| package | name | value |NIL| plist ] ;; ;; CL:SYMBOL: ;; [structure-data 15 | [T,6] |NIL| @'COMMON-LISP' | @'SYMBOL' |NIL|NIL|NIL] (defun cvm-svoperate (gc-address index operation &optional value) " DO: Perform a peek or a poke of the slot at INDEX in the array or structure at the GC-ADDRESS. GC-ADDRESS: A heap address (addressing 64-bit words), which is the base of the array or structure. INDEX: An index into te slots of the array or structure. The element size is taken from the gc-address element-type field. OPERATION: (member :peek :poke) indicates the operation to execute. VALUE: When OPERATION is :poke then the value to be stored. RETURN: When OPERATION is :peek, the value of the slot. " (let ((element-size (cvm-bit-size-of-unboxed-type (cvm-element-type gc-address)))) (multiple-value-bind (dimension gc-address) (cvm-rows gc-address) (unless (<= 0 index (1- dimension)) (error "SVREF: index out of bounds ~D [0,~D[" index dimension)) ;; element-size: 1 8 16 32 64 (if (= 1 element-size) (let* ((opaddr (+ *gc-heap-base* (* 8 (+ gc-address (/ index 64))))) (opofst (mod index 64)) (word (funcall (gc-peek-function 64) opaddr))) (if (eq operation :peek) (ldb (byte 1 opofst) word) (funcall (gc-poke-function 64) opaddr (dpb value (byte 1 opofst) word)))) (let ((opaddr (case element-size ((8) (+ *gc-heap-base* (* 8 gc-address ) index)) ((16) (+ *gc-heap-base* (* 8 gc-address ) (* 2 index))) ((32) (+ *gc-heap-base* (* 8 gc-address ) (* 4 index))) ((64) (+ *gc-heap-base* (* 8 (+ gc-address index)))) (otherwise "CVM-SVOPERATE: bad element-size ~D" element-size)))) (if (eq operation :peek) (funcall (gc-peek-function element-size) opaddr) (funcall (gc-poke-function element-size) opaddr value))))))) ;; (svref vector index) ;; (svset vector index value) (defun cvm-svref (address index) (cvm-svoperate address index :peek)) (defun cvm-svset (address index value) (cvm-svoperate address index :poke value)) (defun cvm-structure-ref (address index) (cvm-svoperate address index :peek)) (defun cvm-structure-store (address index value) (cvm-svoperate address index :poke value)) ;; -------------------- ;; strings ;; -------------------- (defun cvm-make-string (&key contents type length fill-pointer) (setf length (or length (length contents))) (let* ((chartype (cond ((null contents) (or type ct-character-32)) ((zerop (length contents)) ct-character-8) (t (loop :for ch :across contents :maximize (char-code ch) :into max :finally (return (cond ((< max 256) ct-character-8) ((< max 65536) ct-character-16) ((< max 16777216) ct-character-24) (t ct-character-32))))))) (string (if fill-pointer (cvm-make-vector-fp chartype length) (cvm-make-vector chartype length)))) (when fill-pointer (cvm-set-fill-pointer string fill-pointer)) (when contents (loop for i from 0 below length do (cvm-svset string i (char-code (aref contents i))))) (when-debug (:objects) (format t "~&object: ~16,'0X STRING ~S~%" string (cvm-string-value string))) string)) (defun cvm-string-p (address) (and (or (cvm-vector-p address) (cvm-vector-fp-p address)) (member (cvm-element-type address) +character-types+))) (defun cvm-string= (stra strb) (assert (cvm-string-p stra)) (assert (cvm-string-p strb)) (and (= (cvm-length stra) (cvm-length strb)) (loop for i from 0 below (cvm-length stra) do (unless (= (cvm-svref stra i) (cvm-svref strb i)) (return-from cvm-string= nil)) finally (return t)))) (defun cvm-string-value (address) (assert (cvm-string-p address)) (loop with string = (if (cvm-vector-fp-p address) (make-array (list (cvm-length address)) :element-type 'character :initial-element (character " ") :fill-pointer (cvm-fill-pointer address)) (make-string (cvm-length address))) for i from 0 below (cvm-length address) do (setf (aref string i) (code-char (cvm-svref address i))) finally (return string))) ;; -------------------- ;; symbols ;; -------------------- (defun cvm-make-symbol (name package &key (value +cvm-unbound+) (function +cvm-unbound+) (plist +cvm-nil+)) (let (common-lisp symbol sym) (if (cvm-null *gc-symbol*) (setf common-lisp (cvm-find-package "COMMON-LISP") symbol (cvm-find-symbol "SYMBOL" common-lisp)) (setf common-lisp (cvm-symbol-package *gc-symbol*) symbol *gc-symbol*)) (setf sym (cvm-make-structure symbol 5)) (cvm-symbol-set-package sym package) (cvm-symbol-set-name sym name) (cvm-symbol-set-value sym value) (cvm-symbol-set-function sym function) (cvm-symbol-set-plist sym plist) (when-debug (:objects) (format t "~&object: ~16,'0X SYMBOL ~S~%" sym (cvm-string-value name))) sym)) (defun cvm-symbol-bound-p (sym) (not (cvm-unbound-p (cvm-symbol-value sym)))) (defun cvm-symbol-fbound-p (sym) (not (cvm-unbound-p (cvm-symbol-function sym)))) (defun cvm-symbol-makunbound (sym) (cvm-symbol-set-value sym +cvm-unbound+)) (defun cvm-symbol-fmakunbound (sym) (cvm-symbol-set-function sym +cvm-unbound+)) (defgeneric cvm-find-symbol (name package) (:method ((name/symbol string) (name/package string)) (cvm-find-symbol (cvm-make-string :contents name/symbol) (cvm-find-package name/package))) (:method ((name/symbol string) (package integer)) (cvm-find-symbol (cvm-make-string :contents name/symbol) package)) (:method ((name integer) (name/package string)) (cvm-find-symbol name (cvm-find-package name/package))) (:method ((name integer) (package integer)) (cvm-dolist (sym (cvm-package-symbols package) nil) (when (cvm-string= name (cvm-symbol-name sym)) (return-from cvm-find-symbol (values sym :external)))))) (defgeneric cvm-intern (name package) (:method ((name integer) (package integer)) (multiple-value-bind (sym status) (cvm-find-symbol name package) (if sym (values sym status) (let ((sym (cvm-make-symbol name package))) (cvm-push sym (cvm-package-symbols package)) (values sym nil)))))) ;;-------------------- ;; packages ;;-------------------- (defun cvm-make-package (name &key (nicknames +cvm-nil+) (uses +cvm-nil+)) (let* ((common-lisp (if (cvm-null *gc-symbol*) (cvm-find-package "COMMON-LISP") (cvm-symbol-package *gc-symbol*))) (package (if (cvm-null *gc-package*) (cvm-find-symbol "PACKAGE" common-lisp) *gc-package*)) (pack (cvm-make-structure package 5))) (cvm-package-set-name pack name) (cvm-package-set-nicknames pack nicknames) (cvm-package-set-uses pack uses) (gc-push-root pack) (when-debug (:objects) (format t "~&object: ~16,'0X PACKAGE ~S~%" pack (cvm-string-value name))) pack)) (defmacro %and (&rest conjonctions) `(and ,@(mapcar (lambda (conj) (let ((vconj (gensym))) `(let ((,vconj ,conj)) (format t "~S ==> ~A~%" ',conj ,vconj) ,vconj))) conjonctions))) (defgeneric cvm-find-package (name) (:method ((name/package string)) (cvm-find-package (cvm-make-string :contents name/package))) (:method ((name integer)) (flet ((%package-p (self) (and (cvm-structure-p self) (= 6 (cvm-length self)) (= ct-t (cvm-element-type self)) (let ((stype (cvm-structure-ref self 0))) (and (cvm-structure-p stype) (= 6 (cvm-length stype)) (= ct-t (cvm-element-type stype)) (if (cvm-null *gc-package*) (and (string= "PACKAGE" (cvm-string-value (cvm-symbol-name stype))) (string= "COMMON-LISP" (cvm-string-value (cvm-package-name (cvm-symbol-package stype))))) (= *gc-package* stype))))))) (cvm-dolist (item (cvm-hh-root +gc-heap-header+) +cvm-nil+) ;; (format t "~A P/~A~%" (cvm-string-value (cvm-package-name item)) ;; (%package-p item)) (when (and (%package-p item) (cvm-string= name (cvm-package-name item))) (return-from cvm-find-package item)))))) (defgeneric cvm-delete-package (package) (:method ((name/package string)) (cvm-delete-package (cvm-make-string :contents name/package))) (:method ((package integer)) (if (or (eql package (cvm-find-package "COMMON-LISP")) (eql package (cvm-find-package "SYSTEM")) (not (cvm-member-eq package (cvm-hh-root +gc-heap-header+)))) nil (progn (loop for symbols = (cvm-package-symbols package) then (cvm-cdr symbols) do (cvm-symbol-set-package (cvm-car symbols) +cvm-nil+)) (gc-delete-from-root package) t)))) (defun cvm-list-all-packages () (loop for items = (cvm-hh-root +gc-heap-header+) then (cvm-cdr items) until (cvm-null items) when (cvm-package-p (cvm-car items)) collect (cvm-car items))) ;;-------------------- ;; dump & check ;;-------------------- (defun gc-dump-object (object &key (stream *standard-output*) (comment "") (address nil)) (declare (ignore comment)) (setf address (and address (cvm-deref address))) (format stream "~A~16,'0X M/~1D C/~1D T/~2D V/~17,'0D ~A~A~%" (if address (format nil "~8,'0X: " address) "") object (ldb +in-mark+ object) (ldb +in-cons+ object) (ldb +type-code+ object) (ldb +byte-56+ object) (cell-type-label (ldb +type-code+ object)) "" #| comment |#)) (defun gc-dump-cell (address &key (stream *standard-output*) (contents t) (margin "")) (setf address (cvm-deref address)) (flet ((dump (address object &optional (comment "")) (gc-dump-object object :stream stream :comment comment :address address)) (dump-free (address object &optional (comment "")) (declare (ignore comment)) (format stream "~8,'0X: ~16,'0X M/~1D C/~1D T/~2D S/~7,'0D N/~7,'0D ~A~A~%" address object (ldb +in-mark+ object) (ldb +in-cons+ object) (ldb +type-code+ object) (ldb +fb-size+ object) (ldb +fb-next+ object) (cell-type-label (ldb +type-code+ object)) "" #| comment |#))) (if (zerop address) (format stream "~8,'0X = NIL~%" 0) (let ((object (gc-load address))) (case (cvm-type-of object) ((#.ct-cons) (dump address (gc-load address ) "[CDR]") (format stream "~A" margin) (dump (1+ address) (gc-load (1+ address)) "[CAR]")) ((#.ct-free-block) (dump-free address (gc-load address ) "[tc|sz]")) ((#.ct-structure #.ct-vector #.ct-vector-fp #.ct-array) (dump address (gc-load address ) "[tc|sz]") (format stream "~A" margin) (dump (1+ address) (gc-load (1+ address)) "[el|dm]") (if (= ct-t (cvm-type-of (gc-load (1+ address)))) (when contents (loop :for address from (+ 2 address) :repeat (- (cvm-size-of object) 2) :do (format stream "~A" margin) (gc-dump-cell address :stream stream :margin margin))) (gc-dump-block (+ 2 address) (- (cvm-size-of object) 2) stream :margin margin))) (otherwise (dump address (gc-load address )))))))) (defun gc-dump-root (&key (stream *standard-output*)) (cvm-dolist (e (cvm-hh-root +gc-heap-header+)) (gc-dump-cell e) (princ (cvm-string-value (cvm-package-name e)) stream) (terpri stream) (terpri stream) (unless (cvm-null (cvm-structure-ref e 0)) (gc-dump-cell (cvm-structure-ref e 0)) (princ (cvm-string-value (cvm-symbol-name (cvm-structure-ref e 0))) stream) (terpri stream)(terpri stream)) (terpri stream))) (defmacro cvm-do-symbols ((vsym package) &body body) (let ((vpack (gensym)) (epack (gensym))) `(let ((,vpack ,package)(,epack)) (cond ((stringp ,vpack) (setf ,epack (cvm-find-package ,vpack))) ((cvm-string-p ,vpack) (setf ,epack (cvm-find-package (cvm-string-value ,vpack)))) (t (setf ,epack ,vpack))) (unless (cvm-null ,epack) (error "Inexistent package ~A" ,vpack)) (cvm-dolist (,vsym (cvm-package-symbols ,vpack)) ,@body)))) ;;-------------------- ;; We use this bitmap only to check the heap, not for the garbage collection. ;;-------------------- (defun gc-make-bitmap () (make-array (list *gc-heap-size*) :element-type '(unsigned-byte 2) :initial-element 0)) (defun print-bitmap (bitmap &key (stream *standard-output*) (start 0) (end (length bitmap))) (loop for i from start below end for c = (aref bitmap i) initially (unless (zerop (mod i 64)) (format stream "~&~8,'0X: " i)) do (when (zerop (mod i 64)) (format stream "~&~8,'0X: " i)) (princ (aref "GFAV" c) stream) finally (terpri stream))) (defun gc-bitmap-set-free (bitmap address) (assert (zerop (aref bitmap address))) (setf (aref bitmap address) 1)) (defun gc-bitmap-set-allocated (bitmap address) (assert (zerop (aref bitmap address))) (setf (aref bitmap address) 2)) (defun gc-bitmap-set-allocated-range (bitmap address size) (loop :for i :from address :repeat size :do (assert (evenp (aref bitmap i))) ; 0 or 2 (setf (aref bitmap i) 2))) (defun gc-bitmap-set-visited (bitmap address) (assert (= 2 (aref bitmap address))) (setf (aref bitmap address) 3)) (defun gc-bitmap-set-visited-range (bitmap address size) (loop :for i :from address :repeat size :do (assert (= 2 (aref bitmap i))) (setf (aref bitmap i) 3))) (defun gc-bitmap-clear-p (bitmap address) (= 0 (aref bitmap address))) (defun gc-bitmap-free-p (bitmap address) (= 1 (aref bitmap address))) (defun gc-bitmap-allocated-p (bitmap address) (<= 2 (aref bitmap address))) (defun gc-bitmap-visited-p (bitmap address) (= 3 (aref bitmap address))) ;;-------------------- ;; checking the heap ;;-------------------- (defun gc-check-free-block-list (fbln fbl &key (stream *standard-output*) (dump-free nil) (bitmap nil)) " RETURN: the number of blocs, the total size of blocks. RAISE: simple-error conditions when an invariant is invalidated. " (assert (or (cvm-null fbl) (cvm-address-p fbl))) (when dump-free (format stream " [~2,'0X] " fbln) (gc-dump-cell (cvm-deref fbl))) (if (cvm-address-p fbl) (loop for count from 0 for size = 0 for fbp = (cvm-deref fbl) then (cvm-free-block-next fb) for fb = (when (plusp fbp) (gc-load fbp)) while (plusp fbp) do (progn (when dump-free (gc-dump-cell fbp :stream stream)) (unless (cvm-free-block-p fb) (gc-dump-cell fbl) (assert nil () "~D~[th~;st~;nd~:;th~] free block in ~ free block list ~D is not a free-block ~ record at #x~8,'0X~% It's ~16,'0X (~A)~%" count (mod count 10) fbln (cvm-deref fbl) fb (cell-type-label (cvm-type-of fb)))) (assert (<= 1 (cvm-free-block-size fb) (- *gc-heap-size* fbp))) ;; Most free blocs are (<= 2 size) but un-linked free-blocks ;; of size 1 can happen. (incf size (cvm-free-block-size fb)) ;; check the free cells are not already taken, and mark them: (when bitmap (when-debug (:bitmap) (format t "fill bitmap free from ~X to ~X~%" fbp (+ fbp (cvm-free-block-size fb)))) (loop for i from fbp below (+ fbp (cvm-free-block-size fb)) do (gc-bitmap-set-free bitmap i)))) finally (values count size)) (values 0 0))) (defun gc-check-tree (root-address &key (stream *standard-output*) (allow-free-blocks nil) (bitmap nil) (dump-allocated nil) (dump-data nil)) ;; root-address is a gc-address (loop with referenced = (if allow-free-blocks (cons ct-free-block +referenced-cell-types+) +referenced-cell-types+) with bitmap = (or bitmap (gc-make-bitmap)) with addresses = (list root-address) for address = (pop addresses) for object = (when address (gc-load address)) while address do (when-debug (:gcct) (let ((*print-base* 16))(format t " gcct: addresses = ~S~%" addresses)) (format t " gcct: address = ~X~%" address)) (assert (< 0 address *gc-heap-size*)) (assert (gc-bitmap-allocated-p bitmap address)) (when-debug (:gc) (when (or (cvm-address-p address) (cvm-readable-p address)) (gc-dump-cell (cvm-deref address) :stream *trace-output* :contents nil))) (unless (gc-bitmap-visited-p bitmap address) (when-debug (:gcct) (format t " gcct: was not already visited~%")) (flet ((follow (addrobj) (let ((address (cvm-deref addrobj))) (when-debug (:gcct) (format t " gcct: follow ~16,'0X M/~A V/~A~%" addrobj (member (cvm-type-code addrobj) +address-cell-types+) (when (member (cvm-type-code addrobj) +address-cell-types+) (not (gc-bitmap-visited-p bitmap address))))) (when (and (member (cvm-type-code addrobj) +address-cell-types+) (not (gc-bitmap-visited-p bitmap address))) (let ((object (gc-load address))) (assert (member (cvm-type-of object) referenced)) (gc-bitmap-set-allocated-range bitmap address (cvm-size-of object)) (push address addresses) (when-debug (:gcct) (format t " gcct: new addresses = ~S~%" addresses))))))) (when-debug (:gcct) (format t " gcct: object=~X~%" object)) (case (cvm-type-of object) ;; -------------------- free block ((#.ct-free-block) ; Bad! (unless allow-free-blocks (assert nil () "Found a free-block in allocated data at #x~8,'0X" address))) ;; -------------------- address & readable ((#.ct-address #.ct-readable) (when (or dump-allocated dump-data) (gc-dump-cell address :stream stream)) (push (cvm-deref object) addresses) (gc-bitmap-set-visited bitmap address)) ; size = 1 ;; -------------------- simple cells (#.(cons ct-unbound +simple-types+) (when (or dump-allocated dump-data) (gc-dump-cell address :stream stream)) (gc-bitmap-set-visited bitmap address)) ; size = 1 ;; -------------------- cons cells ((#.ct-cons) (when (or dump-allocated dump-data) (gc-dump-cell address :stream stream)) ; dumps CAR and CDR (follow object) ; CDR (follow (gc-load (1+ address))) ; CAR (gc-bitmap-set-visited-range bitmap address 2)) ; size = 2 ;; -------------------- structures and vectors ((#.ct-structure #.ct-vector #.ct-vector-fp #.ct-array) (when-debug (:gcct) (format t " gcct: is a structure~%")) (when (or dump-allocated dump-data) (gc-dump-cell address :stream stream :contents nil)) (when (member (cvm-element-type address) +complex-element-types+) ;; TODO: This condition is messy. Arrays of arrays of strings? ;; TODO: We could push only a descriptor for the range, ;; TODO: and decrement the range on pop. (loop for address from (+ address (cvm-size-of object) -1) downto (+ 2 address) do (follow (gc-load (cvm-deref address))))) (when-debug (:gcct) (format t " gcct: new addresses = ~S~%" addresses)) (gc-bitmap-set-visited-range bitmap address (cvm-size-of object))) ;; -------------------- errors (otherwise (assert nil () "Unknown type-code ~D at #x~8,'0X" (cvm-type-of object) address))))) finally (return bitmap))) (defun gc-check-internal (&key (stream *standard-output*) (allow-free-blocks nil) (dump-all nil) (dump-bitmap nil) (dump-header nil) (dump-free nil) (dump-allocated nil) (dump-data nil)) (when dump-all (setf dump-header t dump-bitmap t dump-free t dump-allocated t dump-data t)) (assert (plusp *gc-heap-base*)) (when dump-header (format stream "~&Heap header:~%") (format stream " base address = #x~8,'0X~%" *gc-heap-base*) (format stream " magic cookie = #x~16,'0X~%" (gc-signature)) (format stream " cell 1 = #x~16,'0X~%" (peek-uint64 *gc-memory* *gc-heap-base*))) ;; check the header structure: (assert (= (gc-load +gc-heap-header+) (cvm-form-head ct-structure 8))) (assert (= (gc-load (1+ +gc-heap-header+)) (cvm-form-head ct-t 6))) ;; check the header slots: (assert (and (cvm-fixnum-p (cvm-hh-size +gc-heap-header+)) (= *gc-heap-size* (cvm-fixnum-value (cvm-hh-size +gc-heap-header+))))) (assert (cvm-vector-p (cvm-hh-free-blocks +gc-heap-header+))) (assert (or (cvm-null (cvm-hh-root +gc-heap-header+)) (cvm-cons-p (cvm-hh-root +gc-heap-header+)))) (assert (or (cvm-null (cvm-hh-new-generation +gc-heap-header+)) (cvm-vector-fp-p (cvm-hh-new-generation +gc-heap-header+)))) (when dump-header (format stream " heap size = #x~8,'0X (~D) 64-bit cells~%" *gc-heap-size* *gc-heap-size*) (format stream " free-blocks at #x~8,'0X~%" (cvm-deref (cvm-hh-free-blocks +gc-heap-header+))) (format stream " variables at #x~8,'0X~%" (cvm-deref (cvm-hh-root +gc-heap-header+))) (format stream " new-generation at #x~8,'0X~%" (cvm-deref (cvm-hh-new-generation +gc-heap-header+)))) ;; check the free block vector: (let ((fb (cvm-deref (cvm-hh-free-blocks +gc-heap-header+)))) (when (/= fb +gc-expected-free-block+) (format stream "Warning: free-blocks vector moved to #x~8,'0X~%" fb)) (assert (= (gc-load fb) (cvm-form-head ct-vector 34))) (assert (= (gc-load (1+ fb)) (cvm-form-head ct-t 32))) (let ((bitmap (gc-make-bitmap))) (gc-bitmap-set-allocated-range bitmap +gc-heap-header+ (cvm-size-of (gc-load +gc-heap-header+))) (gc-bitmap-set-allocated-range bitmap fb (cvm-size-of (gc-load fb))) (gc-bitmap-set-visited-range bitmap fb (cvm-size-of (gc-load fb))) ;; check the free block lists: (when dump-header (format stream "Free lists:~%")) (loop for i from 0 upto +fb-big+ do ;; (format t "checking free block list ~D~%" i) (gc-check-free-block-list i (cvm-svref fb i) :stream stream :bitmap bitmap :dump-free dump-free)) ;; check the allocated data: (when dump-header (format stream "Variables & New Generation:~%")) (gc-check-tree +gc-heap-header+ :stream stream :allow-free-blocks allow-free-blocks :bitmap bitmap :dump-allocated dump-allocated :dump-data dump-data) ;; check the bitmap: no clear bit above +gc-start+ (when dump-bitmap (print-bitmap bitmap :stream stream)) (loop with i = +gc-start+ while (< i *gc-heap-size*) do (if (gc-bitmap-clear-p bitmap i) (let ((end (loop for j from i while (and (< j *gc-heap-size*) (gc-bitmap-clear-p bitmap j)) finally (return j)))) (when dump-bitmap (format stream "gc-check: Found a garbage range #x~8,'0X - #x~8,'0X~%" i (1- end))) (setf i end)) (incf i)))))) (defun gc-check (&key (stream *standard-output*) (allow-free-blocks nil) (dump-all nil) (dump-bitmap nil) (dump-header nil) (dump-free nil) (dump-allocated nil) (dump-data nil)) (when dump-all (setf dump-header t dump-bitmap t dump-free t dump-allocated t dump-data t)) ;; assume *gc-semaphore-set* and *gc-semaphore-number* are valid. (with-gc-lock (gc-check-internal :stream stream :allow-free-blocks allow-free-blocks :dump-header dump-header :dump-bitmap dump-bitmap :dump-free dump-free :dump-allocated dump-allocated :dump-data dump-data))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; GARBAGE COLLECTOR ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; --------------------------------------------------------------------- ;; allocate: ;; case big block: ;; 1- search a block of same size ;; 2- search a block of double size ;; 3- search a best fit block (size+2+) ;; 4- search a bigger block (size+1+) ;; 5- if not already gc in this allocate, ;; then garbage collect and try once more from the start. ;; 6- fail ;; case small block: ;; 1- search a block in the same bucket. ;; 2- search a block in bucket 2*idx if < 31, or in big blocks. ;; 3- search a best fit block (size+2+), from idx+2, idx+3, ..., in big blocks. ;; 4- search a bigger block (size+1+), seach idx+1. ;; 5- if not already gc in this allocate, ;; then garbage collect and try once more from the start. ;; 6- fail ;; --------------------------------------------------------------------- ;; garbage collect: ;; - no copying collector, to avoid having to update the references ;; in other spaces. ;; - mark: recursively work from root and mark all accessible. ;; - sweep: start from first cell, and in sequence, check whether it's marked, ;; and gather free ranges. ;; --------------------------------------------------------------------- (defun fb-extract (free-blocks previous old-block size) (when-debug (:allocate) (format t "fb-extract F/#x~16,'0X P/~A ~@ ~& O/#x~16,'0X S/#x~8,'0X~%" free-blocks (if previous (format nil "#x~16,'0X" previous) "") old-block size) (gc-dump-cell old-block)) (if previous (cvm-free-block-set-next previous old-block) (cvm-svset free-blocks size (cvm-form-address (cvm-free-block-next old-block))))) (defun fb-insert (free-blocks new-block) (when-debug (:allocate) (format t "fb-insert F/#x~16,'0X N/#x~16,'0X~%" free-blocks new-block)) (assert (cvm-free-block-p (gc-load new-block))) (let ((size (cvm-free-block-size (gc-load new-block)))) (if (< size +fb-big+) (progn (cvm-free-block-set-next new-block (cvm-deref (cvm-svref free-blocks size))) (cvm-svset free-blocks size (cvm-form-address new-block))) (loop for prev = nil then curr for curr = (cvm-deref (cvm-svref free-blocks +fb-big+)) then (cvm-free-block-next curr) while (and (plusp curr) (< size (cvm-free-block-size (gc-load curr)))) finally (cvm-free-block-set-next new-block curr) (if prev (cvm-free-block-set-next prev new-block) (cvm-svset free-blocks +fb-big+ (cvm-form-address new-block)))))) (when-debug (:allocate) (gc-dump-cell new-block))) (defun fb-search-big-block (free-list size) (loop with previous = nil with fit = nil ; size with double = nil ; size*2 with best = nil ; size+2+n with bigger = nil ; size+1 for prev = nil then curr for curr = free-list then (cvm-free-block-next curr) for obje = (if (plusp curr) (gc-load curr) 0) while (and (plusp curr) (null best)) do ;; (gc-dump-cell curr) ;; (format t "~X ~D ~D~%" obje(cvm-free-block-size obje) size) (cond ((and (not fit) (= size (cvm-free-block-size obje))) (when-debug (:allocate) (format t "fb-search-big-block #x~16,'0X #x~8,'0X ~@ found fit #x~16,'0X ~:[P/NIL~;~:*P/#x~16,'0X~]~%" free-list size curr (or previous prev))) (setf fit curr previous (or previous prev))) ((and (not double) (= (* size 2) (cvm-free-block-size obje))) (when-debug (:allocate) (format t "fb-search-big-block #x~16,'0X #x~8,'0X ~@ found double #x~16,'0X ~:[P/NIL~;~:*P/#x~16,'0X~]~%" free-list size curr (or previous prev))) (setf double curr previous (or previous prev))) ((and (not best) (<= (+ size 2) (cvm-free-block-size obje))) (when-debug (:allocate) (format t "fb-search-big-block #x~16,'0X #x~8,'0X ~@ found best #x~16,'0X ~:[P/NIL~;~:*P/#x~16,'0X~]~%" free-list size curr (or previous prev))) (setf best curr previous (or previous prev))) ((and (not bigger) (< size (cvm-free-block-size obje))) (when-debug (:allocate) (format t "fb-search-big-block #x~16,'0X #x~8,'0X ~@ found bigger #x~16,'0X ~:[P/NIL~;~:*P/#x~16,'0X~]~%" free-list size curr (or previous prev))) (setf bigger curr previous (or previous prev)))) finally (return (values previous fit double best bigger)))) ;;fb-search-big-block (defun gc-allocate-internal (size) (when (< size 2) (setf size 2)) (let* ((garbage-collected nil) (free-blocks (cvm-deref (cvm-hh-free-blocks +gc-heap-header+))) (idx (min size +fb-big+)) (free-list (cvm-deref (cvm-svref free-blocks idx))) prev fit double best bigger (big-searched nil)) (macrolet ((return-fit (found size) ;; nothing more, return fit `(progn (when-debug (:allocate) (format t "gc-allocate #x~8,'0X ~@ found a fit #x~16,'0X~%" ,size ,found)) (return-from gc-allocate-internal ,found))) (return-double (found size) ;; split in two, fb-insert one, return the other `(let* ((half (/ (cvm-free-block-size (gc-load ,found)) 2)) (free (+ ,found half))) (gc-store free (cvm-form-free-block half 0)) (fb-insert free-blocks free) (cvm-free-block-set-size ,found half) (when-debug (:allocate) (format t "gc-allocate #x~8,'0X ~@ found a double #x~16,'0X F/#x~16,'0X~%" ,size ,found free)) (return-from gc-allocate-internal ,found))) (return-best (found size) ;; split in two, fb-insert the rest, return the one `(let ((free (+ ,found ,size))) (gc-store free (cvm-form-free-block (- (cvm-free-block-size (gc-load ,found)) ,size) 0)) (fb-insert free-blocks free) (cvm-free-block-set-size ,found ,size) (when-debug (:allocate) (format t "gc-allocate #x~8,'0X ~@ found a best #x~16,'0X F/#x~16,'0X~%" ,size ,found free)) (return-from gc-allocate-internal ,found))) (return-bigger (found size) ;; split in two, forget the smaller, return the one ;; lose the 8-byte trailer. ;; (split to put a free-block header in it though!) `(let ((free (+ ,found ,size))) (gc-store free (cvm-form-free-block (- (cvm-free-block-size (gc-load ,found)) ,size) 0)) (cvm-free-block-set-size ,found ,size) (when-debug (:allocate) (format t "gc-allocate #x~8,'0X ~@ found a bigger #x~16,'0X L/#x~16,'0X~%" ,size ,found free)) (return-from gc-allocate-internal ,found)))) (tagbody (when-debug (:allocate) (go :first-time)) :again (when-debug (:allocate) (format t "gc-allocate #x~16,'0X trying again~%" size)) :first-time (when (= idx +fb-big+) ;; big block (when-debug (:allocate) (format t "gc-allocate #x~16,'0X searching a big block~%" size)) (multiple-value-bind (prev fit double best bigger) (fb-search-big-block free-list size) (let ((found (or fit double best bigger))) (when found (fb-extract free-blocks prev found +fb-big+) (cond (fit (return-fit found size)) (double (return-double found size)) (best (return-best found size)) (t (return-bigger found size)))) (go :collect)))) ;; small block (when-debug (:allocate) (format t "gc-allocate #x~16,'0X searching a small block~%" size)) ;; 1- search a block in the same bucket. (when (plusp free-list) (fb-extract free-blocks nil free-list size) (return-fit free-list size)) ;; 2- search a block in bucket 2*size if<+fb-big+, or in big blocks. (when-debug (:allocate) (format t "gc-allocate #x~16,'0X searching a double~%" size)) (if (< (* 2 size) +fb-big+) (let ((free-list (cvm-deref (cvm-svref free-blocks (* 2 size))))) (when (plusp free-list) (fb-extract free-blocks nil free-list (* 2 size)) (return-double free-list size))) (let ((free-list (cvm-deref (cvm-svref free-blocks +fb-big+)))) (multiple-value-setq (prev fit double best bigger) (fb-search-big-block free-list size)) (setf big-searched t) (when double (fb-extract free-blocks prev double +fb-big+) (return-double double size)))) ;; 3- search a best fit block (size+2+), from idx+2,...,in big blks (when-debug (:allocate) (format t "gc-allocate #x~16,'0X searching a best fit~%" size)) (loop for sidx from (+ 2 idx) to +fb-big+ for free-list = (cvm-deref (cvm-svref free-blocks sidx)) do (when-debug (:allocate) (format t "try [~2,'0X]:" sidx) (gc-dump-cell free-list)) (when (plusp free-list) (if (= sidx +fb-big+) (progn (when-debug (:allocate) (format t "gc-allocate big-searched=~A~%" big-searched)) (unless big-searched (multiple-value-setq (prev fit double best bigger) (fb-search-big-block free-list size)) (setf big-searched t)) (when-debug (:allocate) (when prev (format t "gc-allocate previous:~%") (gc-dump-cell prev)) (when fit (format t "gc-allocate fit:~%") (gc-dump-cell fit)) (when double (format t "gc-allocate double:~%") (gc-dump-cell double)) (when best (format t "gc-allocate best:~%") (gc-dump-cell best)) (when bigger (format t "gc-allocate bigger:~%") (gc-dump-cell bigger))) (when best ;; found (fb-extract free-blocks prev best sidx) (return-best best size))) (progn ;; found (fb-extract free-blocks nil free-list sidx) (return-best free-list size))))) ;; 4- search a bigger block (size+1+), seach idx+1. (when-debug (:allocate) (format t "gc-allocate #x~16,'0X searching a bigger~%" size)) (when (< idx 30) (incf idx) (let ((free-list (cvm-deref (cvm-svref free-blocks idx)))) (when (plusp free-list) ;; found! (fb-extract free-blocks nil free-list idx) (return-best free-list size)))) :collect ;; 5- if not already gc in this allocate, ;; then garbage collect and try once more from the start. (unless garbage-collected (when-debug (:allocate) (format t "gc-allocate #x~16,'0X calling garbage collector~%" size)) (gc-collect-internal) (setf garbage-collected t big-searched nil) (go :again)) ;; 6- fail (error "Out of COMMON memory."))))) (defun gc-allocate (size) ;; size = number of 8-byte cells to allocate, from 2 up. (with-gc-lock (when-debug (:check) (format *standard-output* "~&gc-allocate ~A~%Check before allocate~%" size) (apply (function gc-check-internal) :stream *standard-output* *check-args*)) (prog1 (let ((allocated (cvm-form-address (gc-allocate-internal size))) (generation (cvm-hh-new-generation +gc-heap-header+))) (unless (cvm-null generation) (when-debug (:ng) (format t "ng:push [~2D] ~16,'0X~%" (cvm-fill-pointer generation) allocated)) (cvm-vector-push allocated generation)) allocated) (when-debug (:check) (format *standard-output* "~&Check after allocate~%") (apply (function gc-check-internal) :allow-free-blocks t :stream *standard-output* *check-args*))))) (defun gc-mark (address) (case (cvm-type-of address) ((#.ct-cons #.ct-vector #.ct-vector-fp #.ct-structure #.ct-array) (when-debug (:gc) (warn "gc-mark got a complex object instead of a ct-address.~%"))) ((#.ct-free-block) (when-debug (:gc) (warn "gc-mark got a free-block ~A.~%" (with-output-to-string (out) (gc-dump-cell address :stream out :contents nil))))) ((#.ct-address #.ct-readable) ;; Reference values are addresses to the real value which needs a mark. (let ((object (gc-load (cvm-deref address)))) (unless (gc-marked object) (flet ((mark (address object) (when-debug (:gc) (format *trace-output* "~&M ") (gc-dump-cell address :stream *trace-output* :contents t :margin " ")) (gc-store (cvm-deref address) (gc-set-mark object)))) (case (cvm-type-of object) ((#.ct-address #.ct-readable) (when-debug (:gc) (warn "gc-mark got an indirection, ~A to ~A~%~@ ~@{~A~%~}" (cell-type-label (cvm-type-of address)) (cell-type-label (cvm-type-of object)) (with-output-to-string (out) (gc-dump-cell address :stream out :contents nil)) (with-output-to-string (out) (gc-dump-cell object :stream out :contents nil)))) ;; this should not occur, but let's do it anyway. (mark address object) (gc-mark object)) ((#.ct-cons) (mark address object) (gc-mark (cvm-car address)) (gc-mark (cvm-cdr address))) ((#.ct-vector #.ct-vector-fp #.ct-structure #.ct-array) ;; [[vector-data|structure-data] size ;; | [ element-type (T, unboxed-type) dimensions-1 ] ;; | data ] ;; [vector-fp-data size ;; | [ element-type (T, unboxed-type) dimensions-1 ] ;; | fill-pointer ;; | data ] ;; [array-data size ;; | [ element-type (T, unboxed-type) ndimensions ] ;; | dimension_1 | ... | dimension_n ;; | data ] (mark address object) (let ((element-type (cvm-element-type address))) (cond ((= ct-t element-type) ;; elements can be anything (multiple-value-bind (dimension address) (cvm-rows address) (loop for address from address below (+ address dimension) do (gc-mark (gc-load address)))))))) ;; otherwise plain simple values don't need a mark ;; since they are boxed. ))))) ;; otherwise plain simple values don't need a mark ;; since they are boxed. )) (defun gc-sweep () ;; - sweep: start from first cell, and in sequence, check whether ;; it's marked, and gather free ranges. (let ((free-blocks (cvm-deref (cvm-hh-free-blocks +gc-heap-header+)))) (multiple-value-bind (dimension address) (cvm-rows free-blocks) (loop for i from 0 below dimension do (gc-store address +cvm-nil+) (incf address))) (loop with free-start = nil for curadr = +gc-start+ then (+ curadr (cvm-size-of curobj)) for curobj = (when (< curadr *gc-heap-size*) (gc-load curadr)) while (< curadr *gc-heap-size*) do (if (gc-marked curobj) (progn (when-debug (:gc) (format *trace-output* "~&V ") (gc-dump-cell curadr :stream *trace-output* :margin " ")) (gc-store curadr (gc-clear-mark curobj)) (when free-start (gc-store free-start (cvm-form-free-block (- curadr free-start) 0)) (fb-insert free-blocks free-start) (when-debug (:gc) (format *trace-output* "~&C ") (gc-dump-cell free-start :stream *trace-output* :margin " ")) (setf free-start nil))) (setf free-start (or free-start curadr))) finally (when free-start (gc-store free-start (cvm-form-free-block (- curadr free-start) 0)) (fb-insert free-blocks free-start) (when-debug (:gc) (format *trace-output* "~&C ") (gc-dump-cell free-start :stream *trace-output* :margin " ")) (setf free-start nil))))) ;;gc-sweep (defun gc-collect-internal () ;; gc lock is already aquired. ;; garbage collect: ;; - no copying collector, to avoid updating the references in other spaces. ;; - mark: recursively work from root and mark all accessible. ;; - sweep: start from first cell, and in sequence, check whether ;; it's marked, and gather free ranges. (when-debug (:gc :check) (format *trace-output* "~&Check before garbage collection~%") (apply (function gc-check-internal) :stream *trace-output* *check-args*)) (when-debug (:gc) (format *trace-output* "~&Marking root~%")) (gc-mark (cvm-hh-root +gc-heap-header+)) (when-debug (:gc) (format *trace-output* "~&Marking new generation~%")) (gc-mark (cvm-hh-new-generation +gc-heap-header+)) (when-debug (:gc) (format *trace-output* "~&Sweeping~%")) (gc-sweep) (when-debug (:gc :check) (format *trace-output* "~&Check after garbage collection~%") (apply (function gc-check-internal) :stream *trace-output* *check-args*))) ;;gc-collect-internal (defun gc-collect-garbage () (with-gc-lock (gc-collect-internal))) ;;-------------------------- (defun gc-initialized-p () (= (gc-signature) *gc-magic-cookie*)) (defun gc-initialize (memory) " DO: Initialize the heap in *gc-memory*. " (setf *gc-memory* memory *gc-heap-base* (base memory) *gc-heap-size* (truncate (size memory) 8)) (unless (gc-initialized-p) (with-common-lock (gc-store +gc-heap-header+ (cvm-form-head ct-structure 8)) (cvm-initialize-vector +gc-heap-header+ ct-structure ct-t 6) (cvm-hh-set-size +gc-heap-header+ (cvm-form-fixnum *gc-heap-size*)) (let ((fbv (+ +gc-heap-header+ (cvm-size-of (gc-load +gc-heap-header+))))) (cvm-hh-set-free-blocks +gc-heap-header+ (cvm-form-address fbv)) ;; (cvm-initialize-vector stores NIL/0 in the slots) (gc-store fbv (cvm-form-head ct-vector 34)) (cvm-initialize-vector fbv ct-vector ct-t 32) (let ((ptr (+ fbv (cvm-size-of (gc-load fbv))))) (gc-store ptr (cvm-form-free-block (- 64 ptr) 0)) (fb-insert fbv ptr) (setf ptr 64) (gc-store ptr (cvm-form-free-block (- 128 ptr) 0)) (fb-insert fbv ptr) (setf ptr 128) (gc-store ptr (cvm-form-free-block (- *gc-heap-size* ptr) 0)) (fb-insert fbv ptr))) (cvm-hh-set-new-generation +gc-heap-header+ (cvm-make-vector-fp ct-t +ng-size+ :fill-pointer (cvm-form-fixnum 0))) (let* ((name/common-lisp (cvm-make-string :contents "COMMON-LISP")) (name/symbol (cvm-make-string :contents "SYMBOL")) (name/package (cvm-make-string :contents "PACKAGE")) (symbol (cvm-make-structure +cvm-nil+ 5)) (package (cvm-make-structure symbol 5)) (common-lisp (cvm-make-structure package 5))) (setf *gc-symbol* symbol) (setf *gc-package* package) (cvm-symbol-set-package symbol common-lisp) (cvm-symbol-set-name symbol name/symbol) (cvm-symbol-set-package package common-lisp) (cvm-symbol-set-name package name/package) (cvm-package-set-name common-lisp name/common-lisp) (cvm-structure-store symbol 0 symbol) (cvm-structure-store package 0 symbol) (cvm-structure-store common-lisp 0 package) (cvm-push package (cvm-package-symbols common-lisp)) (cvm-push symbol (cvm-package-symbols common-lisp)) (gc-push-root common-lisp)) (let*((name/system (cvm-make-string :contents "SYSTEM")) (name/heap-header (cvm-make-string :contents "HEAP-HEADER")) (system (cvm-make-package name/system)) (heap-header (cvm-intern name/heap-header system))) (cvm-structure-store +gc-heap-header+ 0 heap-header)) (gc-reset-generation) (cvm-hh-set-root +gc-heap-header+ (cvm-list-nreverse (cvm-hh-root +gc-heap-header+))) (gc-sign *gc-magic-cookie*))) (values)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; COMMON FUNCTION INTEFACE (CFI) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; - functions to convert to and from shared memory values ;; and host lisp values. ;; : used to pass data to and from shared and host. (defvar *ld-values* nil) (defun ld-get (value) (when-debug (:ld) (let ((*print-circle* t)) (format t "~&ld-get ~S [~D] --> ~S~%" value (sxhash value) (gethash value *ld-values*)))) (gethash value *ld-values*)) (defun ld-put (value cvm-value) (when-debug (:ld) (let ((*print-circle* t)) (format t "~&ld-put ~S [~D] --: ~S~%" value (sxhash value) cvm-value))) (setf (gethash value *ld-values*) cvm-value)) (defun ld-lcache (l-value) (or (ld-get l-value) (ld-put l-value (cfi-copy-to-common l-value)))) (defmacro with-loop-detection (&body body) `(let ((old-values *ld-values*)) (when (null *ld-values*) (setf *ld-values* (make-hash-table :test (function eql)))) (unwind-protect (progn ,@body) (setf *ld-values* old-values)))) (defgeneric cfi-copy-to-common (value) (:method ((value (eql nil))) (declare (ignorable value)) +cvm-nil+) (:method ((value (eql t))) (declare (ignorable value)) +cvm-t+) (:method ((value character)) (cvm-form-character value)) (:method ((value integer)) (cvm-form-fixnum value)) ; no bignum yet (:method ((value float)) (cond ((typep value 'short-float) (cvm-form-single-float value)) ((typep value 'single-float) (cvm-form-single-float value)) (t (error "double-float and long-float unsupported yet.")))) (:method ((value ratio)) (declare (ignorable value)) (error "No ratio yet.")) #-mocl (:method ((value complex)) (declare (ignorable value)) (error "No complex yet.")) ;; 1- allocate the current node and store it to the ld hash before ;; 2- allocating the sub-nodes. (:method ((value cons)) (or (ld-get value) (cfi-copy-tree value))) (:method ((value symbol)) (or (ld-get value) (let* ((name (cfi-copy-to-common (symbol-name value))) (sym (ld-put value (if (symbol-package value) (cvm-intern name (cfi-copy-to-common (symbol-package value))) (cvm-make-symbol name +cvm-nil+))))) ;; PERHAPS we don't want to copy the value of a random symbol #|| (with-generation ((plis (cfi-copy-to-common (symbol-plist value))) (valu (if (boundp value) (cfi-copy-to-common (symbol-value value)) +cvm-unbound+)) (func (if (fboundp value) (cfi-copy-to-common (FUNCTION-LAMBDA-EXPRESSION (SYMBOL-FUNCTION value))) +cvm-unbound+))) (cvm-symbol-set-plist sym plis) (cvm-symbol-set-value sym valu) (cvm-symbol-set-function sym func)) ||# sym))) (:method ((value string)) ;; TODO: since we make a copy, the fill-pointers are not synchronized! (or (ld-get value) (ld-put value (cvm-make-string :contents value)))) (:method ((value vector)) (declare (ignorable value)) ;; TODO: since we make a copy, the fill-pointers are not synchronized! ;; TODO: avoid circles #|| (or (ld-get value) (ld-put value (cvm-make-vector <<<value>>> (length value)))) ||#(error "not implemented yet")) (:method ((value array)) (declare (ignorable value)) ;; TODO: avoid circles #|| (or (ld-get value) (ld-put value (cvm-make-array value))) ||#(error "not implemented yet")) #-mocl (:method ((value structure-object)) (declare (ignorable value)) ;; TODO: avoid circles (error "Cannot handle structures yet.")) (:method ((value package)) (or (ld-get value) (ld-put value (with-generation ((name (cfi-copy-to-common (package-name value))) (pack (cvm-find-package name))) (if (cvm-null pack) ;; make-package pushes the new package onto the root. (cvm-make-package name #|TODO:nicknames|#) pack))))) (:method ((value t)) ;; function ;; restart ;; method ;; method-combination ;; object ;; structure ;; condition ;; hashtable ;; pathname ;; stream ;; readtable ;; ... (error "Unsupported value ~S" value))) (defun cfi-copy-tree (ltree) (let ((stack '())) (flet ((copy-cdr (ltree ctree) (when-debug (:ct) (format t "~&PROCESSING CDR; LTREE: ~S~%" ltree)) (loop :with cnode :for cprev = ctree :then cnode :for lnode = (cdr ltree) :then (cdr lnode) :while (consp lnode) :do (with-generation () (setf cnode (ld-put lnode (cvm-make-cons +cvm-nil+ +cvm-nil+))) (cvm-setcdr cprev cnode) (push lnode stack)) :finally (unless (null lnode) (with-generation () (cvm-setcdr cprev (cfi-copy-to-common lnode))))))) ;; processing the root node ltree: (let ((ctree (ld-get ltree))) (when-debug (:ct) (format t "~&PROCESSING ROOT: ~S~%" ltree)) (cond (ctree #|nothing more|#) ((consp ltree) ;; we keep ctree in the new-generation. (setf ctree (ld-put ltree (cvm-make-cons +cvm-nil+ +cvm-nil+))) (push ltree stack) ; we'll process (car ltree) thereafter. (copy-cdr ltree ctree)) ; we process (cdr ltree) now. (t (ld-put ltree (cfi-copy-to-common ltree))))) ;; processing the CARs: (loop while stack do (let* ((lpare (pop stack)) (cpare (ld-get lpare)) (ltree (car lpare)) (ctree)) (when-debug (:ct) (format t "~&PROCESSING CAR; LTREE: ~S~%" ltree)) (assert (not (null cpare))) (cond ((atom ltree) (with-generation () (cvm-setcar cpare (cfi-copy-to-common ltree)))) (t (with-generation () (setf ctree (ld-put ltree (cvm-make-cons +cvm-nil+ +cvm-nil+))) (cvm-setcar cpare ctree)) (push ltree stack) (copy-cdr ltree ctree))))))) (ld-get ltree)) (defun cfi-make-symbol (sym) " SYM: The ct-address of a cvm symbol RETURN: An interned lisp symbol whose plist, value and function are updated with copies of those of SYM. " (let ((name (cfi-copy-from-common (cvm-symbol-name sym))) (pack (cfi-copy-from-common (cvm-symbol-package sym)))) (intern name pack))) (defun cfi-symbol-copy-from-common (lisp-symbol cvm-symbol) (setf (symbol-plist lisp-symbol) (cfi-copy-from-common (cvm-symbol-plist cvm-symbol))) (unless (or (eq (symbol-package lisp-symbol) (cvm-find-package (ld-lcache "COMMON-LISP"))) (eq (symbol-package lisp-symbol) (cvm-find-package (ld-lcache "KEYWORD")))) (let ((val (cvm-symbol-value cvm-symbol))) (unless (eql +cvm-unbound+ val) (setf (symbol-value lisp-symbol) (cfi-copy-from-common val)))) (let ((val (cvm-symbol-function cvm-symbol))) (unless (eql +cvm-unbound+ val) (setf (symbol-function lisp-symbol) (cfi-copy-from-common val))))) lisp-symbol) (defun cfi-copy-from-common (cvm-value &key typecode) (case (or typecode (cvm-type-of cvm-value)) ((#.ct-nil) nil) ((#.ct-t) t) ((#.ct-unbound) (error "Trying to convert an unbound cvm-value")) ((#.ct-bit) (ldb (byte 1 0) cvm-value)) ((#.ct-character-8) (code-char (ldb (byte 8 0) cvm-value))) ((#.ct-character-16) (code-char (ldb (byte 16 0) cvm-value))) ((#.ct-character-24) (code-char (ldb (byte 32 0) cvm-value))) ((#.ct-character-32) (code-char (ldb (byte 32 0) cvm-value))) ((#.ct-signed-byte-8) (error "(signed-byte 8) unsupported yet.")) ((#.ct-signed-byte-16) (error "(signed-byte 16) unsupported yet.")) ((#.ct-signed-byte-24) (error "(signed-byte 24) unsupported yet.")) ((#.ct-signed-byte-32) (error "(signed-byte 32) unsupported yet.")) ((#.ct-signed-byte-40) (error "(signed-byte 40) unsupported yet.")) ((#.ct-signed-byte-48) (error "(signed-byte 48) unsupported yet.")) ((#.ct-signed-byte-56) (cvm-fixnum-value cvm-value)) ((#.ct-signed-byte-64) (error "(signed-byte 64) unsupported yet.")) ((#.ct-unsigned-byte-8) (ldb (byte 8 0) cvm-value)) ((#.ct-unsigned-byte-16) (ldb (byte 16 0) cvm-value)) ((#.ct-unsigned-byte-24) (ldb (byte 24 0) cvm-value)) ((#.ct-unsigned-byte-32) (ldb (byte 32 0) cvm-value)) ((#.ct-unsigned-byte-40) (ldb (byte 40 0) cvm-value)) ((#.ct-unsigned-byte-48) (ldb (byte 48 0) cvm-value)) ((#.ct-unsigned-byte-56) (ldb (byte 56 0) cvm-value)) ((#.ct-unsigned-byte-64) (ldb (byte 64 0) cvm-value)) ((#.ct-float-8) (error "float-8 unsupported yet.")) ((#.ct-float-16) (error "float-16 unsupported yet.")) ((#.ct-float-24) (error "float-24 unsupported yet.")) ((#.ct-float-32) (cvm-single-float-value cvm-value)) ((#.ct-float-40) (error "float-40 unsupported yet.")) ((#.ct-float-48) (error "float-48 unsupported yet.")) ((#.ct-float-56) (error "float-56 unsupported yet.")) ((#.ct-float-64) (error "float-64 unsupported yet.")) ((#.ct-structure) (error "Needs an address to convert a structure.")) ((#.ct-vector) (error "Needs an address to convert a vector.")) ((#.ct-vector-fp) (error "Needs an address to convert a vector-fp.")) ((#.ct-array) (error "Needs an address to convert a array.")) ((#.ct-cons) (error "Needs an address to convert a cons.")) ((#.ct-address #.ct-readable) ;; TODO: readable needs post processing! (let ((ref-value (gc-load (cvm-deref cvm-value)))) (case (cvm-type-of ref-value) ((#.ct-cons) (or (ld-get cvm-value) (let ((cons (ld-put cvm-value (cons nil nil)))) (setf (car cons) (cfi-copy-from-common (cvm-car cvm-value)) (cdr cons) (cfi-copy-from-common (cvm-cdr cvm-value))) cons))) ((#.ct-structure) (cond ((cvm-symbol-p cvm-value) (or (ld-get cvm-value) (let ((lsym (ld-put cvm-value (cfi-make-symbol cvm-value)))) ;; PERHAPS we don't want to copy the value of a random symbol #|| (cfi-symbol-copy-from-common lsym cvm-value) ||# lsym))) ((cvm-package-p cvm-value) (or (ld-get cvm-value) (ld-put cvm-value (let* ((packname (cfi-copy-from-common (cvm-package-name cvm-value))) (pack (find-package packname))) (or pack (make-package packname #|TODO:nickname|#)))))) (t (error "structure unsupported yet.")))) ((#.ct-vector #.ct-vector-fp) (cond ((cvm-string-p cvm-value) (or (ld-get cvm-value) (ld-put cvm-value (cvm-string-value cvm-value)))) (t (error "vector unsupported yet.")))) ((#.ct-array) (error "array unsupported yet.")) (otherwise (cfi-copy-from-common (ldb +ex-cons+ ref-value)))))) ((#.ct-free-block) (error "Trying to convert a free block at ~8,'0X" (cvm-deref cvm-value))) (otherwise (error "Invalid type code (~D)" (or typecode (cvm-type-of cvm-value)))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; COMMON USER-LEVEL API ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar *defined-common-variables* '()) ;; Let's define a common list of common variables: (define-symbol-macro *common-variables* (get-common '*common-variables*)) (eval-when (:compile-toplevel :load-toplevel :execute) (setf (documentation 'common-variables* 'variable) "List of symbols naming common variables.")) (defun common-initialize (memory) " DOES: Initialize the memory instance as a shared heap. MEMORY: A subclass of COM.INFORMATIMAGO.COMMON-LISP.HEAP.MEMORY:MEMORY. NOTE: MEMORY objects are byte-addressed, however the various sized operations are only called on naturally aligned addresses: a peek-uint64 will be called only with addresses multiple of 8. (However, this heap usually addresses 64-bit words, gc-store and gc-load convert the heap addresses into the memory byte addresses, and cvm-svoperate does similarly, but may address 8-bit, 16-bit, 32-bit or 64-bit words depending on the size of the data types). " ;; this was the old API: #-(and) " KEY: An IPC key, built with IPC:MAKE-KEY, used to get the shared memory block ('common' memory) and the semaphore set from which a semaphore is needed. COMMON-SEMAPHORE-INDEX: The index in the semphore set identified with the KEY of the semaphore to be used for common memory mutex. Other semaphores can be used by the application. HEAP-SIZE: The size in byte of the shared memory block. SEMSET-SIZE: The size (number of semaphores) in the semaphore set. NOTE: The shared memory block and the semaphore set may be created before hand or not. This function will create them if needed. " (gc-initialize memory) (set-common '*common-variables* '(*common-variables*)) (pushnew '*common-variables* *defined-common-variables*)) (defmacro defcommon (symbol &optional value docstring) " DOES: Defines a common variable, ie. a variable whose value is stored in the common heap. Everytime the variable is read, the value is copied from the common heap into the lisp heap, and vice-versa everytime it's written. SYMBOL: The name of the common variable. It'll be a symbol macro. VALUE: The initial value copied to the common variable. DOCSTRING: A variable documentation string attached to the SYMBOL. NOTE: A common variable named *COMMON-VARIABLES* contains a list of all common variables names (symbols). NOTE: Copying is done taking into account circles. The copying for the following object types is implemented: (signed-byte 56) single-float nil cons character string symbol ; only the package and name package ; only the name. keeps the list of common variables ; in the package. " `(progn (define-symbol-macro ,symbol (get-common ',symbol)) ,(when docstring `(setf (documentation ',symbol 'variable) ,docstring)) (set-common ',symbol ,value) (pushnew ',symbol *common-variables*) (pushnew ',symbol *defined-common-variables*) ',symbol)) (defun update-common-variables () " DOES: Defines a symbol-macro for the common variables available in the common heap that don't have beed defined in this process. " (dolist (var (set-difference *common-variables* *defined-common-variables*)) (eval `(define-symbol-macro ,var (get-common ',var))) (pushnew 'var *defined-common-variables*))) (defun get-common (symbol) " DOES: Copies the value of the common variable from the common heap to the lisp heap and return this lisp value. SYMBOL: The name of the common variable. It'll be a symbol macro. " (with-loop-detection (with-common-lock (unwind-protect (let*((pack (cfi-copy-to-common (symbol-package symbol))) (symb (cvm-find-symbol (symbol-name symbol) pack))) (if symb (cfi-copy-from-common (cvm-symbol-value symb)) (error "There's no common symbol ~S" symbol))) (gc-reset-generation))))) (defun set-common (symbol value) " DOES: Copies the given lisp VALUE into the common variable in the common heap. Return this lisp value. SYMBOL: The name of the common variable. It'll be a symbol macro. VALUE: The lisp value to be copied into the common heap and bound to the common variable. " (with-loop-detection (with-common-lock (unwind-protect (let ((sym (cfi-copy-to-common symbol)) (val (cfi-copy-to-common value))) (if sym (cvm-symbol-set-value sym val) (error "There's no common symbol ~S" symbol))) (gc-reset-generation)))) value) (defsetf get-common set-common) #| (defcommon *test* :test "A test common variable") |# #|| (load"loader") (load"common") (use-package "COM.INFORMATIMAGO.COMMON-LISP.COMMON") (setf COM.INFORMATIMAGO.COMMON-LISP.COMMON::*debug* '(:range :check) COM.INFORMATIMAGO.COMMON-LISP.COMMON::*check-args* '()) (common-initialize (ipc:make-key "/" (susv3:getpid)) 0 :heap-size (* 8 #x800)) (COM.INFORMATIMAGO.COMMON-LISP.COMMON::gc-sign 0) (setf COM.INFORMATIMAGO.COMMON-LISP.COMMON::*debug* '(:range :check :objects :ng :gc) COM.INFORMATIMAGO.COMMON-LISP.COMMON::*check-args* '(:dump-bitmap t)) (defcommon *test* :test "A test common variable") (setf *test* (com.informatimago.common-lisp.cesarum.list:iota 1000)) ||# ;;;; THE END ;;;;
111,829
Common Lisp
.lisp
2,426
36.6385
90
0.541807
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
994624e43553adc05797e393659a511a8dbcb5c7da67365ccaef747d764b1d5c
5,074
[ -1 ]
5,075
com.informatimago.common-lisp.heap.asd
informatimago_lisp/common-lisp/heap/com.informatimago.common-lisp.heap.asd
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: com.informatimago.common-lisp.heap.asd ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; ASD file to load the com.informatimago.common-lisp.heap library. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2010-10-31 <PJB> Created this .asd file. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2010 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see http://www.gnu.org/licenses/ ;;;;************************************************************************** (asdf:defsystem "com.informatimago.common-lisp.heap" ;;system attributes: :description "Informatimago Common Lisp Heap -- A heap for data in shared memory segments." :long-description " As a layer over shared memory between lisp applications, this system provides a heap of type-tagged objects with a simple mark-and-swipe garbage collector. Lisp objects can be copied to/from this heap. " :author "Pascal J. Bourguignon <[email protected]>" :maintainer "Pascal J. Bourguignon <[email protected]>" :licence "AGPL3" ;; component attributes: :version "1.4.0" :properties ((#:author-email . "[email protected]") (#:date . "Autumn 2010") ((#:albert #:output-dir) . "/tmp/documentation/com.informatimago.common-lisp.heap/") ((#:albert #:formats) . ("docbook")) ((#:albert #:docbook #:template) . "book") ((#:albert #:docbook #:bgcolor) . "white") ((#:albert #:docbook #:textcolor) . "black")) #+asdf-unicode :encoding #+asdf-unicode :utf-8 :depends-on ("com.informatimago.common-lisp.cesarum" "com.informatimago.common-lisp.data-encoding") :components ((:file "memory" :depends-on ()) (:file "heap" :depends-on ("memory"))) #+adsf3 :in-order-to #+adsf3 ((asdf:test-op (asdf:test-op "com.informatimago.common-lisp.heap.test")))) ;;;; THE END ;;;;
2,888
Common Lisp
.lisp
60
44.633333
108
0.605524
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
1a76550207585d059252129ec23deb473c2556faf15375f5272adb49778193f4
5,075
[ -1 ]
5,076
message-queue.lisp
informatimago_lisp/common-lisp/cesarum/message-queue.lisp
;;;; -*- coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: message-queue.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Abstract interface to a message queue. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2005-01-02 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2005 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.MESSAGE-QUEUE" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.QUEUE") (:export "RECEIVE" "SEND" "MESSAGE-QUEUE") (:documentation " A message queue, implemented using FIFI QUEUEs. See also: COM.INFORMATIMAGO.COMMON-LISP.CESARUM.QUEUE License: AGPL3 Copyright Pascal J. Bourguignon 2005 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.MESSAGE-QUEUE") (defclass message-queue () ((messages :initform (make-queue) :type queue :documentation "The messages enqueued.")) (:documentation "An abstract message queue.")) (defmethod print-object ((self message-queue) stream) (print-unreadable-object (self stream :type t :identity t) (format stream ":messages ~S " (slot-value self 'messages))) self) (defgeneric send (mqueue message) (:documentation "Enqueues the MESSAGE into the message queue MQUEUE.")) (defgeneric receive (mqueue) (:documentation "If there's a message available in the queue MQUEUE, then dequeues it and returns (values message t) else returns (values nil nil).")) (defmethod send ((self message-queue) message) (queue-enqueue (slot-value self 'messages) message) (values)) (defmethod receive ((self message-queue)) (if (queue-empty-p (slot-value self 'messages)) (values nil nil) (values (queue-dequeue (slot-value self 'messages)) t))) ;;;; message-queue.lisp -- -- ;;;;
3,641
Common Lisp
.lisp
82
41.402439
83
0.666101
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
951824df14d987eb94c5db1c949f728b012df684a6eec63e517f56b53bd4c786
5,076
[ -1 ]
5,077
combination.lisp
informatimago_lisp/common-lisp/cesarum/combination.lisp
;;;; -*- coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: combination.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; See defpackage documentation string. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2005-04-24 <PJB> Converted from BpCombi C++ classes. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2005 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.COMBINATION" (:use "COMMON-LISP") (:export "DONE-P" "GET-NEXT-ELEMENT" "GET-CURRENT-ELEMENT" "RESET" "AT-BEGINNING-P" "ELEMENT-SIZE" "BASE-CARDINAL" "INDEX" "CARDINAL" "ARRANGEMENT" "COMBINATION" "ARRANGEMENT-SANS-REPEAT" "ARRANGEMENT-WITH-REPEAT" ;; --- "COMBINATIONS") (:shadow "STEP") (:documentation " This package exports three classes to generate lazily combinations, and arrangements with and without repeatition (permutations). See also: <http://fr.wikipedia.org/wiki/Combinatoire> License: AGPL3 Copyright Pascal J. Bourguignon 2003 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.COMBINATION") (deftype cardinal () '(integer 0)) (defun copy-vector (vector &key (start 0) (end (length vector)) (element-type t element-type-p)) (let ((result (multiple-value-call (function make-array) (list (- end start)) (if element-type-p (values :element-type element-type) (values))))) (replace result vector :start2 start :end2 end) result)) (defgeneric compute-cardinal (self) (:documentation " NOTE: It must be overriden by subclasses to compute the _cardinal from the _baseCardinal and the _elementSize attributes. ")) (defgeneric initialize (self) (:documentation " NOTE: It must be overriden by subclasses to initialize the enumeration. It must compute the _cardinal, and set the_index either to 0 or to _cardinal. If _index != _cardinal then the choice array must be set to the first enumerated element. ")) (defgeneric next (self) (:documentation " NOTE: It must be overriden by subclasses to step to the next element of the enumeration. If _index<_cardinal, then it must increment _index ; if _index¹_cardinal then the choice array must be set to the first enumerated element. ")) (defgeneric cardinal (self) (:documentation " PRE: !atBegining().. RETURN: the number of elements enumerated by this object. ")) (defgeneric index (self) (:documentation " PRE: !atBegining().. RETURN: the index of the current element enumerated by this object. ")) (defgeneric element-size (self) (:documentation " RETURN: the size of each element returned by getCurrentElement and getNextElement in the choice arrays. ")) (defgeneric reset (self) (:documentation " POST: atBegining(). DO: resets the enumeration. ")) (defgeneric at-beginning-p (self) (:documentation " RETURN: whether the reset() method has been called and getNextElement() (or getCurrentElement()) has not already been called. ")) (defgeneric get-current-element (self) (:documentation " PRE: cardinal()>0. POST: !atBegining(), RETURN: A vector of cardinal: choice. DO: Sets the choice array to the current enumerated element. (ie. the last element retrived with the getNextElement method). The choice array must contain at least elementSize() integers. ")) (defgeneric get-next-element (self) (:documentation " PRE: cardinal()>0, !done-p(), atBegining()=b, (!b => index()=a). POST: !atBegining(), (!b => index()=a+1), RETURN: A vector of cardinal: choice; done-p. DO: Computes the next element to be enumerated and sets the choice array to it. It returns TRUE when the last element is retrived, ie. all elements have been enumerated. The choice array must contain at least elementSize() integers. ")) (defgeneric done-p (self) (:documentation " RETURN: !atBegining() && ((cardinal()=0) || (index()=cardinal())). ")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Set Functor ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defgeneric base-cardinal (functor) (:documentation "RETURN: The cardinal n of the base set.")) (defgeneric set-base-cardinal (functor cardinal)) (defgeneric set-element-size (functor size)) (defgeneric step (functor index)) (defclass set-functor () ((base-cardinal :type cardinal :initform 0 :reader base-cardinal :documentation "The cardinal of the base set.") (cardinal :type cardinal :initform 0 :reader cardinal :documentation "The cardinal of the functor set.") (index :type cardinal :initform 0 :reader index) (element-size :type cardinal :initform 0 :reader element-size) (choice :type vector :initform #()) (at-beginning-p :type boolean :initform nil :reader at-beginning-p)) (:documentation "Representation of an enumerable set.")) (defmethod set-base-cardinal ((self set-functor) card) " PRE: c=card. POST: baseCardinal()=c. DO: informs SELF about the number of elements in the set of which this is function. " (when (/= (base-cardinal self) card) (setf (slot-value self 'base-cardinal) card (slot-value self 'cardinal) 0)) self) (defmethod set-element-size ((self set-functor) size) " PRE: s=size. POST: elementSize()=s. DO: Sets the elementSize() parameter. " (when (/= (element-size self) size) (setf (slot-value self 'element-size) size (slot-value self 'cardinal) 0)) self) (defsetf base-cardinal set-base-cardinal) (defsetf element-size set-element-size) (defmethod reset ((self set-functor)) (compute-cardinal self) (setf (slot-value self 'choice) (make-array (list (cardinal self)) :element-type 'cardinal)) (initialize self) (setf (slot-value self 'at-beginning-p) t) self) (defmethod get-current-element ((self set-functor)) (setf (slot-value self 'at-beginning-p) nil) (copy-vector (slot-value self 'choice) :end (element-size self))) (defmethod get-next-element ((self set-functor)) (if (and (plusp (cardinal self)) (not (done-p self))) (progn (if (at-beginning-p self) (setf (slot-value self 'at-beginning-p) nil) (next self)) (values (get-current-element self) (done-p self))) (values nil nil))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Arrangement Sans Repeat ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defclass arrangement-sans-repeat (set-functor) ((done :type boolean) (taken :type (vector boolean))) (:documentation "We choose k objects in order without repeating the same object, amongst n objects.")) (defmethod done-p ((self arrangement-sans-repeat)) (= (aref (slot-value self 'choice) 0) (base-cardinal self))) (defun arrangement (k n) " RETURN: The number of arrangement of k elements (without repeat) taken amongst n. " (loop :with r = 1 :for i :from (- n k -1) :to n :do (setf r (* r i)) :finally (return r))) (defmethod compute-cardinal ((self arrangement-sans-repeat)) (setf (slot-value self 'cardinal) (arrangement (element-size self) (base-cardinal self)))) (defmethod initialize ((self arrangement-sans-repeat)) (setf (slot-value self 'taken) (make-array (base-cardinal self) :element-type 'boolean :initial-element nil) (slot-value self 'done) nil) (step self 0)) (defmethod step ((self arrangement-sans-repeat) k) (macrolet ((transition (guard action state) `(when ,guard ,action (go ,state)))) (let ((choice (slot-value self 'choice)) (taken (slot-value self 'taken)) (element-size (element-size self)) (base-cardinal (base-cardinal self))) (tagbody :state-0 (transition (< k element-size) (setf (aref choice k) 0) :state-1) (transition (not (< k element-size)) (setf k (1- element-size)) :state-5) :state-1 (transition (aref taken (aref choice k)) nil :state-2) (transition (not (aref taken (aref choice k))) nil :state-3) :state-2 (incf (aref (slot-value self 'choice) k)) (transition (< (aref choice k) base-cardinal) nil :state-1) (transition (and (not (< (aref choice k) base-cardinal)) (zerop k)) (setf (slot-value self 'done) t) :terminate) (transition (and (not (< (aref choice k) base-cardinal)) (not (zerop k))) (decf k) :state-5) :state-3 (setf (aref taken (aref choice k)) t) (transition (< k (1- element-size)) (incf k) :state-0) (transition (not (< k (1- element-size))) nil :terminate) :state-5 (setf (aref taken (aref choice k)) nil) (transition t nil :state-2) :terminate)))) (defmethod next ((self arrangement-sans-repeat)) (step self (element-size self))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Arrangement With Repeat ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defclass arrangement-with-repeat (set-functor) () (:documentation "We choose k objects in order possibly repeating the same object, amongst n objects.")) (defmethod done-p ((self arrangement-with-repeat)) (loop with choice = (slot-value self 'choice) for i from (1- (element-size self)) downto 1 do (unless (zerop (aref choice i)) (return nil)) finally (return (= (aref choice 0) (base-cardinal self))))) (defmethod compute-cardinal ((self arrangement-with-repeat)) (setf (slot-value self 'cardinal) (expt (base-cardinal self) (element-size self)))) (defmethod initialize ((self arrangement-with-repeat)) (loop with choice = (slot-value self 'choice) for i from 0 below (element-size self) do (setf (aref choice i) 0)) self) (defmethod next ((self arrangement-with-repeat)) (loop with k = (1- (element-size self)) with choice = (slot-value self 'choice) with base-cardinal = (base-cardinal self) initially (incf (aref choice k)) while (and (> k 0) (>= (aref choice k) base-cardinal)) do (progn (setf (aref choice k) 0) (decf k) (incf (aref choice k)))) self) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Combinations ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defclass combination (set-functor) () (:documentation "We choose k distinct objects, without taking into account the order, amongst n objects.")) (defmethod done-p ((self combination)) (if (slot-value self 'choice) (= (aref (slot-value self 'choice) 0) (- (base-cardinal self) (element-size self) -1)) t)) (defun combination (k n) "RETURN: The number of combinations of k elements taken amongst n." (let ((r 1) a b) (if (> k (- n k)) (setf a k b (- n k)) (setf a (- n k) b k)) ;; a>=b ;; N!/(a!b!) = Pi(i=a+1,N,i)/b! (loop for i from (1+ a) to n do (setf r (* r i))) (loop for i from 2 to b do (setf r (/ r i))) r)) (defmethod compute-cardinal ((self combination)) (setf (slot-value self 'cardinal) (combination (element-size self) (base-cardinal self)))) (defmethod initialize ((self combination)) (loop with choice = (slot-value self 'choice) for i from 0 below (element-size self) do (setf (aref choice i) i)) self) (defun next-step (choice limit i) (incf (aref choice i)) (if (>= (aref choice i) (+ limit i)) (when (> i 0) (next-step choice limit (1- i)) (setf (aref choice i) (1+ (aref choice (1- i)))))) (values)) (defmethod next ((self combination)) (next-step (slot-value self 'choice) (- (base-cardinal self) (1- (element-size self))) (1- (element-size self)))) (defun combinations (list n) " RETURN: a list of all the combinations of N elements from the LIST. " (cond ((zerop n) '(())) ((< (length list) n) '()) ((= (length list) n) (list list)) (t (nconc (mapcar (lambda (subcomb) (cons (first list) subcomb)) (combinations (rest list) (1- n))) (combinations (rest list) n))))) ;;;; THE END ;;;;
14,769
Common Lisp
.lisp
358
35.715084
110
0.605313
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
6fa5be07a1e7b7a71fcb5e65b0915a36bf801cd6c50fcba5e252f317b91c108a
5,077
[ -1 ]
5,078
mersenne.lisp
informatimago_lisp/common-lisp/cesarum/mersenne.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: mersenne.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Implements CL RANDOM API with a Mersenne's twister ;;;; Pseudo Random Number Generator. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2016-01-30 <PJB> Translated from scheme created 2006-10-23. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2016 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.MERSENNE" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY") (:shadow "RANDOM-STATE" "RANDOM-STATE-P" "MAKE-RANDOM-STATE" "*RANDOM-STATE*" "RANDOM") (:export "RANDOM-STATE" "RANDOM-STATE-P" "MAKE-RANDOM-STATE" "*RANDOM-STATE*" "RANDOM") (:export "SRAND" "RAND") (:documentation " Implements the Mersenne's twister Pseudo Random Number Generator. (Not cryptographically secure). AGPL3 Copyright Pascal J. Bourguignon 2016 - 2016 ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.MERSENNE") ;; The coefficients for MT19937 are: ;; ;; (w, n, m, r) = (32, 624, 397, 31) ;; a = 9908B0DF16 ;; (u, d) = (11, FFFFFFFF16) ;; (s, b) = (7, 9D2C568016) ;; (t, c) = (15, EFC6000016) ;; l = 18 ;; ;; Note that 32-bit implementations of the Mersenne Twister generally ;; have d = FFFFFFFF16. As a result, the d is occasionally omitted ;; from the algorithm description, since the bitwise and with d in ;; that case has no effect. ;; ;; The coefficients for MT19937-64 are:[43] ;; ;; (w, n, m, r) = (64, 312, 156, 31) ;; a = B5026F5AA96619E916 ;; (u, d) = (29, 555555555555555516) ;; (s, b) = (17, 71D67FFFEDA6000016) ;; (t, c) = (37, FFF7EEE00000000016) ;; l = 43 ;; ;; f: ;; (typep 1812433253 'fixnum) ;; (typep 6364136223846793005 'fixnum) ;; (deftype word () '(unsigned-byte 32)) (defstruct (random-state (:constructor %make-random-state)) (i 0) (mt (make-array 624 :initial-element 0 :element-type 'word))) (defvar *random-state*) (defun Makoto-Matsumoto (seed) ;; Mersenne Twistter seed function. (check-type seed word) (let ((mt (random-state-mt *random-state*))) (setf (aref mt 0) seed) (do ((i 1 (1+ i))) ((> i 623)) (setf (aref mt i) (ldb (byte 32 0) (+ 1 (* 69069 (aref mt (- i 1))))))) (setf (random-state-i *random-state*) 624) (values))) (defun Takuji-Nishimura () ;; Mersenne Twistter random generator function. (let ((mt (random-state-mt *random-state*)) (i (random-state-i *random-state*))) (setf i (mod (1+ i) 624)) (when (zerop i) (do ((i 0 (+ 1 i))) ((> i 622)) (setf (aref mt i) (let ((y (ldb (byte 31 0) (aref mt (+ i 1))))) (the word (if (evenp (ldb (byte 1 31) (aref mt i))) (logxor (aref mt (mod (+ i 397) 624)) y) (logxor (aref mt (mod (+ i 397) 624)) y 2567483615)))))) (setf (aref mt 623) (let ((y (ldb (byte 31 0) (aref mt 0)))) (the word (if (evenp (ldb (byte 1 31) (aref mt 623))) (logxor (aref mt 396) y) (logxor (aref mt 396) y 2567483615)))))) (let ((y (aref mt i))) (declare (type word y)) (setf y (logxor y (ash y -11))) (setf y (logxor y (logand (ash y 7) 2636928640))) (setf y (logxor y (logand (ash y 11) 4022730752))) (setf y (logxor y (ash y -18))) (setf (random-state-i *random-state*) i) y))) (defun make-random-state (&optional (state nil)) (check-type state (or (member nil t) random-state)) (case state ((nil) (make-random-state *random-state*)) ((t) (let ((*random-state* (%make-random-state))) (Makoto-Matsumoto (mod (get-universal-time) 4294967291)) *random-state*)) (otherwise (let ((new-state (copy-random-state state))) (setf (random-state-mt new-state) (copy-seq (random-state-mt state))) new-state)))) (setf *random-state* (make-random-state t)) (defun random (limit &optional (*random-state* *random-state*)) "Returns a pseudo-random integer in [0,LIMIT[." (check-type limit (and (or (integer 1) (real 0)) (not (real 0 0)))) (if (integerp limit) (loop :with llen := (integer-length limit) :with wlen := 32 :for position :from 0 :to llen :by wlen :for random := (Takuji-Nishimura) :then (dpb (Takuji-Nishimura) (byte wlen position) random) :finally (return (mod random limit))) (let* ((b (truncate (scale-float (float 1 limit) 1))) (e (loop :for e :from (nth-value 1 (decode-float limit)) :downto 0 :for r := (random b) :while (zerop r) :finally (return e))) (s (1+ (integer-decode-float (float-typecase 1d100 (short-float most-positive-short-float) (single-float most-positive-single-float) (double-float most-positive-double-float) (long-float most-positive-long-float))))) (m (random s))) (scale-float (/ (float m limit) s) e)))) (defun srand (seed) (setf *random-state* (%make-random-state)) (Makoto-Matsumoto (mod seed 4294967291))) (defun rand () (random 4294967296)) #-(and) (progn (loop repeat 10 collect (random 1000)) (73 381 773 143 193 815 324 777 801 439) (loop repeat 10 collect (random 1000.0f0)) (384.27188 387.2843 72.70929 437.53748 212.09105 39.057716 502.98566 808.5497 27.742487 915.78644) (loop repeat 10 collect (random 1000.0f20)) (4.941074E+22 4.378368E+21 2.342984E+22 1.1714196E+22 1.3757518E+22 9.1934555E+22 7.97674E+22 1.0366667E+23 8.556502E+22 6.509138E+22) ) ;;;; THE END ;;;;
7,012
Common Lisp
.lisp
179
33.670391
136
0.586708
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
e9ca0ef5db4a54d0472c22f399466a5cd44726c0169927622c1e0660a459330e
5,078
[ -1 ]
5,079
brelation.lisp
informatimago_lisp/common-lisp/cesarum/brelation.lisp
;;;; -*- mode:lisp; coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: brelation.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; This package implements a relation abstract data type ;;;; based on an array of bset. ;;;; It can represent only relations between two positive ;;;; and bounded integers. ;;;; ;;;; (Inspired by Modula-2 cocktail-9309/reuse/src/Relations.md). ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2004-02-19 <PJB> Created. ;;;;BUGS ;;;; ;;;; This is not as lispy as could be (we may want to have brelation ;;;; of random lisp objects, notably symbols), but it's optimized ;;;; for small integers. ;;;; ;;;; There are no checks for mismatching operands ;;;; (relations with different sizes) ;;;; ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2004 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.BRELATION" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.BSET") (:shadowing-import-from "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.BSET" "COMPLEMENT" "INTERSECTION" "UNION" "SUBSETP") (:import-from "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY" "VECTOR-INIT" "FOR" "UNTIL") (:export "PROJECT-2" "PROJECT-1" "WRITE-BRELATION" "READ-BRELATION" "FOR-ALL-DO" "EXISTS-1" "EXISTS" "FOR-ALL" "EXTRACT" "SELECT" "CARDINAL" "EMPTYP" "IS-NOT-EQUAL" "IS-EQUAL" "IS-STRICT-SUBSET" "IS-SUBSET" "COMPLEMENT" "SYM-DIFF" "INTERSECTION" "DIFFERENCE" "UNION" "ASSIGN" "ASSIGN-ELEMENT" "ASSIGN-EMPTY" "CLOSURE" "GET-CYCLICS" "IS-CYCLIC" "HAS-REFLEXIVE" "IS-EQUIVALENCE" "IS-TRANSITIVE" "IS-SYMMETRIC" "IS-REFLEXIVE" "IS-TRANSITIVE-1" "IS-REFLEXIVE-1" "IS-RELATED" "IS-ELEMENT" "EXCLUDE" "INCLUDE" "MAKE-BRELATION" "BRELATION") (:documentation " This package implements a relation abstract data type based on an array of bset. It can represent only relations between two positive and bounded integers. \(Inspired by Modula-2 cocktail-9309/reuse/src/Relations.md). See also: COM.INFORMATIMAGO.COMMON-LISP.CESARUM.BSET License: AGPL3 Copyright Pascal J. Bourguignon 2004 - 2015 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.BRELATION") (defstruct (brelation (:constructor %make-brelation)) "The Binary Relation Class." (adjsets (make-array '(0) :element-type 'bset :initial-element (make-bset 0)) :type (array bset (*))) (size-1 0 :type element) (size-2 0 :type element)) (defun make-brelation (size-1 size-2) " RETURN: A new BRELATION between sets of sizes SIZE-1 and SIZE-2. " (check-type size-1 element) (check-type size-2 element) (%make-brelation :adjsets (vector-init (make-array (list (1+ size-1)) :element-type 'bset :initial-element (make-bset 0)) (lambda (index) (declare (ignore index)) (make-bset size-2))) :size-1 size-1 :size-2 size-2)) (defmacro imply (p q) " RETURN: P ⇒ Q NOTE: This short circuits the evaluation of Q if P is false. " `(or (not ,p) ,q)) (defmacro adjref (rel i) `(aref (brelation-adjsets ,rel) ,i)) (defmacro related (rel e1 e2) `(is-element ,e2 (adjref ,rel ,e1))) (deftype arc () 'cons) (defun arc (e1 e2) (cons e1 e2)) (defun arc-from (arc) (car arc)) (defun arc-to (arc) (cdr arc)) (defmacro with-arc (((e1 e2) arc) &body body) (let ((varc (gensym))) `(let ((,varc ,arc)) (check-type ,varc arc) (let ((,e1 (arc-from ,varc)) (,e2 (arc-to ,varc))) (check-type ,e1 element) (check-type ,e2 element) ,@body)))) (defmethod include ((rel brelation) arc) " DO: Adds (E1 E2) to the relation REL. POST: REL(E1,E2) " (with-arc ((e1 e2) arc) (include (adjref rel e1) e2)) rel) (defmethod exclude ((rel brelation) arc) " DO: Remove (E1 E2) from the relation REL. POST: ¬ REL(E1,E2) " (with-arc ((e1 e2) arc) (exclude (adjref rel e1) e2)) rel) (defmethod is-element (arc (rel brelation)) " RETURN: Whether REL(E1,E2). " (with-arc ((e1 e2) arc) (related rel e1 e2))) (defgeneric is-related (e1 e2 rel)) (defmethod is-related (e1 e2 (rel brelation)) " RETURN: Whether REL(E1,E2). " (related rel e1 e2)) (defgeneric is-reflexive-1 (e1 rel)) (defmethod is-reflexive-1 (e1 (rel brelation)) " RETURN: Whether REL(E1,E1) " (check-type e1 element) (related rel e1 e1)) (defgeneric is-symmetric-1 (e1 e2 rel)) (defmethod is-symmetric-1 (e1 e2 (rel brelation)) " RETURN: Whether REL(E1,E2) ∧ REL(E2,E1) " (check-type e1 element) (check-type e2 element) (imply (related rel e1 e2) (related rel e2 e1))) (defgeneric is-transitive-1 (e1 e2 e3 rel)) (defmethod is-transitive-1 (e1 e2 e3 (rel brelation)) " RETURN: Whether (REL(E1,E2) ∧ REL(E2,E3)) ⇒ REL(E1,E3) NOTE: Tests the transitivity of the relation REL only on the elements E1, E2, and E3. This doesn't mean the relation REL is transitive (but it's a necessary condition). " (check-type e1 element) (check-type e2 element) (check-type e3 element) (imply (and (related rel e1 e2) (related rel e2 e3)) (related rel e1 e3))) (defgeneric is-reflexive (rel)) (defmethod is-reflexive ((rel brelation)) " RETURN: Whether the relation REL is reflexive. Ie. ∀i∈[0,SIZE1-1], REL(i,i) " (for (i 0 (brelation-size-1 rel)) (unless (related rel i i) (return-from is-reflexive nil))) t) (defgeneric is-symmetric (rel)) (defmethod is-symmetric ((rel brelation)) " RETURN: Whether the relation REL is symetric. Ie. ∀(i,j)∈[0,SIZE1-1]², REL(i,j) ⇒ REL(j,i) " (for (i 0 (brelation-size-1 rel)) (unless (for-all (adjref rel i) (lambda (j) (related rel j i))) (return-from is-symmetric nil))) t) (defgeneric is-transitive (rel)) (defmethod is-transitive ((rel brelation)) " RETURN: Whether the relation REL is transitive. Ie. ∀(i,j,k)∈[0,SIZE1-1]³, REL(i,j) ∧ REL(j,k) ⇒ REL(i,k) " (let ((r (make-brelation (brelation-size-1 rel) (brelation-size-2 rel)))) (assign r rel) (closure r) (is-equal r rel) )) (defgeneric is-equivalence (rel)) (defmethod is-equivalence ((rel brelation)) " RETURN: Whether REL is an equivalence relation. Ie. REL is reflexive, symetric and transitive. " (and (is-reflexive rel) (is-symmetric rel) (is-transitive rel))) (defgeneric has-reflexive (rel)) (defmethod has-reflexive ((rel brelation)) " RETURN: ∃i∈[0,SIZE1-1], REL(i,i) " (for (i 0 (brelation-size-1 rel)) (when (related rel i i) (return-from has-reflexive t))) nil) (defgeneric is-cyclic (rel)) (defmethod is-cyclic ((rel brelation)) " RETURN: Whether the relation REL is cyclic. " (let ((with-pred (make-bset (brelation-size-1 rel))) (without-pred (make-bset (brelation-size-1 rel))) (pred-count (make-array (list (1+ (brelation-size-1 rel))) :element-type 'element :initial-element 0))) (for (i 0 (brelation-size-1 rel)) (for-all-do (adjref rel i) (lambda (e) (incf (aref pred-count e))))) (for (i 0 (brelation-size-1 rel)) (when (= 0 (aref pred-count i)) (include without-pred i))) (complement with-pred) (until (emptyp without-pred) (let ((i (extract without-pred))) (exclude with-pred i) (for-all-do (adjref rel i) (lambda (e) (decf (aref pred-count e)) (when (= 0 (aref pred-count e)) (include without-pred e)))))) (not (emptyp with-pred)))) (defgeneric get-cyclics (rel bset)) (defmethod get-cyclics ((rel brelation) (bset bset)) " RETURN: The set of elements that are in cycles. " (let ((r (make-brelation (brelation-size-1 rel)(brelation-size-2 rel)))) (assign r rel) (closure r) (assign-empty bset) (for (i 0 (brelation-size-1 rel)) (when (related r i i) (include bset i)))) bset) (defmethod assign-empty ((rel brelation)) " POST: REL is the empty relation. RETURN: REL " (for (i 0 (brelation-size-1 rel)) (assign-empty (adjref rel i))) rel) (defmethod assign-element ((rel brelation) arc) " POST: REL contains only (E1,E2). RETURN: REL " (with-arc ((e1 e2) arc) (assign-empty rel) (include rel (arc e1 e2))) rel) (defmethod assign ((rel1 brelation) (rel2 brelation)) " POST: REL1 is a copy of REL2. RETURN: REL1 " (for (i 0 (brelation-size-1 rel1)) (assign-empty (adjref rel1 i)) (assign-empty (adjref rel2 i))) rel1) (defgeneric closure (rel)) (defmethod closure ((rel brelation)) " POST: REL is the transitive closure of the old REL. RETURN: REL " (for (j 0 (brelation-size-1 rel)) (unless (emptyp (adjref rel j)) (for (i 0 (brelation-size-1 rel)) (when (related rel i j) (union (adjref rel i) (adjref rel j)))))) rel) (defmethod union ((rel1 brelation) (rel2 brelation)) " POST: REL1 is the union of old REL1 and REL2. RETURN: REL1 " (for (i 0 (brelation-size-1 rel1)) (union (adjref rel1 i) (adjref rel2 i))) rel1) (defmethod difference ((rel1 brelation) (rel2 brelation)) " POST: REL1 is the difference of old REL1 and REL2. RETURN: REL1 " (for (i 0 (brelation-size-1 rel1)) (difference (adjref rel1 i) (adjref rel2 i))) rel1) (defmethod intersection ((rel1 brelation) (rel2 brelation)) " POST: REL1 is the intersection of old REL1 and REL2. RETURN: REL1 " (for (i 0 (brelation-size-1 rel1)) (intersection (adjref rel1 i) (adjref rel2 i))) rel1) (defmethod sym-diff ((rel1 brelation) (rel2 brelation)) " POST: REL1 is the symetric difference of old REL1 and REL2. RETURN: REL1 " (for (i 0 (brelation-size-1 rel1)) (sym-diff (adjref rel1 i) (adjref rel2 i))) rel1) (defmethod complement ((rel brelation)) " POST: REL is the complement of old REL. RETURN: REL " (for (i 0 (brelation-size-1 rel)) (complement (adjref rel i))) rel) (defmethod subsetp ((rel1 brelation) (rel2 brelation)) " RETURN: Whether REL1 is a subset of REL2. " (for (i 0 (brelation-size-1 rel1)) (unless (subsetp (adjref rel1 i) (adjref rel2 i)) (return-from subsetp nil))) t) (defmethod strict-subsetp ((rel1 brelation) (rel2 brelation)) " RETURN: Whether REL1 is a strict subset of REL2. " (and (is-subset rel1 rel2) (is-not-equal rel1 rel2))) (defmethod is-equal ((rel1 brelation) (rel2 brelation)) " RETURN: Whether REL1 is equal to REL2. " (for (i 0 (brelation-size-1 rel1)) (unless (is-equal (adjref rel1 i) (adjref rel2 i)) (return-from is-equal nil))) t) (defmethod is-not-equal ((rel1 brelation) (rel2 brelation)) " RETURN: Whether REL1 is not equal to REL2. " (not (is-equal rel1 rel2))) (defmethod emptyp ((rel brelation)) " RETURN: Whether REL is empty. " (for (i 0 (brelation-size-1 rel)) (unless (emptyp (adjref rel i)) (return-from emptyp nil))) t) (defmethod cardinal ((rel brelation)) " RETURN: The number of couples in the relation REL. " (let ((n 0)) (for (i 0 (brelation-size-1 rel)) (incf n (cardinal (adjref rel i)))) n)) (defmethod select ((rel brelation)) " RETURN: (values i j) such as REL(i,j), or NIL if REL is empty. " (for (i 0 (brelation-size-1 rel)) (unless (emptyp (adjref rel i)) (return-from select (values i (select (adjref rel i)))))) nil) (defmethod extract ((rel brelation)) " DO: Selects a couple in the relation REL, exclude it from REL, and return it. PRE: (not (emptyp rel)) POST: ¬REL(i,j) RETURN: (values i j) such as old REL(i,j), or NIL if REL is empty. " (multiple-value-bind (e1 e2) (select rel) (when e2 (exclude rel (arc e1 e2)) (values e1 e2)))) (defmethod for-all ((rel brelation) proc) " DO: Calls PROC on couples of the relation REL while it returns true. PROC: A predicate of two elements. RETURN: Whether PROC returned true for all couples. " (for (i 0 (brelation-size-1 rel)) (unless (for-all (adjref rel i) (lambda (e) (funcall proc i e))) (return-from for-all nil))) t) (defmethod exists ((rel brelation) proc) " DO: Calls PROC on couples of the relation REL until it returns true. PROC: A predicate of two elements. RETURN: Whether PROC returned true for at least one couple. " (for (i 0 (brelation-size-1 rel)) (when (exists (adjref rel i) (lambda (e) (funcall proc i e))) (return-from exists t))) nil) (defmethod exists-1 ((rel brelation) proc) " DO: Calls PROC on each couples of the relation REL. PROC: A predicate of two elements. RETURN: Whether PROC returned true for exactly one couple. " (let ((n 0)) (for (i 0 (brelation-size-1 rel)) (when (exists (adjref rel i) (lambda (e) (funcall proc i e))) (incf n))) (= n 1))) (defmethod for-all-do ((rel brelation) proc) " DO: Calls PROC on each couple of the relation REL. PROC: A function of two elements. RETURN: REL " (for (i 0 (brelation-size-1 rel)) (for-all-do (adjref rel i) (lambda (e) (funcall proc i e)))) rel) (defun read-brelation (stream rel) " DO: Read a relation from the STREAM. POST: REL is the relation read. RETURN: REL. NOTE: The serialization format is that of a list of adjacency lists. ((1 (2 3)) (2 (3)) (4)) = ({1 2 3 4} {(1 2) (1 3) (2 3)}) " (assign-empty rel) (when (peek-char (character "(") stream nil nil) (read-char stream) (do () ((char= (peek-char t stream nil (character ")")) (character ")")) (read-char stream)) (let ((i (read stream))) (when (peek-char (character "(") stream nil nil) (read-char stream) (do () ((char= (peek-char t stream nil (character ")")) (character ")")) (read-char stream)) (include rel (arc i (read stream)))))))) rel) (defun write-brelation (stream rel) " DO: Write the relation REL to the STREAM. RETURN: REL. " (princ "(" stream) (for (i 0 (brelation-size-1 rel)) (princ i stream) (write-bset stream (adjref rel i)) (terpri stream)) (princ ")" stream) rel) (defgeneric project-1 (rel e1 bset)) (defmethod project-1 ((rel brelation) e1 (bset bset)) " POST: BSET is the set of all elements I that are in relation REL(I,E2). RETURN: BSET " (assign-empty bset) (for (i 0 (brelation-size-1 rel)) (when (related rel i e1) (include bset i))) bset) (defgeneric project-2 (rel e1 bset)) (defmethod project-2 ((rel brelation) e1 (bset bset)) " POST: BSET is the set of all elements E2 that are in relation REL(E1,E2). RETURN: BSET " (assign bset (adjref rel e1))) ;;;; THE END ;;;;
16,733
Common Lisp
.lisp
497
29.54326
105
0.642304
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
ba8b3bf907e4a9ece9b6750798211de55b62beb45b84db6786eba2ebc8a018fb
5,079
[ -1 ]
5,080
activity.lisp
informatimago_lisp/common-lisp/cesarum/activity.lisp
;;;; -*- coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: activity.lisp ;;;;LANGUAGE: common-lisp ;;;;SYSTEM: common-lisp ;;;;USER-INTERFACE: common-lisp ;;;;DESCRIPTION ;;;; ;;;; See defpackage documentation string. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2007-11-12 <PJB> Improved. Added schedulers and various time-base. ;;;; 2003-03-01 <PJB> Created. ;;;;BUGS ;;;; When the firsts activities in the queue are past their time by ;;;; a long time (ie. more than their period), they're rescheduled ;;;; without taking into account the activities behind that may ;;;; have shorter periods, therefore we may have a long sleep ;;;; before normal activity scheduling resumes. ;;;; ;;;; The state diagram of the activities is not clear. ;;;; Not intensively tested/valided :-( ;;;; ;;;; Instead of sleeping, we should have an option to use select/poll ;;;; (eg socket-status in clisp). See if it can be done with the ;;;; time-base mechanisms. ;;;; ;;;; No provision for compatibility with non-threading server options ;;;; such as UCW's that can work with clisp's socket-status. ;;;; ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2003 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.ACTIVITY" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.LIST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.TIME") (:export "MAKE-ACTIVITY" "CURRENT-ACTIVITY" "ACTIVITYP" "ACTIVITY-YIELD" "ALL-ACTIVITIES" "DESTROY-ACTIVITY" "ACTIVITY-RUN" "ACTIVITY-NAME" "ACTIVITY-CLOSURE" "ACTIVITY-SCHEDULER" "ACTIVITY-SCHEDULED-TIME" "ACTIVITY-PERIOD" "ACTIVITY-DROPABLE-P" "ACTIVITY-EXACT-P" ;; Schedulers "PRINT-SCHEDULER-ACTIVITIES" "SCHEDULER-ALL-ACTIVITIES" "SCHEDULE-ACTIVITY" "UNSCHEDULE-ACTIVITY" "RUN" ;; Utility: "PRINT-ACTIVITIES" "GET-TIME") (:documentation " This package implements a kind of co-routine monitor. An activity is a closure that is called at specified times (T+k*P). It should return before processing can go on. This package is implemented in pure Common Lisp and allows to schedule independent \"tasks\" portably, as long as you can split each task in small chunks, timewise. License: AGPL3 Copyright Pascal J. Bourguignon 2003 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.ACTIVITY") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ACTIVITIES ;;; ;; An activity either: ;; - use universal-time ;; - use internal-real-time ;; - use internal-run-time (we don't use interrupts so ;; we cannot schedule precisely). ;; Also, either: ;; - start + as-often-as-possible (idle tasks) ;; - start + k * period ;; ;; And: ;; - n times ;; - between start-time and end-time ;; ;; ;; (exact count) (inexact count) (inexact count) ;; (any time) (only within period) (only exact time) ;; (not droppable) (droppable) (droppable) ;; ;; |.....|.....|.....| |.....|.....|.....| |.....|.....|.....| ;; x x x x x x x x x x x x ;; ;; |.....|.....|.....| |.....|.....|.....| |.....|.....|.....| ;; x x x x x x x x - - - x ;; ;; |.....|.....|.....| |.....|.....|.....| |.....|.....|.....| ;; x x x x x - x x - - - x ;; ;; x = execute ;; - = drop that time. ;; ;; (Only exact time) allows to execute the tasks only during the first ;; time slice of the period. But then we could have periods starting ;; at different times: ;; ;; |.....|.....|.....| |.....|.....|.....| |.....|.....|.....| ;; xyz xyz xyz xyz xyz xyz xyz xyz x-- x-- x-- x-- ;; ;; |.....|.....|.....| |.....|.....|.....| |.....|.....|.....| ;; x x x x x x x x x x x x ;; .|.....|.....|..... .|.....|.....|..... .|.....|.....|..... ;; y y y y y y y y y ;; ..|.....|.....|.... ..|.....|.....|.... ..|.....|.....|.... ;; z z z z z z z z z ;; (defun schedule (current-time scheduled-time period dropablep exactp idlep precision) " RETURN: (values runp next-scheduled-time) NOTE: exactp => dropablep idlep <=> (zerop period) " (when (or (floatp current-time) (floatp scheduled-time) (floatp period)) (setf current-time (truncate current-time precision) scheduled-time (truncate scheduled-time precision) period (truncate period precision)) (when (zerop period) (setf period 1))) (cond ((< current-time scheduled-time) (values nil (* scheduled-time precision))) ; not yet (idlep (values t (* current-time precision))) (exactp (values (= current-time scheduled-time) (* (+ scheduled-time period) precision))) (dropablep ;; (assert (<= scheduled-time current-time)) (let ((next-scheduled-time (+ scheduled-time period))) (if (< current-time next-scheduled-time) (values t (* next-scheduled-time precision)) (values nil (* (+ current-time (- period (mod (- current-time scheduled-time) period))) precision))))) (t ;; (possible (< (+ scheduled-time period) current-time)) ;; We increment by period to keep the exact count. (values t (* (+ scheduled-time period) precision))))) (let ((next-activity-id 0)) (defun get-next-activity-id () (incf next-activity-id))) (defvar *current-activity* nil "The current activity.") (defvar *scheduler*) (defgeneric activity-closure (activity) (:documentation "RETURN: the closure executed each time the activity is scheduled.")) (defgeneric activity-dropable-p (activity) (:documentation "RETURN: Whether the activity should be skipped instead of scheduled too late.")) (defgeneric activity-exact-p (activity) (:documentation "RETURN: Whether the activity should be run only on exact time.")) (defgeneric activity-name (activity) (:documentation "RETURN: A label for the activity.")) (defgeneric activity-period (activity) (:documentation " RETURN: The period of this activity, expressed in seconds. If zero, then the activity is run as often as possible.")) (defgeneric activity-scheduled-time (activity) (:documentation "RETURN: The scheduled time this activity should run.")) (defclass activity () ((id :reader activity-id :initform (get-next-activity-id) :type integer :documentation "A unique ID for activities.") (name :accessor activity-name :initarg :name :initform "Unnamed" :type string :documentation "A label for the activity.") (closure :accessor activity-closure :initarg :closure :initform (function (lambda ())) :type function :documentation "The closure to be run periodically for this activity.") (scheduler :accessor activity-scheduler :initarg :scheduler :initform *scheduler* :type scheduler :documentation "The scheduler that schedules this activity.") (scheduled-time :initarg :scheduled-time :accessor activity-scheduled-time :initform 0 :type real :documentation "The scheduled time this activity should run.") (period :accessor activity-period :initarg :period :initform 0 :type real :documentation "The period of this activity, expressed in seconds. If zero, then the activity is run as often as possible.") (dropable :accessor activity-dropable-p :initarg :dropable :initform nil :type boolean :documentation "Whether the activity should be skipped instead of scheduled too late.") (exact :accessor activity-exact-p :initarg :exact :initform nil :type boolean :documentation "Whether the activity should be run only on exact time.")) (:documentation "An activity to be scheduled. ")) (defmethod initialize-instance :after ((self activity) &rest args &key (start-in 0 start-in-p) (start-at 0 start-at-p) &allow-other-keys) (declare (ignore args)) (when (and start-in-p start-at-p) (error ":START-IN and :START-AT are mutually exclusive.")) (cond (start-in-p (setf (slot-value self 'next-time) (+ (get-universal-time) start-in))) (start-at-p (setf (slot-value self 'next-time) start-at))) self) (defmethod print-object ((self activity) stream) (print-unreadable-object (self stream :type t :identity t) (format stream ":NAME ~S " (activity-name self)) (format stream ":scheduled-TIME ~A " (activity-scheduled-time self)) (format stream ":PERIOD ~A " (activity-period self)) (format stream ":dropable ~A " (activity-dropable-p self)) (format stream ":exact ~A " (activity-exact-p self))) self) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; TIME BASES ;;; ;;; We want universal-time, real-time and run-time, expressed in seconds, ;;; and for real-time, offset to match the universal-time (therefore ;;; being just the universal-time, but with more precision). ;;; Times are expressed in seconds as double-float. ;;; (deftype time-base () "A value that designates one of the timebases." '(member :universal-time :real-time :run-time)) (defgeneric precision (timebase) (:documentation "Return the number of seconds (or fraction of a second) that is the minimum non-zero difference between two calls to GET-TIME.") (:method ((timebase t)) (declare (ignorable timebase)) (error "Invalid TIMEBASE: ~S" timebase)) (:method ((timebase (eql :universal-time))) (declare (ignorable timebase)) 1.0d0) (:method ((timebase (eql :real-time))) (declare (ignorable timebase)) *internal-time-unit*) (:method ((timebase (eql :run-time))) (declare (ignorable timebase)) *internal-time-unit*)) (defgeneric get-time (timebase) (:documentation " RETURN: Current number of seconds since epoch. TIMEBASE: :universal-time to get the time from (get-univeral-time), :real-time to get the time from (get-internal-real-time), :run-time to get the time from (get-internal-run-time). (in all cases, the time is in number of seconds since the epoch).") (:method ((timebase t)) (declare (ignorable timebase)) (error "Invalid TIMEBASE: ~S" timebase)) (:method ((timebase (eql :universal-time))) (declare (ignorable timebase)) (get-universal-time)) (:method ((timebase (eql :real-time))) (declare (ignorable timebase)) (get-real-time)) (:method ((timebase (eql :run-time))) (declare (ignorable timebase)) (get-run-time))) (defgeneric wait-delay (timebase delay) (:documentation "Sleep for DELAY seconds. The default is to use CL:SLEEP. A 'persistent' scheduler could, when DELAY is big, save the image, setup the system to be launched again after the DELAY is elapsed and restart the scheduling then.") (:method ((timebase t) delay) (declare (ignorable timebase)) (when (plusp delay) (sleep delay)))) (defmethod get-time ((self activity)) (get-time (scheduler-time-base (activity-scheduler self)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; SCHEDULER ;;; #+debug-com.informatimago.common-lisp.cesarum.activity (defvar *in-terminal-p* (and (string/= "dumb" #+clisp (ext:getenv "TERM") #+ccl (ccl:getenv "TERM") #-(or clisp ccl) "xterm") (intersection (ensure-list (com.informatimago.common-lisp.cesarum.stream:bare-stream *terminal-io*)) (ensure-list (com.informatimago.common-lisp.cesarum.stream:bare-stream *standard-output*))))) #+debug-com.informatimago.common-lisp.cesarum.activity (defun formatalot (control-string &rest arguments) (let ((*print-pretty* nil)) ;; #-debug-com.informatimago.common-lisp.cesarum.activity ;; (apply (function format) *trace-output* control-string arguments) ;; #+debug-com.informatimago.common-lisp.cesarum.activity (dolist (line (com.informatimago.common-lisp.cesarum.string:split-string (apply (function format) nil control-string arguments) #(#\newline))) (if *in-terminal-p* (format *trace-output* "~A~A~A~A" (map 'string (function code-char) (com.informatimago.common-lisp.cesarum.ecma048:cr)) (map 'string (function code-char) (com.informatimago.common-lisp.cesarum.ecma048:el 3)) (map 'string (function code-char) (com.informatimago.common-lisp.cesarum.ecma048:cr)) line) (format *trace-output* "~A~%" line))))) (defmacro with-debug (&body body) #+debug-com.informatimago.common-lisp.cesarum.activity `(macrolet ((debug-format (control-string &rest arguments) `(formatalot "ACTIVITY: ~A" (format nil ,control-string ,@arguments)))) ,@body) #-debug-com.informatimago.common-lisp.cesarum.activity `(macrolet ((debug-format (control-string &rest arguments) (declare (ignore control-string arguments)) `(progn))) ,@body)) (defclass scheduler () ((activities :accessor scheduler-activities :initarg :activities :initform '() :type list ; of activity (possibly a circular list) :documentation "The list of activities scheduled by this scheduler.") (time-base :accessor scheduler-time-base :initarg :time-base :initform :universal-time :type time-base :documentation "The time-base used by this scheduler.")) (:documentation "The base class for schedulers.")) (defgeneric print-scheduler-activities (scheduler &optional stream)) (defgeneric scheduler-all-activities (scheduler)) (defgeneric schedule-activity (scheduler activity)) (defgeneric unschedule-activity (scheduler activity)) (defgeneric run (scheduler &key one-step until)) (defvar *rescheduled* nil "Ugly hack: If an idle activity creates a new periodic class, or otherwise changes the schedule, the idle-scheduler needs to yield the hand to it's time-scheduler.") (defmethod activity-scheduled-time :after ((activity activity)) (declare (ignore activity)) (setf *rescheduled* t)) (defclass idle-scheduler (scheduler) ((main-scheduler :accessor idle-scheduler-main-scheduler :initarg :main-scheduler :initform nil :type (or null scheduler) :documentation "The scheduler that should be given the activities that are not idle activities anymore (ie with period>0.")) (:documentation "The Idle Scheduler just runs the activities in round-robin fashion for ")) (defmethod scheduler-all-activities ((scheduler idle-scheduler)) (list-elements (scheduler-activities scheduler))) (defmethod schedule-activity ((scheduler idle-scheduler) (activity activity)) (setf *rescheduled* t) (cond ((zerop (activity-period activity)) (if (scheduler-activities scheduler) (push activity (scheduler-activities scheduler)) (setf (scheduler-activities scheduler) (list activity) (cdr (scheduler-activities scheduler)) (scheduler-activities scheduler)))) ((idle-scheduler-main-scheduler scheduler) (schedule-activity (idle-scheduler-main-scheduler scheduler) activity))) ;; otherwise silently ignore it. scheduler) (defmethod unschedule-activity ((scheduler idle-scheduler) (activity activity)) (let ((queue (scheduler-activities scheduler))) ;; let's remove activity from the circular list queue. (cond ((null queue)) ; nothing to do ((eq (cdr queue) queue) (when (eq (car queue) activity) (setf queue nil (activity-scheduler activity) nil))) (t (loop :for cur :on (cdr queue) :until (or (eq (car cur) activity) (eq cur queue)) :finally (when (eq (car cur) activity) (setf (cdr cur) (cddr cur) (activity-scheduler activity) nil))))) (setf (scheduler-activities scheduler) queue)) scheduler) (defmethod run ((self idle-scheduler) &key one-step until) " DO: Run idle activities. ONE-STEP: If true, runs only one activity (or don't sleep). UNTIL: Time until which activities must be run. " (with-debug (let ((*rescheduled* nil)) (flet ((run-step () (let ((activity (pop (scheduler-activities self)))) (debug-format "Will run idle activity ~S.~%" (activity-name activity)) (let ((*current-activity* activity)) (catch 'activity-yield (funcall (activity-closure activity)))) (debug-format "Did run idle activity ~S.~%" (activity-name activity)) (when (and (activity-scheduler activity) (plusp (activity-period activity))) ;; becomes a periodic activity. (debug-format "Activity ~S changed to periodic.~%" (activity-name activity)) (unschedule-activity self activity) (schedule-activity self activity))))) (if one-step (cond ((or (null until) (< (get-time (scheduler-time-base self)) until)) (if (scheduler-activities self) (run-step) (debug-format "No idle activity.~%"))) (t (debug-format "No time to run idle activities.~%"))) (cond ((null until) ;; idle tasks don't loop (if (scheduler-activities self) (run-step) (debug-format "No idle activity.~%"))) ((< (get-time (scheduler-time-base self)) until) (loop :while (and (scheduler-activities self) (< (get-time (scheduler-time-base self)) until) (not *rescheduled*)) :do (run-step) :finally (when (< (get-time (scheduler-time-base self)) until) (debug-format "No idle activity, will sleep ~A seconds, until ~A.~%" (- until (get-time (scheduler-time-base self))) until) (wait-delay (scheduler-time-base self) (- until (get-time (scheduler-time-base self))))))) (t (debug-format "No time to run idle activities.~%")))))))) (defclass time-scheduler (scheduler) ((idle-scheduler :accessor time-scheduler-idle-scheduler :initarg :idle-scheduler :type scheduler :documentation "The scheduler used when there's nothing to run for a while.")) (:documentation "The time scheduler runs activities at given times.")) (defgeneric time-scheduler-idle-activities (scheduler)) (defmethod time-scheduler-idle-activities ((scheduler time-scheduler)) (list-elements (scheduler-activities (time-scheduler-idle-scheduler scheduler)))) (defmethod scheduler-all-activities ((scheduler time-scheduler)) (nconc (time-scheduler-idle-activities scheduler) (list-elements (scheduler-activities scheduler)))) (defmethod schedule-activity ((scheduler time-scheduler) (activity activity)) " DO: Insert the activity in the right scheduler queue at the right place. DO: COMPUTE THE NEW NEXT-TIME, TRYING TO AVOID TIME DRIFT, BUT ENSURING THAT NEXT-TIME IS IN THE PRESENT-FUTURE. SEE ALSO: SCHEDULE. PRE: (= LAST (NEXT-TIME SELF)) (= NOW (GET-UNIVERSAL-TIME)) POST: (MAX NOW (= (NEXT-TIME SELF) (+ LAST (activity-PERIOD SELF)))) " (setf *rescheduled* t) (if (plusp (activity-period activity)) (let ((queue (cons nil (scheduler-activities scheduler))) (next-time (activity-scheduled-time activity))) (do ((place queue (cdr place))) ((or (null (cdr place)) (< next-time (activity-scheduled-time (cadr place)))) (push activity (cdr place)))) (setf (scheduler-activities scheduler) (cdr queue))) (schedule-activity (time-scheduler-idle-scheduler scheduler) activity)) scheduler) (defmethod unschedule-activity ((scheduler time-scheduler) (activity activity)) (setf *rescheduled* t) (setf (scheduler-activities scheduler) (delete activity (scheduler-activities scheduler)) (activity-scheduler activity) nil) scheduler) (defmethod run ((self time-scheduler) &key one-step until) " DO: Run timed activities. ONE-STEP: If true, runs only one activity (or don't sleep). UNTIL: Time until which activities must be run. " (with-debug (let ((*rescheduled* nil)) ;; with-slots (idle-activities scheduled-activities time-base) self (flet ((run-step () (let* ((activity (car (scheduler-activities self))) (scheduled-time (activity-scheduled-time activity)) (current-time (get-time (scheduler-time-base self)))) (debug-format "Now is ~D, current activity is ~S~%" current-time (activity-name activity)) (if (< current-time scheduled-time) (progn (debug-format "Running idle scheduler for ~A seconds.~%" (- scheduled-time current-time)) (run (time-scheduler-idle-scheduler self) :until scheduled-time)) (multiple-value-bind (runp next-scheduled-time) (schedule current-time scheduled-time (activity-period activity) (activity-dropable-p activity) (activity-exact-p activity) (zerop (activity-period activity)) (precision (scheduler-time-base self))) (setf (activity-scheduled-time activity) next-scheduled-time) (when runp (setf (scheduler-activities self) (cdr (scheduler-activities self))) (debug-format "Will run periodic activity ~S.~%" (activity-name activity)) (let ((*current-activity* activity)) (catch 'activity-yield (funcall (activity-closure activity)))) (debug-format "Did run periodic activity ~S.~%" (activity-name activity)) (when (activity-scheduler activity) (schedule-activity (activity-scheduler activity) activity)) (debug-format "Queue after rescheduling:~%") #+debug-com.informatimago.common-lisp.cesarum.activity (print-scheduler-activities self *trace-output*))))))) (if one-step (run-step) (cond ((null until) (loop :while (or (scheduler-activities self) (scheduler-activities (time-scheduler-idle-scheduler self))) :do (run-step))) ((< (get-time (scheduler-time-base self)) until) (loop :while (and (< (get-time (scheduler-time-base self)) until) (or (scheduler-activities self) (scheduler-activities (time-scheduler-idle-scheduler self)))) :do (run-step))) (t (debug-format "No more time to run activities.~%")))))))) (defun make-scheduler (time-base) (check-type time-base time-base) (make-instance 'time-scheduler :time-base time-base :idle-scheduler (make-instance 'idle-scheduler :time-base time-base))) (defparameter *scheduler* (make-scheduler :real-time #|:universal-time|#)) (defun activity-run (&key one-step until) " DO: Runs the scheduler. ONE-STEP: If true, runs only one activity (or don't sleep). UNTIL: Time (in universal-time seconds) until which activities must be run. " (run *scheduler* :one-step one-step :until until)) (defun format-for-field (activities field width precision) (if (some (lambda (act) (floatp (funcall field act))) activities) ;; ~V,VF (format nil "~~~D,~DF" width (truncate (- (log precision 10)))) (format nil "~~~DD" width))) (defmethod print-scheduler-activities ((scheduler time-scheduler) &optional (stream *standard-output*)) (let ((now (get-time (scheduler-time-base scheduler))) (line-cs (let ((precision (precision (scheduler-time-base scheduler))) (all-activities (scheduler-all-activities scheduler))) (print (list 'all-activities all-activities)) (finish-output) (format nil "~~&~~4D ~~8A ~A ~A ~~:[.~~;D~~]~~:[.~~;E~~] ~~S~~%" (format-for-field all-activities (function activity-scheduled-time) 16 precision) (format-for-field all-activities (function activity-period) 16 precision)))) (title-cs "~&~4A ~8A ~16A ~16A ~:[.~;D~]~:[.~;E~] ~S~%")) #+debug-com.informatimago.common-lisp.cesarum.activity (when *in-terminal-p* (format stream "~A" (map 'string (function code-char) (com.informatimago.common-lisp.cesarum.ecma048:ris)))) (flet ((line () (format stream "~&~4,,,'-A ~8,,,'-A ~16,,,'-A ~16,,,'-A -- ~32,,,'-A~%" "" "" "" "" ""))) (line) (format stream title-cs "ID" "STATE" "SCHEDULED TIME" "PERIOD" "D" "E" "NAME") (line) ;; TODO: Check if any period is float, and then format with 6 decimal digits. (flet ((print-activity (act &optional state) (format stream line-cs (activity-id act) (or state (if (eq act *current-activity*) "CURRENT" "ACTIVE")) (- (activity-scheduled-time act) now) (activity-period act) (activity-dropable-p act) (activity-exact-p act) (activity-name act)))) (loop :with queue = (if *current-activity* (if (member *current-activity* (scheduler-activities scheduler)) (scheduler-activities scheduler) (cons *current-activity* (scheduler-activities scheduler))) (scheduler-activities scheduler)) :for acts :on queue :for act = (car acts) :do (print-activity act) :until (eq (cdr acts) queue)) (loop :with queue = (scheduler-activities (time-scheduler-idle-scheduler scheduler)) :for acts :on queue :for act = (car acts) :do (print-activity act "IDLE") :until (eq (cdr acts) queue))) (line))) (values)) (defun print-activities (&optional (stream *standard-output*)) " DO: Prints on the STREAM a formated list of activities. STREAM: An output stream to which the list of activities is printed. Defaults to *STANDARD-OUTPUT*. " (print-scheduler-activities *scheduler* stream)) (defun make-activity (function &key (name "Unnamed activity") (start-at 0 start-at-p) (start-in 0 start-in-p) (period 1) (dropable nil) (exact nil) (idle nil) ((:scheduler *scheduler*) *scheduler*)) " FUNCTION: A closure, that will be repeatitively called at specified times. NAME: A string, naming the activity. PERIOD: A real indicating the period of the activity. If 0 then run it when idle. START-AT: (mutually exclusive with START-IN) The first universal-time at which the activity should run. START-IN: (mutually exclusive with START-AT) The number of seconds from now when the activity should be run first. If none of START-AT or START-IN is specified, the start time is now. *SCHEDULER* The scheduler used to run this activity. " (when (and start-in-p start-at-p) (error ":START-IN and :START-AT are mutually exclusive.")) (let ((activity (make-instance 'activity :name name :closure function :scheduler (if idle (time-scheduler-idle-scheduler *scheduler*) *scheduler*) :scheduled-time (cond (start-in-p (+ (get-time (scheduler-time-base *scheduler*)) start-in)) (start-at-p start-at) (t (get-time (scheduler-time-base *scheduler*)))) :period period :dropable dropable :exact exact))) (schedule-activity (activity-scheduler activity) activity) activity)) (defun current-activity () "RETURN: The current activity." *current-activity*) (defun activityp (object) " RETURN: Whether the OBJECT is an instance of the ACTIVITY class (or one of its subclasses). " (typep object 'activity)) (defun activity-yield () " DO: Returns control to the scheduler. NOTE: This may be called from an activity closure to return early to the scheduler. " (throw 'activity-yield nil)) (defun all-activities () " RETURN: A new list of all the activities. " (scheduler-all-activities *scheduler*)) (defgeneric find-activity-by-id (scheduler activity-id)) (defmethod find-activity-by-id ((scheduler idle-scheduler) id) (find id (scheduler-activities scheduler) :key (function activity-id))) (defmethod find-activity-by-id ((scheduler time-scheduler) id) (or (find id (scheduler-activities scheduler) :key (function activity-id)) (find id (scheduler-activities (time-scheduler-idle-scheduler scheduler)) :key (function activity-id)))) (defun destroy-activity (activity) " DO: Remove the activity from the scheduling queue. " (let ((scheduler (activity-scheduler activity))) (if (integerp activity) (unschedule-activity scheduler (find-activity-by-id scheduler activity)) (unschedule-activity scheduler activity))) (values)) ;;;; THE END ;;;;
34,374
Common Lisp
.lisp
764
35.373037
99
0.575979
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
fa19e0b960db3d43b8888712c5ac36ec8cf963a274dd73f809558fedf377d624
5,080
[ -1 ]
5,081
character-sets.lisp
informatimago_lisp/common-lisp/cesarum/character-sets.lisp
;;;; -*- coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: character-sets.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; See defpackage documentation string. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2012-04-06 <PJB> Moved the implementation specific stuff to ;;;; com.informatimago.clext.character-sets ;;;; CHARACTER-SET-TO-LISP-ENCODING ;;;; CHARACTER-SET-FROM-LISP-ENCODING ;;;; 2007-05-18 <PJB> Merged with stuff from make-depend, and augmented. ;;;; 2005-08-31 <PJB> Created (iana-character-sets.lisp). ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2005 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.CHARACTER-SETS" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STRING") (:export "CHARACTER-SET" "CS-MIB-ENUM" "CS-NAME" "CS-ALIASES" "CS-SOURCE" "CS-COMMENTS" "CS-REFERENCES" "CS-RANGES" "CS-LISP-ENCODING" "CS-EMACS-ENCODING" "CS-MIME-ENCODING" "REGISTER-CHARACTER-SET" "FIND-CHARACTER-SET" "CHARACTER-SET-ERROR" "CHARACTER-SET-ERROR-CHARACTER-SET" "CHARACTER-SET-TO-MIME-ENCODING" "CHARACTER-IN-CHARACTER-SET-P" "READ-CHARACTER-SETS-FILE" "*CHARACTER-SETS*") (:documentation " This package exports functions to manage character-sets, character encodings, coding systems and external format. It's all the same, but everyone likes to have his own terms... The base character set repertoire will be the IANA one, published at: http://www.iana.org/assignments/character-sets</a> The cs-lisp-encoding and cs-emacs-encoding of the character sets are hooked in by the implementation specific initialization code in the COM.INFORMATIMGO.CLEXT.CHARACTER-SET package. See also: COM.INFORMATIMGO.CLEXT.CHARACTER-SET License: AGPL3 Copyright Pascal J. Bourguignon 2005 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.CHARACTER-SETS") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; ;;;; Character-set descriptions. (obtained from processing IANA ;;;; charactet-sets file). ;;;; (defstruct (character-set (:conc-name cs-)) "Describes a character-set." ;; Identification. name is a string. aliases is a list of strings. mib-enum name aliases ;; Comments and other human readable information: source comments references ;; We associate each IANA character set with the lisp encoding and ;; the emacs encoding. ;; We keep only the current Common Lisp implementation encoding, to ;; promote standardization of implementation encoding names around ;; this IANA character set registry. (We don't want to manage cross ;; CL implementations encodings, let's go thru the IANA registry). lisp-encoding ;; However, we keep also here the emacs encoding for its important ;; application in reading source files edited with emacs. emacs-encoding ;; The preferred name for MIME is stored here, otherwise name is used. mime-encoding ;; Character ranges: a vector of pairs of unicode character codes: ;; [ (aref range (* 2 i)) (aref range (1+ (* 2 i))) ] ;; indicating which characters belong to the character set, ;; or NIL when unknown. ranges) (setf (documentation 'cs-mib-enum 'function) "The integer identifying the character set in the SNMP MIBs." (documentation 'cs-name 'function) "The name of the character set (a string)." (documentation 'cs-aliases 'function) "A list of aliases for the character set (strings)." (documentation 'cs-source 'function) "The normative reference specifying the character set (string)." (documentation 'cs-comments 'function) "A comment (string)." (documentation 'cs-references 'function) "References (string)." (documentation 'cs-lisp-encoding 'function) "The name of the encoding in the current lisp implementation." (documentation 'cs-emacs-encoding 'function) "The name of the encoding in GNU emacs." (documentation 'cs-mime-encoding 'function) "The name of the encoding in MIME." (documentation 'cs-ranges 'function) "The set of unicode ranges of the characters that are in this character-set.") (defgeneric character-set-error-character-set (error) (:documentation "The character-set in error.")) (define-condition character-set-error (error) ((character-set :initarg :character-set :reader character-set-error-character-set) (format-control :initarg :format-control :reader format-control) (format-arguments :initarg :format-arguments :reader format-arguments)) (:documentation "The CHARACTER-SET-ERROR condition.") (:report (lambda (condition stream) (format stream "~?" (format-control condition) (format-arguments condition))))) (defvar *character-sets* nil "The list of Character Sets.") (defun find-character-set (name) " RETURN: The character-set in *CHARACTER-SETS* that has NAME as name or alias, or some variation of NAME (removing non alphanumeric characters and prefixing 'cs'. " (flet ((memb (item list) (member item list :test (function string-equal)))) (declare (inline memb)) (let* ((name (string name)) (result (find-if (lambda (cs) (or (string-equal name (cs-name cs)) (memb name (cs-aliases cs)) (memb name (cs-lisp-encoding cs)) (memb name (cs-emacs-encoding cs)) (memb (concatenate 'string "cs" (remove-if-not (function alphanumericp) name)) (cs-aliases cs)))) *character-sets*))) ;; We move the found character set in front of the list to speed next ;; searches, assuming the application will often search several times ;; the same few character sets. (when result (setf *character-sets* (cons result (delete result *character-sets*)))) result))) (defun register-character-set (cs) " DO: Register a new character-set CS. If there's already a character set with the same name or aliase, signal a CHARACTER-SET-ERROR. RETURN: CS " (let ((old-cs (find-if (lambda (name) (find-character-set name)) (cons (cs-name cs) (cs-aliases cs))))) (if old-cs (error 'character-set-error :character-set old-cs :format-control "There is already a character set with same name or alias ~S" :format-arguments (list (cons (cs-name cs) (cs-aliases cs)))) (push cs *character-sets*))) cs) (defun character-in-character-set-p (character character-set) " RETURN: Whether the CHARACTER belongs to the CHARACTER-SET. " (let ((code (char-code character)) (ranges (cs-ranges character-set))) (if ranges (loop :for i :from 0 :below (length ranges) :by 2 :do (when (<= (aref ranges i) code (aref ranges (1+ i))) (return (values code :known))) :finally (return (values nil :known))) (values t :unknown)))) (defun encodings-not-in-iana (encodings) " RETURN: the subset of ENCODINGS that is not in *CHARACTER-SETS*. " (let ((result '())) (dolist (enc encodings result) (let ((cs (some (function find-character-set) enc))) (unless cs (push enc result)))))) (defun character-set-to-mime-encoding (cs) " RETURN: The MIME encoding of the given character set, or it's NAME. " (or (cs-mime-encoding cs) (cs-name cs))) (defun read-character-sets-file (file) " DO: Parse the <http://www.iana.org/assignments/character-sets> file, and extracts the character-sets defined there. RETURN: A list of character-set structures read from the file. " (let ((lines (with-open-file (in file) (loop :for line = (read-line in nil nil) :while (and line (not (prefixp "Character Set " line)))) (loop ;; join continuation lines. :with lines = '() :for line = (read-line in nil nil) :while (and line (not (prefixp "REFERENCES" line))) :do (if (and (<= 1 (length line)) (char= #\space (aref line 0)) lines) (setf (car lines) (concatenate 'string (car lines) " " (string-trim " " line))) (push line lines)) :finally (return (nreverse lines)))))) (flet ((trim (string start end) (string-trim " " (subseq string start end)))) (declare (inline trim)) (loop :with sets = '() :with cs = nil :for line :in lines :do (let ((spc (position #\space line)) (colon (position #\: line))) (if (and colon (or (not spc) (< colon spc))) (let ((name (subseq line 0 colon)) (value (string-trim " " (subseq line (1+ colon))))) (cond ((string-equal name "Name") (when cs (push cs sets)) (let ((left-bra (position #\[ value)) (spc (position #\space value)) name comment reference) (cond ((and left-bra (or (null spc) (< left-bra spc))) (setf name (trim value 0 left-bra) reference (trim value left-bra nil))) ((and left-bra spc (< spc left-bra)) (setf name (trim value 0 spc) comment (trim value spc left-bra) reference (trim value left-bra nil))) (spc (setf name (trim value 0 spc) comment (trim value spc nil))) (t (setf name (string-trim " " value)))) (setf cs (make-character-set :name name :references (when reference (list reference)))) (when comment (cond ((null comment)) ((search "preferred MIME " comment) (setf (cs-mime-encoding cs) name)) ((string/= "" comment) (push comment (cs-comments cs))))))) ((or (string-equal name "Alias") (string-equal name "Aliases")) (let ((spc (position #\space value)) alias comment) (if spc (setf alias (string-trim " " (subseq value 0 spc)) comment line) (setf alias value comment nil)) (when (search "preferred MIME " comment) (setf (cs-mime-encoding cs) alias)) (unless (string-equal "None" alias) (push alias (cs-aliases cs)) (when (and comment (string/= "" comment)) (push comment (cs-comments cs)))))) ((string-equal name "Source") (setf (cs-source cs) value)) ((string-equal name "MIBenum") (setf (cs-mib-enum cs) (parse-integer value))) ;; bug: ((string-equal name "http") (push line (cs-comments cs))))) (when cs (let ((comment (string-trim " " line))) (when (string/= "" comment) (push comment (cs-comments cs))))))) :finally (when cs (push cs sets)) (return sets))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Provide a default value for *CHARACTER-SETS* ;;; (setf *character-sets* (list (make-character-set :mib-enum 2052 :name "IBM865" :aliases '("csIBM865" "865" "cp865") :mime-encoding 'nil :source '"IBM DOS 3.3 Ref (Abridged), 94X9575 (Feb 1987)" :comments 'nil :references '("[RFC1345,KXS2]") :ranges #(0 127 160 161 163 164 170 172 176 178 181 181 183 183 186 186 188 189 191 191 196 199 201 201 209 209 214 214 216 216 220 220 223 226 228 239 241 244 246 252 255 255 402 402 915 915 920 920 931 931 934 934 937 937 945 945 948 949 960 960 963 964 966 966 8319 8319 8359 8359 8729 8730 8734 8734 8745 8745 8776 8776 8801 8801 8804 8805 8976 8976 8992 8993 9472 9472 9474 9474 9484 9484 9488 9488 9492 9492 9496 9496 9500 9500 9508 9508 9516 9516 9524 9524 9532 9532 9552 9580 9600 9600 9604 9604 9608 9608 9612 9612 9616 9619 9632 9632)) (make-character-set :mib-enum 2051 :name "IBM864" :aliases '("csIBM864" "cp864") :mime-encoding 'nil :source '"IBM Keyboard layouts and code pages, PN 07G4586 June 1991" :comments 'nil :references '("[RFC1345,KXS2]") :ranges #(0 36 38 127 160 160 162 164 166 166 171 173 176 177 183 183 187 189 215 215 247 247 946 946 966 966 1548 1548 1563 1563 1567 1567 1600 1600 1617 1617 1632 1642 8729 8730 8734 8734 8776 8776 9472 9472 9474 9474 9484 9484 9488 9488 9492 9492 9496 9496 9500 9500 9508 9508 9516 9516 9524 9524 9532 9532 9618 9618 9632 9632 65149 65149 65152 65157 65163 65163 65165 65167 65169 65169 65171 65171 65173 65173 65175 65175 65177 65177 65179 65179 65181 65181 65183 65183 65185 65185 65187 65187 65189 65189 65191 65191 65193 65193 65195 65195 65197 65197 65199 65199 65201 65201 65203 65203 65205 65205 65207 65207 65209 65209 65211 65211 65213 65213 65215 65215 65217 65217 65221 65221 65225 65233 65235 65235 65237 65237 65239 65239 65241 65241 65243 65243 65245 65245 65247 65247 65249 65249 65251 65251 65253 65253 65255 65255 65257 65257 65259 65261 65263 65267 65269 65272 65275 65276)) (make-character-set :mib-enum 38 :name #1="EUC-KR" :aliases '("csEUCKR") :mime-encoding '#1# :source '"RFC-1557 (see also KS_C_5861-1992)" :comments 'nil :references '("[RFC1557,Choi]") :ranges #(0 127 161 161 164 164 167 168 170 170 173 174 176 180 182 186 188 191 198 198 208 208 215 216 222 223 230 230 240 240 247 248 254 254 273 273 294 295 305 307 312 312 319 322 329 331 338 339 358 359 711 711 720 720 728 731 733 733 913 929 931 937 945 961 963 969 1025 1025 1040 1103 1105 1105 8213 8213 8216 8217 8220 8221 8224 8225 8229 8230 8240 8240 8242 8243 8251 8251 8308 8308 8319 8319 8321 8324 8364 8364 8451 8451 8457 8457 8467 8467 8470 8470 8481 8482 8486 8486 8491 8491 8531 8532 8539 8542 8544 8553 8560 8569 8592 8601 8658 8658 8660 8660 8704 8704 8706 8707 8711 8712 8715 8715 8719 8719 8721 8721 8730 8730 8733 8734 8736 8736 8741 8741 8743 8748 8750 8750 8756 8757 8764 8765 8786 8786 8800 8801 8804 8805 8810 8811 8834 8835 8838 8839 8857 8857 8869 8869 8978 8978 9312 9326 9332 9346 9372 9397 9424 9449 9472 9475 9484 9547 9618 9618 9632 9633 9635 9641 9650 9651 9654 9655 9660 9661 9664 9665 9670 9672 9675 9675 9678 9681 9733 9734 9742 9743 9756 9756 9758 9758 9792 9792 9794 9794 9824 9825 9827 9829 9831 9834 9836 9837 12288 12291 12296 12305 12307 12309 12353 12435 12449 12534 12593 12686 12800 12828 12896 12923 12927 12927 13184 13188 13192 13258 13263 13264 13267 13267 13270 13270 13272 13272 13275 13277 19968 19969 19971 19971 19975 19979 19981 19981 19985 19985 19988 19990 19992 19993 19998 19998 20013 20013 20018 20018 20024 20025 20027 20027 20034 20035 20037 20037 20043 20043 20045 20047 20054 20054 20056 20057 20061 20063 20075 20075 20077 20077 20083 20083 20086 20087 20094 20094 20098 20098 20102 20102 20104 20104 20107 20108 20110 20110 20112 20114 20116 20117 20120 20120 20123 20123 20126 20126 20129 20130 20132 20134 20136 20136 20139 20142 20150 20150 20154 20154 20160 20161 20164 20164 20167 20167 20170 20171 20173 20173 20180 20185 20189 20189 20191 20191 20195 20197 20208 20208 20210 20210 20214 20215 20219 20219 20225 20225 20233 20235 20237 20241 20271 20271 20276 20276 20278 20278 20280 20280 20282 20282 20284 20285 20291 20291 20294 20296 20301 20305 20309 20309 20313 20316 20329 20329 20335 20336 20339 20339 20342 20342 20346 20346 20350 20351 20353 20353 20355 20356 20358 20358 20360 20360 20362 20363 20365 20365 20367 20367 20369 20369 20374 20374 20376 20376 20379 20379 20381 20381 20398 20399 20405 20406 20415 20415 20418 20420 20425 20426 20430 20430 20433 20433 20435 20436 20439 20439 20442 20442 20445 20445 20447 20449 20462 20463 20465 20465 20467 20467 20469 20469 20472 20472 20474 20474 20482 20482 20486 20486 20489 20489 20491 20491 20493 20493 20497 20498 20502 20502 20505 20506 20508 20508 20510 20511 20513 20513 20515 20516 20518 20520 20522 20525 20539 20539 20547 20547 20551 20553 20559 20559 20565 20565 20570 20570 20572 20572 20581 20581 20596 20598 20600 20600 20608 20608 20613 20613 20621 20621 20625 20625 20632 20633 20652 20653 20658 20659 20661 20661 20663 20663 20670 20670 20677 20677 20681 20682 20687 20687 20689 20689 20693 20694 20698 20698 20702 20702 20709 20709 20711 20711 20717 20717 20729 20729 20731 20731 20735 20737 20740 20740 20742 20742 20745 20745 20754 20754 20767 20767 20769 20769 20778 20778 20786 20786 20791 20791 20794 20794 20796 20796 20800 20801 20803 20809 20811 20814 20818 20818 20828 20828 20834 20834 20837 20837 20839 20846 20849 20849 20853 20856 20860 20860 20864 20864 20870 20870 20874 20874 20877 20877 20882 20882 20885 20885 20887 20887 20896 20896 20901 20901 20906 20906 20908 20908 20918 20919 20925 20925 20932 20932 20934 20934 20937 20937 20939 20941 20956 20958 20961 20961 20976 20977 20982 20982 20984 20986 20989 20989 20992 20992 20995 20995 20998 21000 21002 21002 21006 21006 21009 21009 21015 21015 21021 21021 21028 21029 21033 21034 21038 21038 21040 21040 21046 21051 21059 21059 21063 21063 21066 21069 21076 21076 21078 21078 21083 21083 21085 21085 21089 21089 21097 21098 21103 21103 21106 21106 21109 21109 21117 21117 21119 21119 21123 21123 21127 21129 21133 21133 21137 21138 21147 21147 21151 21152 21155 21156 21161 21163 21182 21182 21185 21185 21187 21187 21189 21189 21191 21191 21193 21193 21197 21197 21202 21202 21205 21206 21208 21209 21211 21211 21213 21215 21218 21220 21235 21235 21237 21237 21240 21240 21242 21243 21246 21247 21253 21253 21256 21256 21261 21261 21263 21264 21269 21271 21273 21273 21280 21281 21283 21283 21290 21290 21295 21295 21305 21305 21311 21313 21315 21316 21319 21322 21325 21325 21329 21332 21335 21335 21338 21338 21340 21340 21342 21342 21344 21344 21350 21350 21352 21352 21359 21361 21364 21365 21367 21367 21373 21373 21375 21375 21380 21380 21395 21395 21400 21400 21402 21402 21407 21408 21413 21414 21421 21421 21435 21435 21443 21443 21448 21451 21453 21453 21460 21460 21462 21463 21467 21467 21473 21477 21481 21485 21487 21491 21496 21496 21507 21508 21512 21514 21516 21521 21531 21531 21533 21533 21535 21536 21542 21542 21545 21545 21547 21547 21555 21555 21560 21561 21563 21564 21566 21566 21570 21570 21576 21576 21578 21578 21585 21585 21608 21608 21610 21610 21617 21617 21619 21619 21621 21621 21627 21629 21632 21632 21638 21638 21644 21644 21646 21646 21648 21648 21668 21668 21672 21672 21675 21676 21683 21683 21688 21688 21693 21693 21696 21697 21700 21700 21704 21705 21729 21729 21733 21733 21736 21736 21741 21742 21746 21746 21754 21754 21764 21764 21766 21767 21774 21774 21776 21776 21788 21788 21807 21807 21809 21809 21813 21813 21822 21822 21828 21828 21830 21830 21839 21839 21843 21843 21846 21846 21854 21854 21859 21859 21884 21884 21888 21888 21892 21892 21894 21895 21897 21898 21912 21914 21916 21917 21927 21927 21929 21932 21934 21934 21957 21957 21959 21959 21972 21972 21978 21978 21980 21980 21983 21983 21987 21988 22013 22014 22022 22022 22025 22025 22036 22036 22039 22039 22063 22063 22066 22066 22068 22068 22070 22070 22099 22099 22120 22120 22123 22123 22132 22132 22150 22150 22181 22181 22188 22188 22190 22190 22196 22196 22204 22204 22218 22218 22221 22221 22225 22225 22234 22235 22238 22238 22240 22240 22256 22256 22265 22266 22275 22276 22280 22280 22283 22283 22285 22285 22290 22291 22294 22294 22296 22296 22303 22303 22312 22312 22317 22317 22320 22320 22331 22331 22336 22336 22338 22338 22343 22343 22346 22346 22349 22350 22352 22353 22369 22369 22372 22372 22374 22374 22378 22378 22382 22382 22384 22384 22389 22389 22396 22396 22402 22402 22408 22408 22411 22411 22419 22419 22432 22432 22434 22435 22467 22467 22471 22472 22475 22475 22478 22478 22495 22496 22512 22512 22516 22516 22519 22519 22521 22522 22524 22524 22528 22528 22530 22530 22533 22534 22536 22538 22558 22558 22561 22561 22564 22564 22567 22567 22570 22570 22575 22577 22580 22581 22586 22586 22602 22603 22607 22607 22609 22609 22612 22612 22615 22616 22618 22618 22622 22622 22625 22626 22628 22628 22645 22645 22649 22649 22652 22652 22654 22654 22659 22659 22661 22661 22665 22665 22675 22675 22684 22684 22686 22687 22696 22697 22702 22702 22707 22707 22714 22715 22718 22718 22721 22721 22725 22725 22727 22727 22734 22734 22737 22737 22739 22739 22741 22741 22744 22745 22750 22751 22756 22756 22763 22764 22767 22767 22777 22779 22781 22781 22799 22799 22804 22806 22809 22810 22812 22812 22818 22818 22823 22823 22825 22827 22829 22830 22833 22833 22839 22839 22846 22846 22852 22852 22855 22857 22862 22865 22868 22869 22871 22871 22874 22874 22880 22880 22882 22882 22887 22887 22890 22894 22899 22900 22904 22904 22909 22909 22914 22916 22922 22922 22931 22931 22934 22935 22937 22937 22949 22949 22952 22952 22956 22956 22969 22969 22971 22971 22974 22974 22979 22979 22982 22982 22985 22985 22987 22987 22992 22993 22995 22996 23001 23002 23004 23005 23014 23014 23016 23016 23018 23018 23020 23020 23022 23022 23032 23032 23035 23035 23039 23039 23041 23041 23043 23043 23057 23057 23064 23064 23067 23068 23071 23072 23077 23077 23081 23081 23094 23094 23100 23100 23105 23105 23110 23110 23113 23113 23130 23130 23138 23138 23142 23142 23186 23186 23194 23195 23204 23204 23233 23234 23236 23236 23241 23241 23244 23244 23265 23265 23270 23270 23273 23273 23301 23301 23305 23305 23307 23308 23318 23318 23338 23338 23360 23360 23363 23363 23376 23377 23380 23381 23383 23384 23386 23386 23388 23389 23391 23391 23395 23396 23401 23401 23403 23403 23408 23409 23413 23413 23416 23416 23418 23418 23420 23420 23429 23429 23431 23433 23435 23436 23439 23439 23443 23443 23445 23452 23458 23462 23468 23468 23470 23470 23472 23472 23475 23478 23480 23481 23487 23488 23490 23495 23500 23500 23504 23504 23506 23508 23511 23511 23518 23519 23521 23522 23524 23529 23531 23532 23534 23535 23541 23542 23544 23544 23546 23546 23553 23553 23556 23556 23559 23563 23565 23567 23569 23569 23574 23574 23577 23577 23588 23588 23592 23592 23601 23601 23608 23612 23614 23616 23621 23622 23624 23624 23627 23627 23629 23630 23633 23633 23637 23637 23643 23643 23648 23648 23650 23650 23652 23653 23660 23660 23663 23663 23665 23665 23673 23673 23696 23697 23713 23713 23721 23721 23723 23724 23729 23729 23731 23731 23733 23733 23735 23736 23738 23738 23742 23742 23744 23744 23769 23769 23776 23776 23784 23784 23791 23792 23796 23796 23798 23798 23803 23803 23805 23805 23815 23815 23821 23822 23825 23825 23828 23828 23830 23831 23833 23833 23847 23847 23849 23849 23883 23884 23888 23888 23913 23913 23916 23916 23919 23919 23943 23943 23947 23947 23965 23965 23968 23968 23970 23970 23978 23978 23992 23992 23994 23994 23996 23997 24013 24013 24018 24018 24022 24022 24029 24030 24033 24034 24037 24040 24043 24043 24046 24046 24049 24052 24055 24055 24061 24062 24066 24067 24070 24070 24076 24076 24081 24081 24086 24086 24089 24089 24091 24091 24093 24093 24101 24101 24107 24107 24109 24109 24115 24115 24118 24118 24120 24120 24125 24125 24127 24128 24132 24133 24135 24135 24140 24140 24149 24149 24159 24159 24161 24163 24178 24180 24183 24185 24187 24190 24196 24196 24199 24199 24202 24202 24207 24207 24213 24213 24215 24215 24218 24218 24220 24220 24224 24224 24230 24231 24235 24235 24237 24237 24245 24248 24254 24254 24258 24258 24264 24266 24272 24272 24275 24275 24278 24278 24282 24283 24287 24288 24290 24291 24300 24300 24307 24307 24310 24311 24314 24315 24321 24321 24324 24324 24330 24330 24335 24335 24337 24337 24339 24341 24343 24344 24347 24347 24351 24351 24358 24359 24361 24361 24369 24369 24373 24373 24378 24378 24380 24380 24392 24392 24394 24394 24396 24396 24398 24398 24406 24407 24409 24409 24411 24411 24418 24418 24422 24423 24425 24429 24432 24433 24439 24439 24441 24441 24444 24444 24447 24449 24453 24453 24455 24455 24458 24460 24464 24466 24471 24473 24478 24478 24480 24481 24488 24490 24494 24494 24501 24501 24503 24503 24505 24505 24509 24509 24515 24515 24517 24517 24524 24525 24534 24537 24544 24544 24555 24555 24565 24565 24573 24573 24575 24575 24591 24591 24594 24594 24598 24598 24604 24605 24608 24609 24613 24613 24615 24616 24618 24618 24623 24623 24641 24643 24653 24653 24656 24656 24658 24658 24661 24661 24665 24665 24669 24669 24674 24677 24680 24682 24684 24685 24687 24688 24709 24709 24713 24713 24716 24717 24724 24724 24726 24726 24730 24731 24735 24736 24739 24740 24743 24743 24752 24752 24754 24756 24758 24758 24760 24760 24764 24765 24773 24773 24775 24775 24785 24785 24794 24794 24796 24796 24799 24801 24816 24817 24819 24819 24822 24822 24825 24827 24833 24833 24838 24838 24840 24841 24845 24847 24853 24853 24858 24859 24863 24863 24871 24871 24880 24880 24884 24884 24887 24887 24892 24892 24894 24895 24898 24898 24900 24900 24903 24904 24906 24908 24915 24915 24917 24917 24920 24921 24925 24925 24927 24927 24930 24932 24935 24936 24939 24939 24942 24942 24944 24944 24950 24951 24957 24958 24961 24962 24970 24970 24974 24974 24976 24977 24980 24980 24984 24986 24996 24996 24999 24999 25001 25001 25003 25004 25006 25006 25010 25010 25014 25014 25018 25018 25022 25022 25027 25027 25031 25035 25062 25062 25074 25074 25078 25080 25082 25082 25084 25084 25087 25088 25095 25096 25098 25098 25100 25102 25104 25106 25110 25110 25114 25114 25119 25119 25121 25121 25130 25130 25134 25134 25136 25137 25140 25140 25142 25142 25150 25153 25159 25161 25163 25163 25165 25165 25171 25171 25176 25176 25198 25198 25201 25201 25206 25206 25209 25209 25212 25212 25215 25216 25220 25220 25225 25226 25233 25234 25237 25237 25239 25240 25243 25243 25259 25259 25265 25265 25269 25269 25273 25273 25276 25277 25282 25282 25287 25289 25292 25293 25295 25296 25298 25300 25302 25305 25307 25308 25324 25327 25329 25329 25331 25331 25335 25335 25342 25343 25345 25345 25351 25351 25353 25353 25361 25361 25387 25387 25391 25391 25402 25403 25405 25406 25417 25417 25420 25420 25423 25424 25429 25429 25447 25448 25454 25454 25458 25458 25463 25463 25466 25467 25471 25471 25475 25475 25480 25481 25484 25484 25490 25490 25494 25494 25496 25496 25499 25499 25504 25506 25509 25509 25511 25514 25536 25536 25540 25540 25542 25542 25551 25552 25558 25558 25562 25563 25569 25569 25581 25582 25588 25588 25590 25591 25613 25613 25615 25615 25620 25620 25622 25623 25628 25628 25634 25634 25644 25645 25658 25658 25662 25662 25688 25688 25696 25696 25705 25705 25711 25711 25720 25722 25736 25736 25745 25747 25754 25754 25758 25758 25764 25765 25771 25771 25773 25774 25776 25776 25778 25778 25787 25787 25793 25793 25796 25797 25799 25799 25802 25802 25805 25806 25810 25810 25812 25812 25816 25816 25818 25818 25825 25826 25829 25831 25836 25836 25842 25842 25844 25844 25850 25850 25854 25854 25856 25856 25860 25860 25880 25880 25885 25885 25891 25891 25898 25900 25903 25903 25910 25913 25915 25915 25918 25919 25925 25925 25928 25928 25933 25935 25937 25937 25942 25943 25950 25950 25954 25955 25958 25958 25964 25965 25970 25970 25972 25973 25975 25976 25982 25982 25986 25987 25989 25989 25991 25991 25996 25996 26000 26001 26007 26007 26009 26009 26011 26012 26015 26015 26017 26017 26020 26021 26023 26023 26027 26028 26031 26032 26039 26039 26041 26041 26044 26045 26049 26049 26053 26053 26059 26060 26063 26063 26066 26066 26071 26071 26080 26080 26083 26083 26085 26086 26088 26089 26092 26093 26097 26097 26100 26100 26106 26109 26111 26111 26118 26119 26121 26122 26124 26124 26126 26129 26131 26133 26142 26144 26149 26149 26151 26152 26157 26157 26159 26161 26164 26164 26166 26166 26170 26171 26177 26180 26185 26185 26187 26187 26191 26191 26201 26201 26203 26203 26205 26207 26212 26217 26219 26219 26222 26223 26227 26228 26230 26232 26234 26234 26244 26244 26247 26249 26254 26254 26256 26257 26262 26264 26269 26269 26272 26272 26274 26274 26283 26283 26286 26286 26290 26292 26297 26297 26299 26299 26302 26302 26308 26308 26310 26311 26313 26313 26326 26326 26329 26329 26332 26333 26336 26336 26342 26342 26352 26352 26354 26356 26359 26362 26364 26364 26366 26368 26371 26371 26376 26377 26379 26379 26381 26381 26388 26389 26391 26391 26395 26395 26397 26399 26406 26408 26410 26414 26417 26417 26420 26420 26422 26422 26426 26426 26429 26429 26438 26438 26441 26441 26446 26449 26451 26451 26454 26454 26460 26460 26462 26463 26477 26477 26479 26481 26483 26483 26485 26485 26487 26487 26491 26491 26494 26495 26503 26503 26505 26505 26507 26507 26511 26512 26515 26515 26517 26517 26519 26519 26522 26522 26524 26525 26543 26544 26547 26547 26550 26552 26558 26558 26564 26564 26575 26580 26586 26586 26589 26589 26601 26601 26604 26604 26607 26609 26611 26614 26619 26619 26622 26622 26642 26643 26646 26647 26657 26658 26666 26666 26671 26671 26680 26681 26684 26685 26688 26691 26696 26696 26702 26702 26704 26705 26707 26708 26733 26733 26742 26742 26751 26751 26753 26753 26757 26757 26767 26767 26771 26772 26775 26775 26781 26781 26783 26783 26785 26786 26791 26792 26797 26797 26799 26801 26803 26803 26805 26806 26820 26821 26825 26825 26827 26827 26829 26829 26834 26834 26837 26837 26839 26840 26842 26842 26847 26848 26855 26856 26862 26862 26866 26866 26873 26874 26880 26880 26885 26885 26893 26894 26898 26898 26919 26919 26928 26928 26941 26941 26943 26943 26954 26954 26963 26965 26967 26967 26969 26970 26974 26974 26976 26979 26984 26984 26987 26987 26989 26991 26997 26997 26999 27001 27029 27029 27035 27036 27045 27045 27047 27047 27054 27054 27060 27060 27067 27067 27073 27073 27075 27075 27083 27085 27088 27088 27112 27112 27114 27114 27131 27131 27133 27133 27135 27135 27138 27138 27146 27146 27153 27153 27155 27155 27159 27159 27161 27161 27166 27167 27169 27169 27171 27171 27189 27189 27192 27194 27197 27197 27204 27204 27208 27208 27211 27211 27218 27219 27224 27225 27231 27231 27233 27233 27243 27243 27264 27264 27268 27268 27273 27273 27277 27278 27287 27287 27292 27292 27298 27299 27315 27315 27323 27323 27330 27331 27347 27347 27354 27355 27382 27382 27387 27387 27396 27396 27402 27402 27404 27404 27410 27410 27414 27414 27424 27425 27427 27427 27442 27442 27450 27450 27453 27454 27462 27463 27468 27468 27470 27470 27472 27472 27487 27487 27489 27494 27498 27498 27506 27506 27511 27512 27515 27515 27519 27519 27523 27524 27526 27526 27529 27530 27542 27542 27544 27544 27550 27550 27566 27567 27570 27570 27573 27573 27575 27575 27578 27578 27580 27580 27583 27583 27585 27585 27589 27590 27595 27595 27597 27597 27599 27599 27602 27604 27606 27608 27611 27611 27627 27628 27656 27656 27663 27663 27665 27665 27667 27667 27683 27683 27700 27700 27703 27704 27710 27710 27712 27714 27726 27726 27728 27728 27733 27733 27735 27735 27738 27738 27741 27744 27752 27752 27754 27754 27757 27757 27760 27760 27762 27762 27766 27766 27770 27770 27773 27774 27777 27779 27781 27784 27788 27788 27792 27792 27794 27798 27801 27803 27819 27819 27822 27822 27827 27827 27832 27833 27835 27839 27841 27842 27844 27844 27849 27850 27852 27852 27859 27859 27861 27861 27863 27863 27867 27867 27873 27875 27877 27877 27880 27880 27883 27883 27886 27888 27891 27891 27915 27916 27921 27921 27927 27927 27929 27929 27931 27931 27934 27934 27941 27941 27943 27943 27945 27946 27954 27954 27957 27958 27960 27961 27963 27963 27965 27966 27969 27969 27993 27994 27996 27996 28003 28003 28006 28006 28009 28010 28012 28012 28014 28014 28020 28020 28023 28025 28031 28031 28037 28037 28039 28041 28044 28046 28049 28049 28051 28051 28053 28053 28079 28079 28082 28082 28085 28085 28096 28096 28099 28103 28107 28107 28111 28111 28113 28113 28120 28122 28126 28126 28129 28129 28136 28136 28138 28139 28142 28142 28145 28145 28147 28147 28149 28149 28151 28155 28183 28183 28185 28187 28191 28193 28195 28198 28203 28205 28207 28207 28210 28210 28212 28212 28214 28214 28216 28216 28218 28218 28220 28222 28227 28228 28234 28234 28237 28237 28246 28246 28248 28248 28251 28252 28254 28255 28263 28263 28267 28267 28270 28271 28274 28275 28282 28282 28304 28304 28310 28310 28316 28317 28319 28319 28322 28322 28325 28325 28330 28331 28335 28335 28337 28337 28342 28342 28346 28346 28354 28354 28356 28357 28361 28361 28363 28364 28366 28366 28369 28369 28371 28372 28399 28399 28404 28404 28408 28408 28414 28415 28417 28418 28422 28422 28431 28431 28433 28433 28436 28437 28448 28448 28450 28451 28459 28460 28465 28466 28472 28472 28479 28479 28481 28481 28497 28497 28500 28500 28503 28504 28506 28507 28510 28511 28514 28514 28516 28516 28525 28526 28528 28528 28538 28538 28540 28542 28545 28545 28548 28548 28552 28552 28557 28558 28560 28560 28564 28564 28567 28567 28579 28580 28583 28583 28590 28591 28593 28593 28595 28595 28601 28601 28606 28606 28608 28611 28618 28618 28629 28629 28634 28634 28639 28641 28644 28644 28649 28649 28651 28652 28655 28655 28657 28657 28670 28670 28673 28673 28677 28678 28681 28681 28683 28683 28687 28687 28689 28689 28693 28693 28696 28696 28698 28703 28707 28707 28711 28712 28719 28719 28727 28727 28734 28734 28748 28748 28752 28753 28760 28760 28765 28765 28771 28771 28779 28779 28784 28784 28792 28792 28796 28797 28805 28805 28810 28810 28814 28814 28818 28818 28824 28826 28833 28833 28836 28836 28843 28845 28847 28847 28851 28851 28855 28857 28872 28872 28875 28875 28879 28879 28888 28889 28893 28893 28895 28895 28913 28913 28921 28921 28925 28925 28932 28932 28937 28937 28940 28940 28953 28954 28958 28958 28961 28961 28966 28966 28976 28976 28982 28982 28999 28999 29001 29002 29004 29004 29006 29006 29008 29008 29014 29014 29017 29017 29020 29020 29022 29022 29028 29031 29033 29033 29036 29036 29038 29038 29053 29053 29060 29060 29065 29066 29071 29071 29074 29074 29076 29076 29081 29081 29087 29087 29090 29090 29100 29100 29105 29105 29113 29114 29118 29118 29121 29121 29123 29123 29128 29129 29134 29134 29136 29136 29138 29138 29140 29141 29151 29151 29157 29159 29165 29166 29179 29180 29182 29184 29190 29190 29200 29200 29211 29211 29226 29226 29228 29229 29232 29232 29234 29234 29237 29238 29242 29243 29245 29246 29248 29248 29254 29256 29260 29260 29266 29266 29272 29273 29275 29275 29277 29277 29279 29279 29281 29282 29287 29287 29289 29289 29298 29298 29305 29305 29309 29309 29312 29313 29346 29346 29351 29351 29356 29356 29359 29359 29376 29376 29378 29378 29380 29380 29390 29390 29392 29392 29399 29399 29401 29401 29409 29409 29417 29417 29432 29433 29436 29437 29450 29450 29462 29462 29467 29469 29477 29477 29481 29483 29494 29495 29502 29503 29508 29509 29520 29520 29522 29522 29527 29527 29544 29544 29546 29546 29552 29552 29554 29554 29557 29557 29560 29560 29562 29563 29572 29572 29574 29575 29577 29577 29579 29579 29582 29582 29588 29588 29590 29592 29599 29599 29607 29607 29609 29609 29613 29613 29618 29619 29625 29625 29632 29632 29634 29634 29641 29642 29644 29645 29647 29647 29654 29654 29657 29657 29661 29662 29664 29664 29667 29670 29673 29674 29677 29677 29687 29687 29689 29689 29693 29694 29697 29697 29699 29699 29701 29703 29705 29705 29715 29715 29723 29723 29728 29730 29733 29734 29736 29736 29738 29740 29742 29744 29747 29750 29752 29752 29754 29754 29759 29761 29763 29764 29771 29771 29781 29781 29783 29783 29785 29788 29790 29792 29794 29794 29796 29797 29800 29802 29807 29807 29822 29822 29826 29827 29831 29831 29833 29833 29835 29835 29848 29848 29852 29852 29854 29855 29857 29857 29859 29859 29861 29861 29863 29864 29866 29866 29872 29872 29874 29874 29877 29877 29881 29881 29885 29885 29887 29887 29894 29894 29898 29898 29903 29903 29908 29908 29912 29912 29914 29914 29916 29916 29920 29920 29922 29923 29926 29926 29934 29934 29943 29943 29953 29953 29956 29956 29969 29969 29973 29973 29976 29976 29978 29979 29983 29983 29987 29987 29989 29990 29992 29992 29995 29996 30000 30003 30007 30008 30010 30010 30023 30023 30028 30028 30031 30031 30033 30033 30035 30036 30041 30041 30043 30045 30050 30050 30053 30054 30058 30058 30063 30064 30069 30070 30072 30072 30074 30074 30079 30079 30086 30087 30090 30091 30094 30095 30097 30097 30109 30109 30117 30117 30123 30123 30129 30131 30133 30133 30136 30137 30140 30142 30146 30146 30149 30149 30151 30151 30157 30157 30162 30162 30164 30165 30168 30169 30171 30171 30178 30178 30192 30192 30194 30194 30196 30196 30202 30202 30204 30204 30208 30208 30221 30221 30233 30233 30239 30242 30244 30244 30246 30246 30267 30267 30274 30274 30284 30284 30286 30286 30290 30290 30294 30294 30305 30305 30308 30308 30313 30313 30316 30316 30320 30320 30322 30322 30328 30328 30331 30334 30340 30340 30342 30343 30350 30350 30352 30352 30355 30355 30382 30382 30394 30394 30399 30399 30402 30403 30406 30406 30408 30408 30410 30410 30418 30418 30422 30422 30427 30428 30430 30431 30433 30433 30435 30436 30439 30439 30446 30446 30450 30450 30452 30452 30456 30456 30460 30460 30462 30462 30465 30465 30468 30468 30472 30473 30475 30475 30494 30494 30496 30496 30505 30505 30519 30520 30522 30522 30524 30524 30528 30528 30541 30541 30555 30555 30561 30561 30563 30563 30566 30566 30571 30571 30585 30585 30590 30591 30603 30603 30609 30609 30622 30622 30629 30629 30636 30637 30640 30640 30643 30643 30651 30652 30655 30655 30679 30679 30683 30684 30690 30691 30693 30693 30697 30697 30701 30703 30707 30707 30722 30722 30738 30738 30757 30759 30764 30764 30770 30770 30772 30772 30789 30789 30799 30799 30813 30813 30827 30828 30831 30831 30844 30844 30849 30849 30855 30855 30860 30862 30865 30865 30871 30871 30883 30883 30887 30887 30889 30889 30906 30908 30913 30913 30917 30917 30922 30923 30926 30926 30928 30928 30952 30952 30956 30956 30959 30959 30965 30965 30971 30971 30977 30977 30990 30990 30998 30998 31018 31020 31034 31034 31038 31038 31040 31041 31047 31049 31056 31056 31062 31063 31066 31070 31072 31072 31077 31077 31080 31080 31085 31085 31098 31098 31103 31103 31105 31105 31117 31119 31121 31121 31142 31143 31146 31146 31150 31150 31153 31153 31155 31155 31161 31161 31165 31169 31177 31179 31185 31186 31189 31189 31192 31192 31199 31199 31204 31204 31206 31207 31209 31209 31227 31227 31232 31232 31237 31237 31240 31240 31243 31243 31245 31245 31252 31252 31255 31255 31257 31258 31260 31260 31263 31264 31278 31278 31281 31281 31286 31287 31291 31293 31295 31296 31302 31302 31305 31305 31309 31310 31319 31319 31329 31330 31337 31337 31339 31339 31344 31344 31348 31348 31350 31350 31353 31354 31357 31357 31359 31359 31361 31361 31364 31364 31368 31368 31378 31379 31381 31381 31384 31384 31391 31391 31401 31402 31406 31407 31418 31418 31428 31429 31431 31431 31434 31435 31447 31447 31449 31449 31453 31453 31455 31456 31459 31459 31461 31461 31466 31466 31469 31469 31471 31471 31478 31478 31481 31482 31487 31487 31503 31503 31505 31505 31513 31513 31515 31515 31518 31518 31520 31520 31526 31526 31532 31533 31545 31545 31558 31558 31561 31561 31563 31565 31567 31570 31572 31572 31574 31574 31584 31584 31596 31596 31598 31598 31605 31605 31613 31613 31623 31623 31627 31627 31631 31631 31636 31637 31639 31639 31642 31642 31645 31645 31649 31649 31661 31661 31665 31665 31668 31668 31672 31672 31680 31681 31684 31684 31686 31687 31689 31689 31698 31698 31712 31712 31716 31716 31721 31721 31751 31751 31762 31762 31774 31774 31777 31777 31783 31783 31786 31787 31805 31807 31811 31811 31820 31821 31840 31840 31844 31844 31852 31852 31859 31859 31875 31875 31881 31881 31890 31890 31893 31893 31895 31896 31903 31903 31909 31909 31911 31911 31918 31918 31921 31923 31929 31929 31934 31934 31946 31946 31958 31958 31966 31968 31975 31975 31995 31995 31998 31998 32000 32000 32002 32002 32004 32008 32010 32011 32013 32013 32016 32016 32020 32020 32023 32027 32032 32034 32043 32044 32046 32048 32051 32051 32053 32053 32057 32058 32066 32070 32080 32080 32094 32094 32097 32098 32102 32102 32104 32104 32106 32106 32110 32110 32113 32115 32118 32118 32121 32121 32127 32127 32142 32143 32147 32147 32156 32156 32160 32160 32162 32162 32172 32173 32177 32178 32180 32181 32184 32184 32186 32187 32189 32191 32199 32199 32202 32203 32214 32214 32216 32216 32218 32218 32221 32222 32224 32225 32227 32227 32232 32233 32236 32236 32239 32239 32244 32244 32251 32251 32265 32266 32277 32277 32283 32283 32285 32287 32289 32289 32291 32291 32299 32299 32302 32303 32305 32305 32311 32311 32317 32318 32321 32321 32323 32323 32326 32327 32338 32338 32340 32341 32350 32350 32353 32353 32361 32363 32365 32365 32368 32368 32377 32377 32380 32380 32386 32386 32396 32396 32399 32399 32403 32403 32406 32406 32408 32408 32411 32412 32566 32566 32568 32568 32570 32570 32588 32588 32592 32592 32596 32597 32618 32619 32622 32622 32624 32624 32626 32626 32629 32629 32631 32631 32633 32633 32645 32645 32648 32648 32650 32650 32652 32652 32654 32654 32660 32660 32666 32666 32670 32670 32676 32676 32680 32681 32690 32690 32696 32697 32701 32701 32705 32705 32709 32709 32714 32714 32716 32716 32718 32718 32722 32722 32724 32725 32735 32737 32745 32745 32747 32747 32752 32752 32761 32761 32764 32764 32768 32769 32771 32771 32773 32774 32777 32777 32780 32780 32784 32784 32789 32789 32791 32792 32813 32813 32819 32819 32822 32822 32829 32829 32831 32831 32835 32835 32838 32838 32842 32842 32854 32854 32856 32856 32858 32858 32862 32862 32879 32880 32882 32883 32887 32887 32893 32895 32900 32903 32905 32905 32907 32908 32918 32918 32923 32923 32925 32925 32929 32930 32933 32933 32937 32938 32943 32943 32945 32946 32948 32948 32954 32954 32963 32964 32972 32972 32974 32974 32986 32987 32990 32990 32993 32993 32996 32997 33009 33009 33012 33012 33016 33016 33021 33021 33026 33026 33029 33032 33034 33034 33048 33048 33050 33051 33059 33059 33065 33065 33067 33067 33071 33071 33081 33081 33086 33086 33099 33099 33102 33102 33104 33105 33108 33109 33125 33126 33131 33131 33136 33137 33144 33146 33151 33152 33160 33160 33162 33162 33167 33167 33178 33178 33180 33181 33184 33184 33187 33187 33192 33192 33203 33203 33205 33205 33210 33210 33213 33216 33218 33218 33222 33222 33229 33229 33240 33240 33247 33247 33251 33251 33253 33253 33255 33256 33258 33258 33261 33261 33267 33268 33274 33276 33278 33278 33285 33285 33287 33288 33290 33290 33292 33293 33298 33298 33307 33308 33310 33311 33313 33313 33322 33324 33333 33335 33337 33337 33344 33344 33349 33349 33351 33351 33369 33369 33380 33380 33382 33382 33390 33391 33393 33394 33398 33398 33400 33400 33406 33406 33419 33419 33421 33422 33426 33426 33433 33434 33437 33437 33439 33439 33445 33446 33449 33449 33452 33455 33457 33457 33459 33459 33463 33465 33467 33469 33471 33471 33489 33490 33492 33493 33495 33495 33499 33499 33502 33503 33505 33505 33509 33511 33521 33521 33533 33534 33537 33541 33545 33545 33559 33559 33576 33576 33579 33579 33583 33583 33585 33585 33588 33590 33592 33593 33600 33600 33607 33607 33609 33610 33615 33615 33617 33618 33651 33651 33655 33655 33659 33659 33673 33674 33678 33678 33686 33686 33688 33688 33694 33694 33698 33698 33705 33707 33725 33725 33729 33729 33733 33733 33737 33738 33740 33740 33747 33747 33750 33750 33756 33756 33769 33769 33771 33771 33775 33778 33780 33780 33785 33785 33789 33789 33795 33796 33802 33802 33804 33806 33833 33833 33836 33836 33841 33841 33848 33848 33853 33853 33865 33865 33879 33879 33883 33883 33889 33889 33891 33891 33894 33894 33899 33900 33903 33903 33909 33909 33914 33914 33936 33936 33940 33940 33945 33945 33948 33948 33953 33953 33970 33970 33976 33976 33979 33980 33983 33984 33986 33986 33988 33988 33990 33990 33993 33993 33995 33995 33997 33997 34001 34001 34010 34010 34028 34028 34030 34030 34036 34036 34044 34044 34065 34065 34067 34068 34071 34072 34074 34074 34078 34078 34081 34081 34083 34083 34085 34085 34092 34093 34095 34095 34109 34109 34111 34111 34113 34113 34115 34115 34121 34121 34126 34126 34131 34131 34137 34137 34147 34147 34152 34154 34157 34157 34180 34180 34183 34183 34191 34191 34193 34193 34196 34196 34203 34203 34214 34214 34216 34218 34223 34224 34234 34234 34241 34241 34249 34249 34253 34255 34261 34261 34268 34269 34276 34277 34281 34282 34295 34295 34298 34299 34303 34303 34306 34306 34310 34311 34314 34314 34326 34327 34330 34330 34349 34349 34367 34367 34382 34382 34384 34384 34388 34389 34395 34396 34398 34399 34407 34407 34425 34425 34442 34442 34444 34444 34451 34451 34467 34468 34473 34473 34503 34503 34507 34507 34516 34516 34521 34521 34523 34523 34527 34527 34532 34532 34541 34541 34558 34558 34560 34560 34562 34563 34568 34568 34584 34584 34586 34586 34588 34588 34638 34638 34645 34645 34647 34647 34655 34655 34662 34662 34664 34664 34676 34676 34678 34678 34680 34680 34690 34690 34701 34701 34719 34719 34722 34722 34739 34739 34746 34746 34756 34756 34784 34784 34796 34796 34799 34799 34802 34802 34809 34809 34811 34811 34814 34814 34821 34821 34847 34847 34850 34851 34865 34865 34870 34870 34875 34875 34880 34880 34886 34886 34892 34893 34898 34899 34903 34903 34905 34905 34907 34907 34909 34909 34913 34915 34920 34920 34923 34923 34928 34928 34930 34930 34935 34935 34942 34943 34945 34946 34952 34952 34955 34955 34957 34957 34962 34962 34966 34967 34974 34974 34987 34987 34996 34996 35009 35010 35023 35023 35028 35029 35033 35033 35036 35037 35039 35039 35041 35041 35048 35048 35059 35061 35064 35064 35069 35069 35079 35079 35088 35088 35090 35091 35096 35097 35109 35109 35114 35114 35126 35126 35128 35128 35131 35131 35137 35137 35140 35140 35167 35167 35172 35172 35178 35178 35186 35186 35199 35199 35201 35201 35203 35203 35206 35207 35211 35211 35215 35215 35219 35219 35222 35222 35233 35233 35241 35242 35250 35250 35258 35258 35261 35261 35264 35264 35282 35282 35299 35299 35316 35316 35320 35320 35328 35328 35330 35331 35336 35336 35338 35338 35340 35340 35342 35342 35347 35347 35350 35352 35355 35355 35357 35357 35359 35359 35363 35363 35365 35365 35370 35370 35373 35373 35377 35377 35380 35380 35382 35382 35386 35387 35408 35408 35412 35413 35419 35419 35422 35422 35424 35424 35426 35427 35430 35430 35433 35433 35437 35438 35440 35443 35445 35445 35449 35449 35461 35461 35463 35463 35468 35469 35475 35475 35477 35477 35480 35480 35486 35486 35488 35489 35491 35494 35496 35496 35498 35498 35504 35504 35506 35506 35513 35513 35516 35516 35518 35519 35522 35522 35524 35524 35527 35527 35531 35531 35533 35533 35535 35535 35538 35538 35542 35542 35547 35548 35553 35553 35558 35559 35562 35563 35565 35566 35569 35569 35574 35576 35578 35578 35582 35582 35584 35586 35588 35588 35598 35598 35600 35600 35604 35604 35606 35607 35609 35611 35613 35613 35616 35616 35624 35624 35627 35628 35635 35635 35641 35641 35649 35649 35657 35657 35662 35663 35672 35672 35674 35674 35676 35676 35686 35686 35692 35692 35695 35696 35700 35700 35703 35703 35709 35709 35712 35712 35722 35722 35728 35728 35730 35731 35734 35734 35738 35738 35895 35895 35903 35903 35905 35905 35910 35910 35912 35912 35914 35914 35916 35916 35925 35925 35930 35930 35937 35937 35946 35947 35961 35962 35970 35970 35978 35978 35980 35980 35997 35998 36000 36002 36007 36012 36015 36016 36019 36020 36022 36024 36027 36029 36031 36036 36039 36040 36042 36042 36049 36049 36051 36051 36058 36058 36060 36060 36062 36062 36064 36064 36066 36068 36070 36070 36074 36074 36077 36077 36084 36084 36091 36093 36100 36101 36103 36104 36106 36106 36109 36109 36115 36115 36118 36118 36196 36196 36198 36198 36203 36203 36208 36208 36211 36212 36215 36215 36229 36229 36234 36234 36249 36249 36259 36259 36264 36264 36275 36275 36282 36282 36286 36286 36294 36294 36299 36300 36303 36303 36315 36315 36317 36317 36321 36321 36323 36323 36328 36328 36335 36335 36339 36339 36362 36362 36367 36368 36382 36382 36394 36394 36400 36400 36405 36405 36418 36418 36420 36420 36423 36426 36441 36441 36447 36448 36468 36468 36470 36470 36481 36481 36487 36487 36490 36490 36493 36493 36522 36524 36544 36544 36554 36557 36562 36562 36575 36575 36587 36587 36600 36600 36603 36603 36606 36606 36611 36611 36613 36613 36617 36617 36626 36629 36635 36639 36646 36647 36649 36650 36655 36655 36659 36659 36664 36665 36667 36667 36670 36671 36676 36677 36681 36681 36685 36686 36701 36701 36703 36703 36706 36706 36763 36764 36771 36771 36774 36774 36776 36776 36781 36781 36783 36786 36802 36802 36805 36805 36814 36814 36817 36817 36820 36820 36838 36838 36842 36843 36845 36845 36848 36848 36850 36850 36855 36855 36857 36857 36861 36861 36864 36867 36869 36870 36872 36872 36875 36875 36877 36877 36879 36881 36884 36885 36887 36887 36889 36890 36893 36899 36910 36910 36913 36914 36917 36917 36920 36920 36924 36924 36926 36926 36929 36930 36935 36935 36938 36939 36941 36942 36944 36945 36947 36949 36953 36953 36956 36958 36960 36961 36963 36963 36969 36969 36973 36975 36978 36978 36981 36981 36983 36984 36986 36986 36988 36989 36991 36996 36999 37000 37002 37002 37007 37007 37009 37009 37013 37013 37017 37017 37026 37027 37030 37030 37032 37032 37034 37034 37039 37041 37045 37045 37048 37048 37057 37057 37066 37066 37086 37086 37089 37089 37096 37096 37101 37101 37109 37109 37117 37117 37122 37122 37138 37138 37141 37141 37145 37145 37159 37159 37165 37165 37170 37170 37193 37198 37202 37202 37218 37218 37225 37226 37228 37228 37237 37237 37239 37240 37255 37255 37257 37257 37259 37259 37261 37261 37266 37266 37276 37276 37291 37292 37294 37295 37297 37297 37300 37301 37312 37312 37319 37319 37321 37321 37323 37329 37335 37336 37340 37341 37347 37347 37351 37351 37354 37354 37365 37365 37389 37389 37392 37394 37399 37399 37406 37406 37428 37428 37434 37434 37439 37440 37445 37445 37449 37449 37463 37463 37467 37467 37470 37470 37474 37474 37476 37478 37504 37504 37507 37507 37509 37509 37521 37521 37523 37523 37526 37526 37528 37528 37532 37532 37555 37555 37558 37559 37561 37561 37580 37580 37583 37583 37586 37586 37604 37604 37610 37610 37624 37624 37628 37628 37636 37636 37648 37648 37656 37656 37658 37658 37662 37666 37668 37668 37670 37670 37672 37672 37675 37675 37678 37679 37704 37704 37706 37707 37709 37709 37716 37716 37723 37723 37742 37742 37749 37749 37756 37756 37758 37758 37772 37772 37780 37780 37782 37782 37786 37786 37795 37795 37799 37799 37804 37805 37808 37808 37827 37827 37841 37841 37854 37854 37857 37857 37860 37860 37878 37878 37892 37892 37912 37912 37925 37925 37931 37931 37941 37941 37944 37944 37956 37956 37969 37970 37979 37979 38013 38013 38015 38015 38263 38263 38272 38272 38275 38275 38281 38281 38283 38283 38287 38287 38289 38292 38296 38296 38307 38309 38312 38312 38317 38317 38321 38321 38331 38332 38343 38343 38346 38346 38356 38358 38364 38364 38369 38370 38428 38428 38433 38433 38442 38442 38446 38446 38450 38450 38459 38459 38463 38464 38466 38466 38468 38468 38475 38477 38480 38480 38491 38495 38498 38500 38506 38506 38512 38512 38515 38515 38517 38520 38525 38525 38533 38534 38538 38539 38541 38542 38548 38549 38552 38553 38555 38556 38563 38563 38567 38568 38570 38570 38577 38577 38583 38583 38587 38587 38592 38593 38596 38599 38601 38601 38603 38606 38613 38614 38617 38617 38619 38620 38626 38627 38632 38634 38639 38640 38642 38642 38646 38647 38649 38649 38651 38651 38656 38656 38662 38663 38673 38673 38675 38675 38678 38678 38681 38681 38684 38684 38686 38686 38695 38695 38704 38704 38706 38706 38713 38713 38717 38717 38722 38722 38724 38724 38728 38728 38737 38737 38742 38742 38748 38748 38750 38750 38753 38754 38761 38761 38765 38765 38772 38772 38775 38775 38778 38778 38795 38795 38797 38797 38799 38799 38816 38816 38824 38824 38827 38827 38829 38829 38854 38854 38859 38859 38867 38867 38876 38876 38899 38899 38902 38902 38907 38907 38911 38915 38917 38918 38920 38920 38922 38922 38924 38924 38928 38931 38935 38936 38957 38957 38960 38960 38968 38969 38971 38971 38982 38982 38988 38990 38996 38996 39000 39000 39002 39002 39006 39006 39013 39013 39015 39015 39019 39019 39023 39023 39080 39080 39087 39087 39089 39089 39108 39108 39111 39111 39131 39132 39135 39135 39137 39138 39149 39151 39156 39156 39164 39166 39171 39171 39177 39178 39180 39180 39184 39184 39187 39187 39192 39192 39198 39198 39200 39200 39208 39208 39237 39237 39241 39241 39243 39245 39249 39250 39252 39252 39255 39255 39318 39318 39321 39321 39325 39325 39333 39333 39336 39336 39340 39342 39345 39345 39347 39348 39353 39353 39361 39361 39376 39378 39381 39381 39385 39385 39389 39389 39391 39391 39405 39405 39409 39409 39423 39423 39425 39425 39432 39432 39438 39439 39449 39449 39467 39467 39472 39472 39478 39479 39488 39488 39491 39491 39493 39493 39501 39501 39509 39509 39511 39511 39514 39515 39519 39519 39522 39522 39525 39525 39529 39530 39592 39592 39608 39608 39635 39636 39640 39640 39653 39653 39662 39662 39706 39706 39719 39719 39722 39722 39729 39729 39740 39740 39745 39749 39759 39759 39764 39764 39770 39770 39791 39791 39822 39822 39825 39825 39839 39839 39851 39851 39854 39854 39881 39881 39894 39894 39908 39908 39912 39912 39949 39949 39952 39952 39954 39954 39957 39957 39973 39973 39986 39986 39995 39995 40007 40007 40009 40009 40023 40023 40165 40165 40167 40167 40169 40169 40179 40180 40182 40182 40201 40201 40219 40219 40230 40230 40232 40232 40251 40251 40273 40273 40285 40285 40288 40289 40300 40300 40306 40306 40361 40361 40367 40367 40372 40372 40388 40388 40407 40407 40434 40434 40440 40442 40474 40474 40478 40478 40565 40565 40569 40569 40573 40573 40575 40575 40594 40595 40599 40599 40605 40605 40607 40607 40613 40613 40628 40629 40635 40635 40638 40638 40643 40643 40653 40654 40657 40657 40660 40660 40664 40664 40667 40668 40670 40670 40680 40680 40692 40692 40711 40712 40718 40718 40723 40723 40736 40736 40763 40763 40778 40779 40782 40782 40786 40786 40799 40799 40801 40801 40807 40807 40810 40810 40812 40812 40823 40823 40845 40845 40848 40848 40853 40853 40860 40860 44032 55203 63744 64011 65281 65374 65504 65507 65509 65510 917504 917631)) (make-character-set :mib-enum 2082 :name "VISCII" :aliases '("csVISCII") :mime-encoding 'nil :source '"RFC 1456" :comments 'nil :references '("[RFC1456]") :ranges #(0 1 3 4 7 19 21 24 26 29 31 127 192 195 200 202 204 205 210 213 217 218 221 221 224 227 232 234 236 237 242 245 249 250 253 253 258 259 272 273 296 297 360 361 416 417 431 432 7840 7929 917504 917631)) (make-character-set :mib-enum 2084 :name #2="KOI8-R" :aliases '("csKOI8R") :mime-encoding '#2# :source '"RFC 1489, based on GOST-19768-74, ISO-6937/8, INIS-Cyrillic, ISO-5427." :comments 'nil :references '("[RFC1489]") :ranges #(0 127 160 160 169 169 176 176 178 178 183 183 247 247 1025 1025 1040 1103 1105 1105 8729 8730 8776 8776 8804 8805 8992 8993 9472 9472 9474 9474 9484 9484 9488 9488 9492 9492 9496 9496 9500 9500 9508 9508 9516 9516 9524 9524 9532 9532 9552 9580 9600 9600 9604 9604 9608 9608 9612 9612 9616 9619 9632 9632)) (make-character-set :mib-enum 2011 :name "IBM437" :aliases '("csPC8CodePage437" "437" "cp437") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges #(0 127 160 163 165 165 170 172 176 178 183 183 186 189 191 191 196 199 201 201 209 209 214 214 220 220 223 226 228 239 241 244 246 247 249 252 255 255 402 402 915 915 920 920 931 931 934 934 937 937 945 945 948 949 956 956 960 960 963 964 966 966 8319 8319 8359 8359 8729 8730 8734 8734 8745 8745 8776 8776 8801 8801 8804 8805 8976 8976 8992 8993 9472 9472 9474 9474 9484 9484 9488 9488 9492 9492 9496 9496 9500 9500 9508 9508 9516 9516 9524 9524 9532 9532 9552 9580 9600 9600 9604 9604 9608 9608 9612 9612 9616 9619 9632 9632)) (make-character-set :mib-enum 113 :name "GBK" :aliases '("windows-936" "MS936" "CP936") :mime-encoding 'nil :source '"Chinese IT Standardization Technical Committee Please see: <http://www.iana.org/assignments/charset-reg/GBK>" :comments 'nil :references 'nil :ranges #(0 127 164 164 167 168 176 177 183 183 215 215 224 225 232 234 236 237 242 243 247 247 249 250 252 252 257 257 275 275 283 283 299 299 324 324 328 328 333 333 363 363 462 462 464 464 466 466 468 468 470 470 472 472 474 474 476 476 593 593 609 609 711 711 713 715 729 729 913 929 931 937 945 961 963 969 1025 1025 1040 1103 1105 1105 8208 8208 8211 8214 8216 8217 8220 8221 8229 8230 8240 8240 8242 8243 8245 8245 8251 8251 8451 8451 8453 8453 8457 8457 8470 8470 8481 8481 8544 8555 8560 8569 8592 8595 8598 8601 8712 8712 8719 8719 8721 8721 8725 8725 8730 8730 8733 8736 8739 8739 8741 8741 8743 8747 8750 8750 8756 8759 8765 8765 8776 8776 8780 8780 8786 8786 8800 8801 8804 8807 8814 8815 8853 8853 8857 8857 8869 8869 8895 8895 8978 8978 9312 9321 9332 9371 9472 9547 9552 9587 9601 9615 9619 9621 9632 9633 9650 9651 9660 9661 9670 9671 9675 9675 9678 9679 9698 9701 9733 9734 9737 9737 9792 9792 9794 9794 12288 12291 12293 12311 12317 12318 12321 12329 12353 12435 12443 12446 12449 12534 12540 12542 12549 12585 12832 12841 12849 12849 12963 12963 13198 13199 13212 13214 13217 13217 13252 13252 13262 13262 13265 13266 13269 13269 19968 40869 63788 63788 63865 63865 63893 63893 63975 63975 63985 63985 64012 64015 64017 64017 64019 64020 64024 64024 64031 64033 64035 64036 64039 64041 65072 65073 65075 65092 65097 65106 65108 65111 65113 65126 65128 65131 65281 65374 65504 65509 917504 917631)) (make-character-set :mib-enum 1014 :name "UTF-16LE" :aliases 'nil :mime-encoding 'nil :source '"RFC 2781" :comments 'nil :references '("[RFC2781]") :ranges #(0 65535)) (make-character-set :mib-enum 114 :name "GB18030" :aliases 'nil :mime-encoding 'nil :source '"Chinese IT Standardization Technical Committee Please see: <http://www.iana.org/assignments/charset-reg/GB18030>" :comments 'nil :references 'nil :ranges #(0 544 546 563 592 685 688 750 768 847 864 879 884 885 890 890 894 894 900 906 908 908 910 929 931 974 976 1014 1024 1158 1160 1230 1232 1269 1272 1273 1280 1295 1329 1366 1369 1375 1377 1415 1417 1418 1425 1441 1443 1465 1467 1476 1488 1514 1520 1524 1548 1548 1563 1563 1567 1567 1569 1594 1600 1621 1632 1773 1776 1790 1792 1805 1807 1836 1840 1866 1920 1969 2305 2307 2309 2361 2364 2381 2384 2388 2392 2416 2433 2435 2437 2444 2447 2448 2451 2472 2474 2480 2482 2482 2486 2489 2492 2492 2494 2500 2503 2504 2507 2509 2519 2519 2524 2525 2527 2531 2534 2554 2562 2562 2565 2570 2575 2576 2579 2600 2602 2608 2610 2611 2613 2614 2616 2617 2620 2620 2622 2626 2631 2632 2635 2637 2649 2652 2654 2654 2662 2676 2689 2691 2693 2699 2701 2701 2703 2705 2707 2728 2730 2736 2738 2739 2741 2745 2748 2757 2759 2761 2763 2765 2768 2768 2784 2784 2790 2799 2817 2819 2821 2828 2831 2832 2835 2856 2858 2864 2866 2867 2870 2873 2876 2883 2887 2888 2891 2893 2902 2903 2908 2909 2911 2913 2918 2928 2946 2947 2949 2954 2958 2960 2962 2965 2969 2970 2972 2972 2974 2975 2979 2980 2984 2986 2990 2997 2999 3001 3006 3010 3014 3016 3018 3021 3031 3031 3047 3058 3073 3075 3077 3084 3086 3088 3090 3112 3114 3123 3125 3129 3134 3140 3142 3144 3146 3149 3157 3158 3168 3169 3174 3183 3202 3203 3205 3212 3214 3216 3218 3240 3242 3251 3253 3257 3262 3268 3270 3272 3274 3277 3285 3286 3294 3294 3296 3297 3302 3311 3330 3331 3333 3340 3342 3344 3346 3368 3370 3385 3390 3395 3398 3400 3402 3405 3415 3415 3424 3425 3430 3439 3458 3459 3461 3478 3482 3505 3507 3515 3517 3517 3520 3526 3530 3530 3535 3540 3542 3542 3544 3551 3570 3572 3585 3642 3647 3675 3713 3714 3716 3716 3719 3720 3722 3722 3725 3725 3732 3735 3737 3743 3745 3747 3749 3749 3751 3751 3754 3755 3757 3769 3771 3773 3776 3780 3782 3782 3784 3789 3792 3801 3804 3805 3840 3911 3913 3946 3953 3979 3984 3991 3993 4028 4030 4044 4047 4047 4096 4129 4131 4135 4137 4138 4140 4146 4150 4153 4160 4185 4256 4293 4304 4344 4347 4347 4352 4441 4447 4514 4520 4601 4608 4614 4616 4678 4680 4680 4682 4685 4688 4694 4696 4696 4698 4701 4704 4742 4744 4744 4746 4749 4752 4782 4784 4784 4786 4789 4792 4798 4800 4800 4802 4805 4808 4814 4816 4822 4824 4846 4848 4878 4880 4880 4882 4885 4888 4894 4896 4934 4936 4954 4961 4988 5024 5108 5121 5750 5760 5788 5792 5872 5888 5900 5902 5908 5920 5942 5952 5971 5984 5996 5998 6000 6002 6003 6016 6108 6112 6121 6144 6158 6160 6169 6176 6263 6272 6313 7680 7835 7840 7929 7936 7957 7960 7965 7968 8005 8008 8013 8016 8023 8025 8025 8027 8027 8029 8029 8031 8061 8064 8116 8118 8132 8134 8147 8150 8155 8157 8175 8178 8180 8182 8190 8192 8274 8279 8279 8287 8291 8298 8305 8308 8334 8352 8369 8400 8426 8448 8506 8509 8523 8531 8579 8592 9166 9216 9254 9280 9290 9312 9470 9472 9747 9750 9751 9753 9853 9856 9865 9985 9988 9990 9993 9996 10023 10025 10059 10061 10061 10063 10066 10070 10070 10072 10078 10081 10132 10136 10159 10161 10174 10192 10219 10224 11007 11904 11929 11931 12019 12032 12245 12272 12283 12288 12351 12353 12438 12441 12543 12549 12588 12593 12686 12688 12727 12784 12828 12832 12867 12881 12923 12927 13003 13008 13054 13056 13174 13179 13277 13280 13310 13312 19893 19968 40869 40960 42124 42128 42182 44032 55203 57344 64045 64048 64106 64256 64262 64275 64279 64285 64310 64312 64316 64318 64318 64320 64321 64323 64324 64326 64433 64467 64831 64848 64911 64914 64967 65008 65020 65024 65039 65056 65059 65072 65094 65097 65106 65108 65126 65128 65131 65136 65140 65142 65276 65279 65279 65281 65470 65474 65479 65482 65487 65490 65495 65498 65500 65504 65510 65512 65518 65529 65533)) (make-character-set :mib-enum 2048 :name "IBM860" :aliases '("csIBM860" "860" "cp860") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges #(0 127 160 163 170 172 176 178 183 183 186 189 191 195 199 202 204 205 209 213 217 218 220 220 223 227 231 234 236 237 241 245 247 247 249 250 252 252 915 915 920 920 931 931 934 934 937 937 945 945 948 949 956 956 960 960 963 964 966 966 8319 8319 8359 8359 8729 8730 8734 8734 8745 8745 8776 8776 8801 8801 8804 8805 8992 8993 9472 9472 9474 9474 9484 9484 9488 9488 9492 9492 9496 9496 9500 9500 9508 9508 9516 9516 9524 9524 9532 9532 9552 9580 9600 9600 9604 9604 9608 9608 9612 9612 9616 9619 9632 9632)) (make-character-set :mib-enum 1019 :name "UTF-32LE" :aliases 'nil :mime-encoding 'nil :source '"<http://www.unicode.org/unicode/reports/tr19/>" :comments 'nil :references '("[Davis]") :ranges #(0 1114111)) (make-character-set :mib-enum 1001 :name "ISO-10646-UCS-4" :aliases '("csUCS4") :mime-encoding 'nil :source '"the full code space. (same comment about byte order, these are 31-bit numbers." :comments 'nil :references 'nil :ranges #(0 1114111)) (make-character-set :mib-enum 2087 :name "IBM775" :aliases '("csPC775Baltic" "cp775") :mime-encoding 'nil :source '"HP PCL 5 Comparison Guide (P/N 5021-0329) pp B-13, 1996" :comments 'nil :references '("[HP-PCL5]") :ranges #(0 127 160 160 162 164 166 167 169 169 171 174 176 179 181 183 185 185 187 190 196 198 201 201 211 211 213 216 220 220 223 223 228 230 233 233 243 243 245 248 252 252 256 257 260 263 268 269 274 275 278 281 290 291 298 299 302 303 310 311 315 316 321 326 332 333 342 343 346 347 352 353 362 363 370 371 377 382 8217 8217 8220 8222 8729 8729 9472 9472 9474 9474 9484 9484 9488 9488 9492 9492 9496 9496 9500 9500 9508 9508 9516 9516 9524 9524 9532 9532 9552 9553 9556 9556 9559 9559 9562 9562 9565 9565 9568 9568 9571 9571 9574 9574 9577 9577 9580 9580 9600 9600 9604 9604 9608 9608 9612 9612 9616 9619 9632 9632)) (make-character-set :mib-enum 1013 :name "UTF-16BE" :aliases 'nil :mime-encoding 'nil :source '"RFC 2781" :comments 'nil :references '("[RFC2781]") :ranges #(0 65535)) (make-character-set :mib-enum 11 :name "ISO_8859-8:1988" :aliases '("csISOLatinHebrew" "hebrew" #3="ISO-8859-8" "ISO_8859-8" "iso-ir-138") :mime-encoding '#3# :source '"ECMA registry" :comments '("Alias: ISO-8859-8 (preferred MIME name)") :references '("[RFC1345,KXS2]") :ranges #(0 160 162 169 171 185 187 190 215 215 247 247 1488 1514 8206 8207 8215 8215)) (make-character-set :mib-enum 2004 :name "hp-roman8" :aliases '("csHPRoman8" "r8" "roman8") :mime-encoding 'nil :source '"LaserJet IIP Printer User's Manual, HP part no 33471-90901, Hewlet-Packard, June 1989." :comments 'nil :references '("[HP-PCL5,RFC1345,KXS2]") :ranges #(0 165 167 168 170 171 175 177 180 183 186 214 216 246 248 255 352 353 376 376 402 402 710 710 715 715 732 732 8212 8212 8356 8356 9632 9632)) (make-character-set :mib-enum 2010 :name "IBM852" :aliases '("csPCp852" "852" "cp852") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges #(0 127 160 160 164 164 167 168 171 173 176 176 180 180 184 184 187 187 193 194 196 196 199 199 201 201 203 203 205 206 211 212 214 215 218 218 220 221 223 223 225 226 228 228 231 231 233 233 235 235 237 238 243 244 246 247 250 250 252 253 258 263 268 273 280 283 313 314 317 318 321 324 327 328 336 337 340 341 344 347 350 357 366 369 377 382 711 711 728 729 731 731 733 733 9472 9472 9474 9474 9484 9484 9488 9488 9492 9492 9496 9496 9500 9500 9508 9508 9516 9516 9524 9524 9532 9532 9552 9553 9556 9556 9559 9559 9562 9562 9565 9565 9568 9568 9571 9571 9574 9574 9577 9577 9580 9580 9600 9600 9604 9604 9608 9608 9617 9619 9632 9632)) (make-character-set :mib-enum 12 :name "ISO_8859-9:1989" :aliases '("csISOLatin5" "l5" "latin5" #4="ISO-8859-9" "ISO_8859-9" "iso-ir-148") :mime-encoding '#4# :source '"ECMA registry" :comments '("Alias: ISO-8859-9 (preferred MIME name)") :references '("[RFC1345,KXS2]") :ranges #(0 207 209 220 223 239 241 252 255 255 286 287 304 305 350 351)) (make-character-set :mib-enum 2054 :name "IBM869" :aliases '("csIBM869" "cp-gr" "869" "cp869") :mime-encoding 'nil :source '"IBM Keyboard layouts and code pages, PN 07G4586 June 1991" :comments 'nil :references '("[RFC1345,KXS2]") :ranges #(0 127 160 160 163 163 166 169 171 173 176 180 187 187 189 189 901 906 908 908 910 929 931 974 8213 8213 8216 8217 9472 9472 9474 9474 9484 9484 9488 9488 9492 9492 9496 9496 9500 9500 9508 9508 9516 9516 9524 9524 9532 9532 9552 9553 9556 9556 9559 9559 9562 9562 9565 9565 9568 9568 9571 9571 9574 9574 9577 9577 9580 9580 9600 9600 9604 9604 9608 9608 9617 9619 9632 9632)) (make-character-set :mib-enum 39 :name #5="ISO-2022-JP" :aliases '("csISO2022JP") :mime-encoding '#5# :source '"RFC-1468 (see also RFC-2237)" :comments 'nil :references '("[RFC1468,Murai]") :ranges #(0 127 162 163 165 165 167 168 172 172 176 177 180 180 182 182 215 215 247 247 913 929 931 937 945 961 963 969 1025 1025 1040 1103 1105 1105 8208 8208 8213 8214 8216 8217 8220 8221 8224 8225 8229 8230 8240 8240 8242 8243 8251 8251 8254 8254 8451 8451 8491 8491 8592 8595 8658 8658 8660 8660 8704 8704 8706 8707 8711 8712 8715 8715 8722 8722 8730 8730 8733 8734 8736 8736 8743 8748 8756 8757 8765 8765 8786 8786 8800 8801 8806 8807 8810 8811 8834 8835 8838 8839 8869 8869 8978 8978 9472 9475 9484 9484 9487 9488 9491 9492 9495 9496 9499 9501 9504 9504 9507 9509 9512 9512 9515 9516 9519 9520 9523 9524 9527 9528 9531 9532 9535 9535 9538 9538 9547 9547 9632 9633 9650 9651 9660 9661 9670 9671 9675 9675 9678 9679 9711 9711 9733 9734 9792 9792 9794 9794 9834 9834 9837 9837 9839 9839 12288 12291 12293 12309 12316 12316 12353 12435 12443 12446 12449 12534 12539 12542 19968 19969 19971 19971 19975 19979 19981 19982 19984 19985 19988 19993 19998 19998 20001 20001 20006 20006 20010 20010 20013 20013 20017 20018 20022 20022 20024 20025 20027 20028 20031 20031 20034 20035 20037 20037 20043 20043 20045 20047 20053 20057 20061 20063 20066 20066 20081 20081 20083 20083 20094 20094 20096 20096 20098 20098 20101 20102 20104 20108 20110 20110 20113 20114 20116 20117 20120 20121 20123 20124 20126 20130 20132 20134 20136 20136 20139 20142 20144 20144 20147 20147 20150 20150 20154 20154 20160 20162 20164 20164 20166 20167 20170 20171 20173 20175 20180 20185 20189 20191 20195 20197 20205 20206 20208 20208 20210 20210 20214 20215 20219 20219 20225 20225 20233 20234 20237 20241 20250 20250 20252 20253 20271 20272 20276 20276 20278 20278 20280 20280 20282 20282 20284 20285 20291 20291 20294 20295 20301 20305 20307 20307 20309 20309 20311 20311 20313 20318 20329 20329 20335 20336 20339 20339 20341 20342 20347 20348 20351 20351 20355 20355 20358 20358 20360 20360 20363 20363 20365 20365 20367 20367 20369 20369 20374 20374 20376 20376 20379 20379 20381 20381 20384 20385 20395 20395 20397 20399 20405 20406 20415 20415 20418 20420 20426 20426 20430 20430 20432 20433 20436 20436 20439 20440 20442 20443 20445 20445 20447 20447 20449 20449 20451 20453 20462 20463 20467 20467 20469 20470 20472 20472 20474 20474 20478 20478 20485 20486 20489 20489 20491 20491 20493 20493 20495 20495 20497 20498 20500 20500 20502 20502 20505 20506 20511 20511 20513 20513 20515 20518 20520 20525 20534 20534 20537 20537 20547 20547 20551 20553 20559 20560 20565 20566 20570 20570 20572 20572 20581 20581 20588 20588 20594 20594 20596 20598 20600 20600 20605 20605 20608 20608 20613 20613 20621 20621 20625 20625 20632 20634 20652 20653 20658 20661 20663 20663 20670 20670 20674 20674 20677 20677 20681 20682 20685 20685 20687 20687 20689 20689 20693 20694 20698 20698 20702 20702 20707 20707 20709 20709 20711 20711 20717 20718 20725 20725 20729 20729 20731 20731 20736 20738 20740 20740 20745 20745 20754 20754 20756 20758 20760 20760 20762 20762 20767 20767 20769 20769 20778 20778 20786 20786 20791 20791 20794 20796 20799 20801 20803 20809 20811 20814 20816 20816 20818 20818 20820 20820 20826 20826 20828 20828 20834 20834 20837 20837 20840 20846 20849 20849 20853 20856 20860 20860 20864 20864 20866 20866 20869 20870 20873 20874 20876 20877 20879 20883 20885 20887 20889 20889 20896 20896 20898 20898 20900 20902 20904 20908 20912 20919 20925 20925 20932 20934 20937 20937 20939 20941 20950 20950 20955 20957 20960 20961 20966 20967 20969 20970 20973 20973 20976 20977 20981 20982 20984 20986 20989 20990 20992 20992 20995 20996 20998 21000 21002 21003 21006 21006 21009 21009 21012 21012 21015 21015 21021 21021 21028 21029 21031 21031 21033 21034 21038 21038 21040 21040 21043 21043 21046 21051 21059 21060 21063 21063 21066 21069 21071 21071 21076 21076 21078 21078 21083 21083 21086 21086 21091 21093 21097 21098 21103 21109 21117 21117 21119 21119 21123 21123 21127 21129 21133 21133 21137 21138 21140 21140 21147 21147 21151 21152 21155 21155 21161 21165 21169 21169 21172 21173 21177 21177 21180 21180 21182 21182 21185 21185 21187 21187 21189 21189 21191 21191 21193 21193 21197 21197 21202 21202 21205 21205 21207 21209 21213 21216 21218 21220 21222 21223 21234 21235 21237 21237 21240 21242 21246 21247 21249 21250 21253 21254 21256 21256 21261 21261 21263 21264 21269 21271 21273 21274 21277 21277 21280 21281 21283 21283 21290 21290 21295 21295 21297 21297 21299 21299 21304 21307 21311 21313 21315 21315 21317 21322 21325 21325 21329 21332 21335 21336 21338 21338 21340 21340 21342 21342 21344 21344 21350 21350 21353 21353 21358 21361 21363 21365 21367 21368 21371 21371 21375 21375 21378 21378 21380 21380 21398 21398 21400 21400 21402 21402 21407 21408 21413 21414 21416 21417 21421 21422 21424 21424 21427 21427 21430 21430 21435 21435 21442 21443 21448 21454 21460 21460 21462 21463 21465 21465 21467 21467 21471 21471 21473 21477 21480 21491 21494 21496 21498 21498 21505 21505 21507 21508 21512 21521 21531 21531 21533 21533 21535 21536 21542 21542 21545 21545 21547 21550 21558 21558 21560 21561 21563 21566 21568 21568 21570 21570 21574 21574 21576 21578 21582 21582 21585 21585 21599 21599 21608 21608 21610 21610 21616 21617 21619 21619 21621 21623 21627 21629 21632 21632 21636 21636 21638 21638 21643 21644 21646 21648 21650 21650 21666 21666 21668 21669 21672 21672 21675 21676 21679 21679 21682 21683 21688 21688 21692 21694 21696 21698 21700 21700 21703 21705 21720 21720 21729 21730 21733 21734 21736 21737 21741 21742 21746 21746 21754 21754 21757 21757 21764 21764 21766 21767 21775 21776 21780 21780 21782 21782 21806 21807 21809 21809 21811 21811 21816 21817 21822 21822 21824 21824 21828 21830 21836 21836 21839 21839 21843 21843 21846 21847 21852 21853 21859 21859 21883 21884 21886 21886 21888 21888 21891 21892 21895 21895 21897 21899 21912 21914 21916 21919 21927 21932 21934 21934 21936 21936 21942 21942 21956 21957 21959 21959 21972 21972 21978 21978 21980 21980 21983 21983 21987 21988 22007 22007 22009 22009 22013 22014 22022 22022 22025 22025 22036 22036 22038 22040 22043 22043 22057 22057 22063 22063 22065 22066 22068 22068 22070 22070 22072 22072 22082 22082 22092 22092 22094 22094 22096 22096 22107 22107 22116 22116 22120 22120 22122 22124 22132 22132 22136 22136 22138 22138 22144 22144 22150 22151 22154 22154 22159 22159 22164 22164 22176 22176 22178 22178 22181 22181 22190 22190 22196 22196 22198 22198 22204 22204 22208 22211 22216 22216 22222 22222 22225 22225 22227 22227 22231 22232 22234 22235 22238 22238 22240 22240 22243 22243 22254 22254 22256 22256 22258 22259 22265 22266 22269 22269 22271 22272 22275 22276 22280 22281 22283 22283 22285 22285 22287 22287 22290 22291 22294 22294 22296 22296 22300 22300 22303 22303 22310 22312 22317 22317 22320 22320 22327 22328 22331 22331 22336 22336 22338 22338 22343 22343 22346 22346 22350 22353 22369 22369 22372 22372 22374 22374 22377 22378 22399 22399 22402 22402 22408 22409 22411 22411 22419 22419 22432 22432 22434 22436 22442 22442 22448 22448 22451 22451 22464 22464 22467 22467 22470 22470 22475 22475 22478 22478 22482 22484 22486 22486 22492 22492 22495 22496 22499 22499 22516 22516 22519 22519 22521 22522 22524 22524 22528 22528 22530 22530 22533 22534 22538 22539 22549 22549 22553 22553 22557 22557 22561 22561 22564 22564 22570 22570 22575 22577 22580 22581 22586 22586 22589 22589 22592 22593 22602 22603 22609 22610 22612 22612 22615 22618 22622 22622 22626 22626 22633 22633 22635 22635 22640 22640 22642 22642 22645 22645 22649 22649 22654 22654 22659 22659 22661 22661 22675 22675 22679 22679 22684 22684 22687 22687 22696 22696 22699 22699 22702 22702 22707 22707 22712 22715 22718 22718 22721 22721 22725 22725 22727 22727 22730 22730 22732 22732 22737 22737 22739 22739 22741 22741 22743 22745 22748 22748 22750 22751 22756 22757 22763 22764 22766 22770 22775 22775 22777 22781 22786 22786 22793 22794 22799 22800 22805 22806 22808 22812 22818 22818 22821 22821 22823 22823 22825 22830 22833 22834 22839 22840 22846 22846 22852 22852 22855 22857 22862 22865 22868 22869 22871 22872 22874 22874 22880 22880 22882 22882 22885 22885 22887 22890 22892 22892 22894 22894 22899 22900 22904 22904 22909 22909 22913 22916 22922 22922 22925 22925 22931 22931 22934 22934 22937 22937 22939 22939 22941 22941 22947 22947 22949 22949 22952 22952 22956 22956 22962 22962 22969 22969 22971 22971 22974 22974 22982 22982 22985 22985 22987 22987 22992 22993 22995 22996 23001 23002 23004 23004 23013 23014 23016 23016 23018 23019 23030 23030 23035 23035 23039 23039 23041 23041 23043 23043 23049 23049 23057 23057 23064 23064 23066 23066 23068 23068 23071 23072 23077 23077 23081 23081 23087 23087 23093 23094 23100 23100 23104 23105 23110 23110 23113 23113 23130 23130 23138 23138 23142 23142 23146 23146 23148 23148 23167 23167 23186 23186 23194 23195 23228 23230 23233 23234 23241 23241 23243 23244 23248 23248 23254 23255 23265 23265 23267 23267 23270 23270 23273 23273 23290 23291 23305 23305 23307 23308 23318 23318 23330 23330 23338 23338 23340 23340 23344 23344 23346 23346 23350 23350 23358 23358 23360 23360 23363 23363 23365 23365 23376 23377 23380 23381 23383 23384 23386 23389 23391 23391 23395 23398 23401 23401 23403 23403 23408 23409 23411 23411 23413 23413 23416 23416 23418 23418 23424 23424 23427 23427 23429 23429 23431 23433 23435 23437 23439 23439 23445 23445 23447 23453 23455 23455 23458 23462 23470 23470 23472 23472 23475 23478 23480 23481 23487 23487 23490 23495 23497 23497 23500 23500 23504 23504 23506 23508 23515 23515 23517 23519 23521 23522 23524 23529 23531 23531 23534 23534 23536 23536 23539 23539 23541 23542 23544 23544 23546 23546 23550 23551 23553 23554 23556 23563 23565 23567 23569 23569 23571 23571 23574 23574 23578 23578 23584 23584 23586 23586 23588 23588 23592 23592 23597 23597 23601 23601 23608 23617 23621 23622 23624 23624 23626 23627 23629 23633 23635 23635 23637 23637 23646 23646 23648 23649 23652 23653 23660 23660 23662 23663 23665 23665 23670 23670 23673 23673 23692 23692 23696 23697 23700 23700 23713 23713 23720 23721 23723 23724 23729 23729 23731 23731 23734 23736 23739 23740 23742 23742 23749 23749 23751 23751 23769 23769 23776 23777 23784 23786 23789 23789 23791 23792 23798 23798 23802 23803 23805 23805 23815 23815 23819 23819 23822 23822 23825 23825 23828 23835 23839 23839 23842 23842 23849 23849 23883 23884 23886 23886 23888 23888 23890 23890 23900 23900 23913 23913 23916 23916 23919 23919 23923 23923 23926 23926 23938 23938 23940 23940 23943 23943 23947 23948 23952 23952 23965 23965 23970 23970 23980 23980 23982 23982 23991 23991 23994 23994 23996 23997 24009 24009 24012 24013 24018 24019 24022 24022 24027 24027 24029 24030 24033 24033 24035 24035 24037 24040 24043 24043 24046 24046 24049 24053 24055 24055 24059 24059 24061 24062 24066 24067 24070 24070 24075 24076 24081 24081 24086 24086 24089 24091 24093 24093 24101 24101 24107 24107 24109 24109 24111 24112 24115 24115 24118 24120 24125 24125 24128 24128 24131 24133 24135 24135 24140 24140 24142 24142 24148 24149 24151 24151 24159 24159 24161 24164 24178 24182 24184 24191 24193 24193 24195 24196 24199 24199 24202 24202 24207 24207 24213 24215 24218 24218 24220 24220 24224 24224 24230 24231 24235 24235 24237 24237 24245 24248 24257 24259 24264 24266 24271 24272 24275 24275 24278 24278 24282 24283 24285 24285 24287 24291 24296 24297 24300 24300 24304 24305 24307 24308 24310 24312 24314 24316 24318 24319 24321 24321 24323 24324 24329 24333 24335 24337 24339 24344 24347 24347 24351 24351 24357 24359 24361 24361 24365 24365 24367 24367 24369 24369 24373 24373 24375 24376 24380 24380 24382 24382 24385 24385 24392 24392 24394 24394 24396 24396 24398 24398 24401 24401 24403 24403 24406 24407 24409 24409 24412 24413 24417 24418 24422 24422 24425 24429 24432 24433 24435 24435 24439 24439 24441 24441 24444 24444 24447 24453 24455 24456 24458 24460 24464 24467 24471 24473 24478 24478 24480 24481 24488 24490 24493 24494 24499 24500 24505 24505 24508 24509 24515 24515 24517 24517 24524 24525 24534 24537 24540 24541 24544 24544 24548 24548 24555 24555 24560 24561 24565 24565 24568 24568 24571 24571 24573 24573 24575 24575 24590 24592 24594 24594 24597 24598 24601 24601 24603 24605 24608 24609 24613 24619 24623 24623 24625 24625 24634 24634 24641 24643 24646 24646 24650 24651 24653 24653 24656 24656 24658 24658 24661 24661 24665 24666 24671 24672 24674 24677 24680 24685 24687 24688 24693 24693 24695 24695 24705 24705 24707 24708 24713 24713 24715 24717 24722 24722 24724 24724 24726 24727 24730 24731 24735 24736 24739 24739 24742 24743 24745 24746 24754 24758 24760 24760 24764 24765 24773 24775 24785 24785 24787 24787 24792 24792 24794 24794 24796 24796 24799 24801 24803 24803 24807 24808 24816 24817 24819 24820 24822 24823 24825 24827 24832 24833 24835 24835 24838 24838 24840 24841 24845 24847 24853 24853 24858 24859 24863 24863 24865 24865 24871 24872 24876 24876 24884 24884 24892 24895 24898 24898 24900 24900 24903 24904 24906 24910 24915 24915 24917 24917 24920 24922 24925 24925 24927 24927 24930 24931 24933 24933 24935 24936 24939 24939 24942 24945 24947 24951 24958 24958 24962 24962 24967 24967 24970 24970 24974 24974 24976 24977 24980 24980 24982 24982 24985 24986 24996 24996 24999 24999 25001 25001 25003 25004 25006 25006 25010 25010 25014 25014 25018 25018 25022 25022 25027 25027 25030 25037 25040 25040 25059 25059 25062 25062 25074 25074 25076 25076 25078 25080 25082 25082 25084 25088 25096 25098 25100 25102 25104 25106 25108 25108 25110 25110 25114 25115 25117 25119 25121 25121 25126 25126 25130 25130 25134 25136 25138 25140 25144 25144 25147 25147 25151 25153 25159 25161 25163 25163 25165 25166 25171 25171 25173 25173 25176 25176 25179 25179 25182 25182 25184 25184 25187 25187 25192 25192 25198 25198 25201 25201 25206 25206 25209 25209 25212 25212 25214 25216 25218 25220 25225 25226 25233 25240 25243 25244 25246 25246 25259 25260 25265 25265 25269 25269 25273 25273 25275 25277 25282 25282 25285 25290 25292 25293 25295 25300 25303 25305 25307 25309 25312 25313 25324 25327 25329 25329 25331 25331 25333 25335 25342 25343 25345 25346 25351 25353 25356 25356 25361 25361 25369 25369 25375 25375 25383 25384 25387 25387 25391 25391 25402 25402 25405 25407 25417 25417 25420 25421 25423 25424 25429 25429 25431 25431 25436 25436 25447 25449 25451 25451 25454 25454 25458 25458 25462 25463 25466 25467 25472 25472 25475 25475 25480 25481 25484 25484 25486 25487 25490 25490 25494 25494 25496 25496 25499 25499 25503 25507 25509 25509 25511 25516 25522 25522 25524 25525 25531 25531 25534 25534 25536 25536 25539 25540 25542 25542 25545 25545 25551 25552 25554 25554 25558 25558 25562 25563 25569 25569 25571 25571 25577 25577 25582 25582 25588 25588 25590 25590 25594 25594 25606 25606 25613 25613 25615 25615 25619 25619 25622 25623 25628 25628 25638 25638 25640 25640 25644 25645 25652 25652 25654 25654 25658 25658 25662 25662 25666 25666 25678 25678 25688 25688 25703 25703 25705 25705 25711 25711 25718 25718 25720 25720 25722 25722 25731 25731 25736 25736 25746 25747 25749 25749 25754 25754 25758 25758 25764 25765 25769 25769 25771 25771 25773 25774 25776 25776 25778 25778 25785 25785 25787 25788 25793 25794 25797 25797 25799 25799 25805 25805 25810 25810 25812 25812 25816 25816 25818 25818 25824 25827 25830 25831 25836 25836 25839 25839 25841 25842 25844 25844 25846 25846 25850 25850 25853 25854 25856 25856 25861 25861 25880 25880 25884 25885 25891 25892 25898 25900 25903 25903 25908 25913 25915 25915 25918 25919 25925 25925 25928 25928 25933 25933 25935 25935 25937 25937 25941 25945 25949 25950 25954 25955 25958 25958 25964 25964 25968 25968 25970 25970 25972 25973 25975 25976 25986 25987 25991 25993 25996 25996 25998 25998 26000 26001 26007 26007 26009 26009 26011 26012 26015 26015 26017 26017 26020 26021 26023 26023 26027 26029 26031 26032 26039 26039 26041 26041 26044 26045 26049 26049 26051 26054 26059 26060 26063 26063 26066 26066 26071 26071 26073 26073 26075 26075 26080 26082 26085 26089 26092 26093 26097 26097 26106 26107 26114 26115 26118 26119 26122 26122 26124 26124 26126 26127 26131 26132 26140 26140 26143 26144 26149 26149 26151 26152 26157 26157 26159 26159 26164 26166 26172 26172 26175 26175 26177 26180 26185 26185 26187 26187 26191 26191 26194 26194 26205 26207 26210 26210 26212 26212 26214 26217 26222 26224 26228 26228 26230 26230 26234 26234 26241 26241 26243 26244 26247 26249 26254 26254 26257 26257 26262 26264 26269 26269 26274 26274 26278 26278 26283 26283 26286 26286 26292 26292 26296 26297 26300 26300 26302 26302 26305 26305 26308 26308 26311 26311 26313 26313 26326 26326 26329 26330 26332 26333 26336 26336 26342 26342 26345 26345 26352 26352 26354 26357 26359 26361 26364 26368 26371 26371 26376 26377 26379 26379 26381 26381 26383 26383 26388 26391 26395 26395 26397 26399 26406 26408 26410 26414 26417 26417 26420 26420 26422 26424 26426 26426 26429 26429 26431 26431 26433 26433 26438 26438 26441 26441 26446 26449 26451 26451 26454 26454 26457 26457 26460 26460 26462 26469 26474 26474 26477 26477 26479 26483 26485 26485 26487 26487 26492 26492 26494 26495 26501 26501 26503 26503 26505 26505 26507 26508 26512 26512 26517 26517 26519 26519 26522 26522 26524 26525 26528 26530 26534 26534 26537 26537 26543 26543 26547 26548 26550 26553 26561 26561 26564 26564 26566 26566 26570 26570 26574 26577 26579 26580 26584 26584 26586 26586 26589 26590 26594 26594 26596 26596 26599 26599 26601 26601 26604 26604 26606 26607 26609 26609 26611 26613 26619 26619 26622 26623 26626 26628 26643 26643 26646 26647 26654 26654 26657 26658 26665 26667 26674 26674 26676 26676 26680 26681 26684 26685 26688 26691 26694 26694 26696 26696 26701 26702 26704 26705 26707 26708 26713 26713 26716 26717 26719 26719 26723 26723 26727 26727 26740 26740 26742 26743 26750 26751 26753 26753 26755 26755 26757 26757 26765 26765 26767 26767 26771 26772 26775 26775 26779 26779 26781 26781 26783 26784 26786 26786 26790 26792 26797 26797 26799 26801 26803 26803 26805 26806 26809 26810 26812 26812 26820 26820 26822 26822 26825 26827 26829 26829 26834 26834 26836 26837 26839 26840 26842 26842 26847 26849 26851 26851 26855 26855 26862 26863 26866 26866 26873 26874 26880 26881 26884 26885 26888 26888 26891 26895 26898 26898 26905 26908 26913 26915 26917 26918 26920 26920 26922 26922 26928 26928 26932 26932 26934 26934 26937 26937 26941 26941 26943 26943 26954 26954 26963 26965 26969 26970 26972 26974 26976 26978 26986 26987 26989 26991 26995 26997 26999 27001 27004 27006 27009 27010 27018 27018 27022 27022 27025 27025 27028 27029 27035 27036 27040 27040 27047 27047 27054 27054 27057 27058 27060 27060 27067 27067 27070 27071 27073 27073 27075 27075 27079 27079 27082 27086 27088 27088 27091 27091 27096 27097 27101 27102 27111 27112 27115 27115 27117 27117 27122 27122 27129 27129 27131 27131 27133 27133 27135 27135 27138 27138 27141 27141 27146 27148 27154 27156 27159 27159 27161 27161 27163 27163 27166 27167 27169 27171 27177 27179 27182 27182 27189 27190 27192 27194 27197 27197 27204 27204 27207 27208 27211 27211 27224 27225 27231 27231 27233 27234 27238 27238 27250 27250 27256 27256 27263 27264 27268 27268 27277 27278 27280 27280 27287 27287 27292 27292 27296 27296 27298 27299 27306 27306 27308 27308 27310 27310 27315 27315 27320 27320 27323 27323 27329 27331 27345 27345 27347 27347 27354 27355 27358 27359 27368 27368 27370 27370 27386 27387 27396 27397 27402 27402 27410 27410 27414 27414 27421 27421 27423 27425 27427 27427 27431 27431 27442 27442 27447 27450 27453 27454 27459 27459 27463 27463 27465 27465 27468 27468 27470 27470 27472 27472 27475 27476 27481 27481 27483 27483 27487 27487 27489 27492 27494 27494 27497 27498 27503 27503 27507 27508 27512 27513 27515 27515 27519 27520 27523 27524 27526 27526 27529 27531 27533 27533 27541 27542 27544 27544 27550 27550 27556 27556 27562 27563 27567 27567 27569 27573 27575 27575 27578 27580 27583 27584 27589 27590 27595 27595 27597 27598 27602 27604 27608 27608 27611 27611 27615 27615 27627 27628 27631 27631 27635 27635 27656 27656 27663 27663 27665 27665 27667 27668 27671 27671 27675 27675 27683 27684 27700 27700 27703 27704 27710 27710 27712 27714 27726 27726 27728 27728 27733 27733 27735 27735 27738 27738 27741 27744 27746 27746 27752 27752 27754 27754 27760 27760 27762 27763 27770 27770 27773 27774 27777 27779 27784 27784 27788 27789 27792 27792 27794 27795 27798 27798 27801 27803 27809 27810 27819 27819 27822 27822 27825 27825 27827 27827 27832 27839 27841 27841 27844 27845 27849 27850 27852 27852 27859 27859 27861 27861 27863 27863 27865 27865 27867 27867 27869 27869 27873 27875 27877 27877 27880 27880 27882 27882 27887 27889 27891 27891 27915 27916 27922 27922 27927 27927 27929 27929 27931 27931 27934 27935 27941 27941 27945 27947 27954 27955 27957 27958 27960 27960 27963 27963 27965 27966 27969 27969 27972 27973 27993 27994 27996 27996 28003 28004 28006 28006 28009 28010 28012 28012 28014 28014 28020 28020 28023 28025 28037 28037 28040 28040 28044 28044 28046 28046 28051 28051 28053 28053 28057 28057 28059 28060 28079 28079 28082 28082 28085 28085 28088 28088 28092 28092 28096 28096 28101 28103 28107 28108 28113 28114 28117 28117 28120 28121 28126 28126 28129 28129 28132 28132 28134 28134 28136 28136 28138 28140 28142 28142 28145 28145 28147 28147 28149 28149 28151 28151 28153 28155 28165 28165 28167 28171 28179 28179 28181 28181 28185 28187 28189 28189 28191 28193 28195 28198 28201 28201 28203 28207 28216 28216 28218 28218 28222 28222 28227 28227 28234 28234 28237 28238 28246 28246 28248 28248 28251 28251 28255 28255 28263 28263 28267 28267 28270 28271 28274 28274 28278 28278 28286 28288 28290 28290 28300 28300 28303 28304 28310 28310 28312 28312 28316 28317 28319 28319 28322 28322 28325 28325 28330 28330 28335 28335 28338 28338 28342 28343 28346 28346 28349 28349 28354 28354 28356 28357 28361 28361 28363 28364 28369 28369 28371 28373 28381 28382 28396 28396 28399 28399 28402 28402 28404 28404 28407 28408 28414 28415 28417 28418 28422 28422 28425 28425 28431 28431 28433 28433 28435 28437 28448 28448 28450 28451 28459 28460 28465 28466 28472 28472 28478 28479 28481 28481 28485 28485 28500 28500 28504 28504 28507 28508 28511 28511 28516 28516 28518 28518 28525 28528 28532 28532 28536 28536 28538 28538 28540 28540 28544 28546 28548 28548 28550 28550 28558 28558 28561 28561 28567 28567 28577 28577 28579 28580 28586 28586 28593 28593 28595 28595 28601 28601 28608 28611 28614 28614 28628 28629 28632 28632 28635 28635 28639 28641 28644 28644 28651 28652 28654 28655 28657 28657 28659 28659 28662 28662 28666 28666 28670 28670 28673 28673 28681 28681 28683 28683 28687 28687 28689 28689 28693 28693 28696 28696 28698 28699 28701 28703 28710 28711 28716 28716 28720 28720 28722 28722 28734 28734 28748 28748 28753 28753 28760 28760 28771 28771 28779 28779 28783 28784 28792 28792 28796 28797 28809 28810 28814 28814 28818 28818 28825 28825 28844 28847 28851 28851 28856 28858 28872 28872 28875 28875 28879 28879 28889 28889 28893 28893 28895 28895 28913 28913 28921 28921 28925 28925 28937 28937 28948 28948 28953 28954 28956 28956 28961 28961 28966 28966 28982 28982 28988 28988 29001 29001 29004 29004 29006 29006 29013 29014 29017 29017 29026 29026 29028 29031 29033 29033 29036 29036 29038 29038 29053 29053 29060 29060 29064 29064 29066 29066 29071 29071 29076 29077 29081 29081 29087 29087 29096 29096 29100 29100 29105 29105 29113 29113 29118 29118 29123 29123 29128 29129 29134 29134 29136 29136 29138 29138 29140 29141 29143 29143 29151 29152 29157 29159 29164 29166 29173 29173 29177 29177 29179 29180 29183 29183 29190 29190 29197 29197 29200 29200 29211 29211 29224 29224 29226 29226 29228 29229 29232 29232 29234 29234 29237 29238 29242 29248 29254 29256 29259 29260 29266 29266 29272 29273 29275 29275 29277 29277 29279 29279 29281 29282 29287 29287 29289 29289 29298 29298 29300 29300 29305 29305 29309 29310 29312 29314 29319 29319 29330 29330 29334 29334 29344 29344 29346 29346 29351 29351 29356 29356 29359 29359 29362 29362 29366 29366 29369 29369 29378 29380 29382 29382 29390 29390 29392 29392 29394 29394 29399 29399 29401 29401 29403 29403 29408 29410 29417 29417 29420 29421 29431 29433 29436 29437 29450 29450 29462 29463 29467 29469 29471 29471 29477 29477 29481 29483 29486 29487 29492 29492 29494 29495 29502 29503 29508 29509 29518 29519 29527 29527 29539 29539 29544 29544 29546 29546 29552 29552 29554 29554 29557 29557 29560 29560 29562 29563 29572 29572 29575 29575 29577 29577 29579 29579 29590 29590 29609 29609 29618 29619 29627 29627 29632 29632 29634 29634 29640 29640 29642 29642 29645 29646 29662 29662 29664 29664 29669 29669 29674 29674 29677 29678 29681 29681 29688 29688 29694 29694 29699 29699 29701 29702 29705 29705 29730 29730 29733 29733 29746 29750 29754 29754 29759 29759 29761 29761 29781 29781 29785 29788 29790 29792 29795 29796 29801 29802 29807 29808 29811 29811 29814 29814 29822 29822 29827 29827 29835 29835 29854 29854 29858 29858 29863 29863 29872 29872 29885 29885 29898 29898 29903 29903 29908 29908 29916 29916 29920 29920 29922 29923 29926 29927 29929 29929 29934 29934 29936 29938 29942 29944 29955 29957 29964 29966 29969 29969 29971 29971 29973 29973 29976 29976 29978 29978 29980 29980 29982 29983 29987 29987 29989 29990 29992 29992 29995 29996 30000 30003 30007 30008 30010 30012 30020 30020 30022 30022 30025 30029 30031 30031 30033 30033 30036 30036 30041 30045 30048 30048 30050 30050 30052 30055 30057 30059 30061 30061 30064 30064 30067 30068 30070 30072 30079 30079 30082 30082 30086 30087 30089 30091 30094 30095 30097 30097 30100 30100 30106 30106 30109 30109 30115 30115 30117 30117 30123 30123 30129 30131 30133 30133 30136 30137 30140 30142 30146 30147 30149 30149 30151 30151 30154 30154 30157 30157 30162 30162 30164 30165 30168 30169 30171 30171 30174 30174 30178 30179 30185 30185 30192 30192 30194 30196 30202 30202 30204 30204 30206 30207 30209 30209 30217 30217 30219 30219 30221 30221 30239 30242 30244 30244 30247 30247 30256 30256 30260 30260 30267 30267 30274 30274 30278 30280 30284 30284 30290 30290 30294 30294 30296 30296 30300 30300 30305 30306 30311 30314 30316 30316 30320 30320 30322 30322 30326 30326 30328 30328 30330 30334 30336 30336 30339 30340 30342 30344 30347 30347 30350 30350 30352 30352 30355 30355 30358 30358 30361 30362 30382 30382 30384 30384 30388 30388 30391 30394 30399 30399 30402 30403 30406 30406 30408 30408 30410 30410 30413 30413 30418 30418 30422 30423 30427 30428 30430 30431 30433 30433 30435 30437 30439 30439 30442 30442 30446 30446 30450 30450 30452 30452 30456 30456 30459 30459 30462 30462 30465 30465 30468 30468 30471 30473 30475 30476 30491 30491 30494 30496 30500 30502 30505 30505 30519 30520 30522 30522 30524 30524 30528 30528 30535 30535 30554 30555 30561 30561 30563 30563 30565 30566 30568 30568 30571 30571 30585 30585 30590 30591 30603 30603 30606 30606 30609 30609 30622 30622 30624 30624 30629 30629 30636 30637 30640 30640 30643 30643 30646 30646 30649 30649 30651 30653 30655 30655 30663 30663 30669 30669 30679 30679 30682 30684 30690 30691 30693 30693 30695 30695 30697 30697 30701 30703 30707 30707 30716 30716 30722 30722 30732 30732 30738 30738 30740 30741 30752 30752 30757 30759 30770 30770 30772 30772 30778 30778 30783 30783 30789 30789 30813 30813 30827 30828 30831 30831 30834 30834 30836 30836 30844 30844 30849 30849 30854 30855 30860 30862 30865 30865 30867 30867 30869 30869 30871 30871 30874 30874 30883 30883 30887 30887 30889 30890 30895 30895 30901 30901 30906 30906 30908 30908 30910 30910 30913 30913 30917 30918 30922 30923 30928 30929 30932 30932 30938 30938 30951 30952 30956 30956 30959 30959 30964 30964 30973 30973 30977 30977 30983 30983 30990 30990 30993 30994 31001 31001 31014 31014 31018 31020 31034 31034 31036 31036 31038 31038 31040 31041 31047 31049 31056 31056 31059 31059 31061 31063 31066 31066 31069 31072 31074 31074 31077 31077 31080 31080 31085 31085 31095 31095 31098 31098 31103 31105 31108 31109 31114 31114 31117 31119 31133 31133 31142 31143 31146 31146 31150 31150 31152 31152 31155 31155 31161 31162 31165 31169 31177 31177 31179 31179 31185 31186 31189 31189 31192 31192 31199 31199 31201 31201 31203 31204 31206 31207 31209 31209 31212 31212 31216 31216 31227 31227 31232 31232 31240 31240 31243 31243 31245 31246 31252 31252 31255 31258 31260 31260 31263 31264 31278 31278 31281 31282 31287 31287 31291 31296 31298 31299 31302 31302 31305 31305 31309 31312 31319 31319 31329 31331 31337 31337 31339 31339 31344 31344 31348 31348 31350 31350 31353 31354 31357 31357 31359 31359 31361 31361 31363 31364 31368 31368 31378 31379 31381 31384 31391 31391 31401 31402 31406 31408 31414 31414 31418 31418 31423 31423 31427 31429 31431 31432 31434 31435 31437 31437 31439 31439 31442 31443 31445 31445 31449 31450 31452 31453 31455 31459 31461 31462 31466 31466 31469 31469 31471 31472 31478 31478 31480 31482 31487 31487 31490 31490 31492 31492 31494 31494 31496 31496 31498 31499 31503 31503 31505 31505 31512 31513 31515 31515 31518 31518 31520 31520 31525 31526 31528 31528 31532 31532 31539 31539 31541 31542 31545 31545 31557 31558 31560 31561 31563 31565 31567 31570 31572 31572 31574 31574 31581 31581 31589 31589 31591 31591 31596 31596 31598 31598 31600 31601 31604 31605 31610 31610 31622 31623 31627 31627 31629 31629 31631 31631 31634 31634 31636 31637 31639 31642 31644 31645 31647 31647 31649 31649 31658 31658 31661 31661 31665 31665 31668 31668 31672 31672 31680 31681 31684 31684 31686 31687 31689 31689 31691 31692 31695 31695 31709 31709 31712 31712 31716 31718 31721 31721 31725 31725 31731 31731 31734 31735 31744 31744 31751 31751 31757 31757 31761 31764 31767 31767 31775 31775 31777 31777 31779 31779 31783 31783 31786 31787 31799 31800 31805 31808 31811 31811 31820 31821 31823 31824 31828 31828 31830 31830 31832 31832 31839 31840 31844 31845 31852 31852 31859 31859 31861 31861 31870 31870 31873 31875 31881 31881 31883 31883 31885 31885 31888 31888 31890 31890 31893 31893 31895 31896 31899 31899 31903 31903 31905 31906 31908 31909 31911 31912 31915 31915 31917 31918 31921 31923 31929 31929 31933 31934 31936 31936 31938 31938 31941 31941 31946 31946 31950 31950 31954 31954 31958 31958 31960 31960 31964 31964 31966 31968 31970 31970 31975 31975 31983 31983 31986 31986 31988 31988 31990 31990 31992 31992 31994 31995 31998 31998 32000 32000 32002 32002 32004 32006 32010 32011 32013 32013 32016 32016 32020 32021 32023 32028 32032 32034 32043 32044 32046 32048 32050 32051 32053 32053 32057 32058 32063 32063 32066 32070 32075 32076 32078 32080 32086 32086 32091 32091 32094 32094 32097 32099 32102 32102 32104 32104 32110 32110 32113 32115 32117 32118 32121 32121 32125 32125 32137 32137 32143 32143 32147 32147 32153 32156 32159 32159 32162 32163 32171 32178 32180 32181 32184 32184 32186 32187 32189 32191 32199 32199 32202 32203 32207 32207 32209 32210 32213 32213 32216 32216 32218 32218 32220 32222 32224 32225 32228 32228 32232 32233 32236 32236 32239 32239 32242 32242 32244 32244 32251 32251 32257 32257 32260 32261 32265 32267 32274 32274 32283 32283 32286 32287 32289 32291 32294 32294 32299 32299 32302 32302 32305 32306 32309 32309 32311 32311 32313 32315 32317 32318 32321 32321 32323 32323 32326 32326 32330 32331 32333 32333 32340 32342 32345 32346 32349 32350 32358 32359 32361 32362 32365 32365 32368 32368 32377 32377 32379 32381 32383 32383 32386 32387 32392 32393 32396 32396 32398 32400 32402 32404 32406 32406 32411 32412 32566 32566 32568 32568 32570 32570 32581 32581 32588 32590 32592 32593 32596 32597 32600 32600 32607 32608 32615 32619 32622 32622 32624 32624 32626 32626 32629 32629 32631 32633 32642 32643 32645 32648 32650 32650 32652 32652 32654 32654 32660 32660 32666 32666 32669 32670 32675 32676 32680 32681 32686 32687 32690 32690 32694 32694 32696 32697 32701 32701 32705 32705 32709 32710 32714 32714 32716 32716 32722 32722 32724 32725 32736 32737 32742 32742 32745 32745 32747 32747 32752 32752 32755 32755 32761 32761 32763 32764 32768 32769 32771 32774 32779 32780 32784 32784 32786 32786 32789 32789 32791 32793 32796 32796 32801 32801 32808 32808 32819 32819 32822 32822 32827 32827 32829 32829 32831 32831 32838 32838 32842 32842 32850 32850 32854 32854 32856 32856 32858 32858 32862 32863 32865 32866 32872 32872 32879 32880 32882 32884 32886 32887 32889 32889 32893 32895 32900 32903 32905 32905 32907 32908 32915 32915 32918 32918 32920 32920 32922 32923 32925 32925 32929 32930 32933 32933 32937 32938 32940 32941 32943 32943 32945 32946 32948 32948 32954 32954 32963 32964 32966 32966 32972 32972 32974 32974 32982 32982 32985 32987 32989 32990 32993 32993 32996 32997 33007 33007 33009 33009 33012 33012 33016 33016 33020 33021 33026 33026 33029 33034 33050 33051 33059 33059 33065 33065 33071 33071 33073 33073 33075 33075 33081 33081 33086 33086 33094 33094 33099 33099 33102 33102 33104 33105 33107 33109 33119 33119 33125 33126 33131 33131 33134 33134 33136 33137 33140 33140 33144 33146 33151 33152 33154 33155 33160 33160 33162 33162 33167 33167 33171 33171 33173 33173 33178 33178 33180 33181 33184 33184 33187 33188 33192 33193 33200 33200 33203 33203 33205 33205 33208 33208 33210 33210 33213 33216 33218 33218 33222 33222 33224 33225 33229 33229 33233 33233 33235 33235 33240 33242 33247 33248 33251 33251 33253 33253 33255 33256 33258 33258 33261 33261 33267 33268 33274 33276 33278 33278 33281 33282 33285 33285 33287 33290 33292 33294 33296 33296 33298 33298 33302 33304 33307 33308 33310 33311 33321 33324 33326 33326 33331 33331 33333 33337 33344 33344 33351 33351 33368 33370 33373 33373 33375 33375 33378 33378 33380 33380 33382 33382 33384 33384 33386 33387 33390 33391 33393 33394 33398 33400 33406 33406 33419 33419 33421 33421 33426 33426 33433 33433 33437 33437 33439 33439 33445 33446 33451 33453 33455 33455 33457 33457 33459 33459 33464 33465 33467 33467 33469 33469 33477 33477 33489 33492 33495 33495 33497 33497 33499 33500 33502 33503 33505 33505 33507 33507 33509 33511 33515 33515 33521 33521 33523 33524 33529 33531 33538 33542 33545 33545 33550 33550 33558 33560 33564 33564 33571 33571 33576 33576 33579 33579 33583 33583 33585 33586 33588 33590 33592 33593 33600 33600 33605 33605 33609 33610 33615 33616 33618 33618 33624 33624 33651 33651 33653 33653 33655 33655 33659 33660 33669 33669 33671 33671 33673 33674 33678 33678 33683 33683 33686 33686 33690 33690 33694 33696 33698 33698 33704 33704 33706 33707 33713 33713 33717 33717 33725 33725 33729 33729 33733 33733 33738 33738 33740 33740 33742 33742 33747 33747 33750 33750 33752 33752 33756 33756 33759 33760 33769 33769 33771 33771 33775 33778 33780 33780 33783 33783 33787 33787 33789 33789 33795 33796 33799 33799 33803 33806 33811 33811 33824 33824 33826 33826 33833 33834 33836 33836 33841 33841 33845 33845 33848 33848 33852 33853 33862 33862 33865 33865 33870 33870 33879 33879 33883 33883 33889 33891 33894 33894 33897 33897 33899 33903 33905 33905 33909 33909 33911 33911 33913 33914 33922 33922 33924 33924 33931 33931 33936 33936 33940 33940 33945 33945 33948 33948 33951 33951 33953 33953 33965 33965 33970 33970 33976 33977 33979 33980 33983 33983 33985 33985 33988 33988 33990 33990 33993 33995 33997 33997 34000 34001 34006 34006 34009 34010 34028 34028 34030 34030 34036 34036 34044 34044 34047 34048 34054 34054 34065 34065 34067 34069 34071 34072 34074 34074 34079 34079 34081 34081 34086 34086 34092 34093 34101 34101 34109 34109 34112 34113 34115 34115 34120 34123 34126 34126 34133 34133 34135 34136 34138 34138 34147 34147 34152 34154 34157 34157 34167 34167 34174 34174 34176 34176 34180 34180 34183 34184 34186 34186 34192 34193 34196 34196 34199 34199 34201 34201 34203 34204 34212 34212 34214 34214 34216 34220 34222 34223 34233 34234 34241 34241 34249 34249 34253 34253 34255 34256 34261 34261 34268 34269 34276 34277 34281 34282 34295 34295 34297 34299 34302 34302 34306 34306 34310 34311 34314 34315 34323 34323 34326 34327 34330 34330 34338 34338 34349 34349 34351 34352 34367 34367 34381 34382 34384 34384 34388 34389 34394 34394 34396 34396 34398 34399 34407 34407 34411 34411 34417 34417 34425 34425 34427 34427 34442 34444 34451 34451 34453 34453 34467 34468 34473 34475 34479 34480 34486 34486 34500 34500 34502 34503 34505 34505 34507 34507 34509 34510 34516 34516 34521 34521 34523 34523 34526 34527 34532 34532 34537 34537 34540 34543 34552 34553 34555 34555 34558 34558 34560 34560 34562 34563 34566 34566 34568 34570 34573 34573 34577 34578 34584 34584 34586 34586 34588 34588 34597 34597 34601 34601 34612 34612 34615 34615 34619 34619 34623 34623 34633 34633 34635 34636 34638 34638 34643 34643 34645 34645 34647 34647 34649 34649 34655 34656 34659 34659 34662 34662 34664 34664 34666 34666 34670 34670 34676 34676 34678 34678 34680 34680 34687 34687 34690 34690 34701 34701 34719 34719 34722 34722 34731 34731 34735 34735 34739 34739 34746 34747 34749 34749 34752 34752 34756 34756 34758 34759 34763 34763 34768 34768 34770 34770 34784 34784 34799 34799 34802 34802 34806 34807 34809 34809 34811 34811 34814 34814 34821 34821 34829 34831 34833 34833 34837 34838 34849 34851 34855 34855 34865 34865 34870 34870 34873 34873 34875 34875 34880 34880 34882 34882 34884 34884 34886 34886 34892 34893 34898 34899 34903 34903 34905 34905 34907 34907 34909 34910 34913 34915 34920 34920 34923 34923 34928 34928 34930 34930 34933 34933 34935 34935 34941 34943 34945 34946 34952 34952 34955 34955 34957 34957 34962 34962 34966 34967 34969 34969 34974 34974 34978 34978 34980 34980 34987 34987 34990 34990 34992 34993 34996 34997 34999 34999 35007 35007 35009 35013 35023 35023 35028 35029 35032 35033 35036 35037 35039 35039 35041 35041 35048 35048 35058 35060 35064 35065 35068 35070 35074 35074 35076 35076 35079 35079 35082 35082 35084 35084 35088 35088 35090 35091 35101 35102 35109 35109 35114 35115 35126 35126 35128 35128 35131 35131 35137 35137 35139 35140 35148 35149 35158 35158 35166 35168 35172 35172 35174 35174 35178 35178 35181 35181 35183 35183 35186 35186 35188 35188 35191 35191 35198 35199 35201 35201 35203 35203 35206 35208 35210 35211 35215 35215 35219 35219 35222 35224 35226 35226 35233 35233 35238 35239 35241 35242 35244 35244 35247 35247 35250 35251 35258 35258 35261 35261 35263 35264 35282 35282 35290 35290 35292 35293 35299 35299 35302 35303 35316 35316 35320 35320 35328 35328 35330 35331 35336 35336 35338 35338 35340 35340 35342 35342 35344 35344 35347 35347 35350 35352 35355 35355 35357 35357 35359 35359 35363 35363 35365 35365 35370 35370 35373 35373 35377 35377 35379 35380 35382 35382 35386 35388 35393 35393 35398 35398 35400 35400 35408 35410 35412 35413 35419 35419 35422 35422 35424 35424 35426 35427 35430 35430 35433 35433 35435 35438 35440 35443 35452 35452 35458 35458 35460 35461 35463 35463 35465 35465 35468 35469 35473 35473 35475 35475 35477 35477 35480 35480 35482 35482 35486 35486 35488 35489 35491 35494 35496 35496 35500 35501 35504 35504 35506 35506 35513 35513 35516 35516 35519 35519 35522 35522 35524 35524 35527 35527 35531 35533 35535 35535 35538 35538 35542 35542 35546 35548 35550 35550 35552 35554 35556 35556 35558 35559 35563 35563 35565 35566 35569 35569 35571 35571 35575 35576 35578 35578 35582 35582 35584 35586 35588 35588 35591 35591 35596 35596 35598 35598 35600 35600 35604 35604 35606 35607 35609 35611 35613 35613 35616 35617 35622 35622 35624 35624 35627 35628 35635 35635 35641 35641 35646 35646 35649 35649 35657 35657 35660 35660 35662 35663 35670 35670 35672 35672 35674 35676 35679 35679 35686 35686 35691 35692 35695 35698 35700 35700 35703 35703 35709 35709 35712 35712 35715 35715 35722 35722 35724 35724 35726 35726 35728 35728 35730 35731 35734 35734 35737 35738 35895 35895 35898 35898 35903 35903 35905 35905 35910 35910 35912 35912 35914 35914 35916 35916 35918 35918 35920 35920 35925 35925 35930 35930 35937 35938 35946 35948 35960 35962 35964 35964 35970 35970 35973 35973 35977 35978 35980 35982 35988 35988 35992 35992 35997 35998 36000 36002 36007 36016 36018 36020 36022 36024 36027 36029 36031 36036 36039 36040 36042 36042 36045 36046 36049 36049 36051 36051 36058 36060 36062 36062 36064 36064 36066 36068 36070 36070 36074 36074 36077 36077 36090 36093 36100 36101 36103 36104 36106 36107 36109 36109 36111 36112 36115 36116 36118 36118 36196 36196 36198 36199 36203 36203 36205 36205 36208 36209 36211 36212 36215 36215 36225 36225 36229 36229 36234 36234 36249 36249 36259 36259 36264 36264 36275 36275 36282 36282 36286 36286 36290 36290 36299 36300 36303 36303 36310 36310 36314 36315 36317 36317 36319 36319 36321 36321 36323 36323 36328 36328 36330 36331 36335 36335 36339 36339 36341 36341 36348 36348 36351 36351 36360 36362 36367 36368 36381 36383 36394 36394 36400 36400 36404 36405 36418 36418 36420 36420 36423 36426 36428 36428 36432 36432 36437 36437 36441 36441 36447 36448 36451 36452 36466 36466 36468 36468 36470 36470 36476 36476 36481 36481 36484 36485 36487 36487 36490 36491 36493 36493 36497 36497 36499 36500 36505 36505 36513 36513 36522 36524 36527 36529 36542 36542 36549 36550 36552 36552 36554 36557 36562 36562 36571 36571 36575 36575 36578 36579 36587 36587 36600 36600 36603 36606 36611 36611 36613 36613 36617 36618 36620 36620 36626 36629 36633 36633 36635 36637 36639 36639 36646 36646 36649 36650 36655 36655 36659 36659 36664 36665 36667 36667 36670 36671 36674 36674 36676 36678 36681 36681 36684 36686 36695 36695 36700 36700 36703 36703 36705 36708 36763 36764 36766 36767 36771 36771 36775 36776 36781 36786 36791 36791 36794 36796 36799 36799 36802 36802 36804 36805 36814 36814 36817 36817 36820 36820 36826 36826 36834 36834 36837 36838 36841 36843 36845 36845 36847 36848 36852 36852 36855 36858 36861 36861 36864 36865 36867 36867 36869 36870 36875 36875 36877 36881 36883 36887 36889 36890 36893 36899 36903 36903 36910 36910 36913 36914 36917 36918 36920 36921 36924 36924 36926 36926 36929 36930 36933 36933 36935 36935 36937 36939 36941 36950 36952 36953 36956 36956 36958 36958 36960 36961 36963 36963 36965 36965 36968 36969 36973 36975 36978 36978 36981 36984 36986 36986 36988 36989 36991 36996 36999 36999 37001 37002 37007 37007 37009 37009 37027 37027 37030 37030 37032 37032 37034 37034 37039 37039 37041 37041 37045 37045 37048 37048 37057 37057 37066 37066 37070 37070 37083 37083 37089 37090 37092 37092 37096 37096 37101 37101 37109 37109 37111 37111 37117 37117 37122 37122 37138 37138 37145 37145 37165 37165 37168 37168 37170 37170 37193 37198 37202 37202 37204 37204 37206 37206 37208 37208 37218 37219 37221 37221 37225 37226 37228 37228 37234 37235 37237 37237 37239 37240 37250 37250 37255 37255 37257 37257 37259 37259 37261 37261 37264 37264 37266 37266 37271 37271 37276 37276 37282 37282 37284 37284 37290 37291 37295 37295 37300 37301 37304 37304 37306 37306 37312 37313 37318 37321 37323 37329 37334 37334 37336 37336 37339 37341 37343 37343 37345 37345 37347 37347 37350 37351 37365 37366 37372 37372 37375 37375 37389 37390 37393 37393 37396 37397 37406 37406 37417 37417 37420 37420 37428 37428 37431 37431 37439 37439 37444 37445 37448 37449 37451 37451 37456 37456 37463 37463 37466 37467 37470 37470 37474 37474 37476 37476 37478 37478 37489 37489 37502 37502 37504 37504 37507 37507 37509 37509 37521 37521 37523 37523 37525 37526 37528 37528 37530 37532 37549 37549 37559 37559 37561 37561 37583 37583 37586 37586 37604 37604 37609 37610 37613 37613 37618 37619 37624 37624 37626 37626 37628 37628 37638 37638 37647 37648 37656 37658 37664 37664 37666 37667 37670 37670 37672 37672 37675 37676 37678 37679 37682 37682 37685 37685 37690 37691 37700 37700 37707 37707 37709 37709 37716 37716 37718 37718 37723 37724 37728 37728 37740 37740 37742 37742 37749 37749 37756 37756 37758 37758 37772 37772 37780 37780 37782 37783 37786 37786 37799 37799 37804 37806 37808 37808 37817 37817 37827 37827 37832 37832 37840 37841 37846 37848 37853 37853 37857 37857 37860 37861 37864 37864 37891 37891 37895 37895 37904 37904 37907 37908 37912 37914 37921 37921 37931 37931 37941 37942 37944 37944 37946 37946 37953 37953 37956 37956 37969 37971 37978 37979 37982 37982 37984 37984 37986 37986 37994 37994 38000 38000 38005 38005 38007 38007 38012 38015 38017 38017 38263 38263 38272 38272 38274 38275 38279 38279 38281 38283 38287 38287 38289 38289 38291 38292 38294 38294 38296 38297 38304 38304 38306 38309 38311 38312 38317 38317 38322 38322 38329 38329 38331 38332 38334 38334 38339 38339 38343 38343 38346 38346 38348 38349 38356 38358 38360 38360 38364 38364 38369 38370 38373 38373 38428 38428 38433 38433 38440 38440 38442 38442 38446 38447 38450 38450 38459 38459 38463 38464 38466 38466 38468 38468 38475 38477 38479 38480 38491 38495 38498 38502 38506 38506 38508 38508 38512 38512 38514 38515 38517 38520 38522 38522 38525 38525 38533 38534 38536 38536 38538 38539 38541 38543 38548 38549 38551 38553 38555 38556 38560 38560 38563 38563 38567 38568 38570 38570 38576 38578 38580 38580 38582 38585 38587 38588 38592 38593 38596 38599 38601 38601 38603 38606 38609 38609 38613 38614 38617 38617 38619 38620 38626 38627 38632 38632 38634 38635 38640 38640 38642 38642 38646 38647 38649 38649 38651 38651 38656 38656 38660 38660 38662 38664 38666 38666 38669 38671 38673 38673 38675 38675 38678 38678 38681 38681 38684 38684 38686 38686 38692 38692 38695 38695 38698 38698 38704 38704 38706 38706 38712 38713 38717 38718 38722 38722 38724 38724 38726 38726 38728 38729 38738 38738 38742 38742 38745 38745 38748 38748 38750 38750 38752 38754 38756 38756 38758 38758 38760 38761 38763 38763 38765 38765 38769 38769 38772 38772 38777 38778 38780 38780 38785 38785 38788 38790 38795 38795 38797 38797 38799 38800 38808 38808 38812 38812 38816 38816 38819 38819 38822 38822 38824 38824 38827 38827 38829 38829 38835 38836 38851 38851 38854 38854 38856 38856 38859 38859 38867 38867 38876 38876 38893 38894 38898 38899 38901 38902 38907 38907 38911 38911 38913 38915 38917 38918 38920 38920 38924 38924 38927 38931 38935 38936 38938 38938 38945 38945 38948 38948 38956 38957 38964 38964 38967 38968 38971 38973 38982 38982 38987 38991 38996 38997 39000 39000 39003 39003 39006 39006 39015 39015 39019 39019 39023 39025 39027 39028 39080 39080 39082 39082 39087 39087 39089 39089 39094 39094 39107 39108 39110 39110 39131 39132 39135 39135 39138 39138 39145 39145 39147 39147 39149 39151 39154 39154 39156 39156 39164 39166 39171 39171 39173 39173 39177 39178 39180 39180 39184 39184 39186 39188 39192 39192 39197 39198 39200 39201 39204 39204 39208 39208 39212 39212 39214 39214 39229 39230 39234 39234 39237 39237 39241 39241 39243 39244 39248 39250 39253 39253 39255 39255 39318 39321 39333 39333 39336 39336 39340 39342 39347 39348 39356 39356 39361 39361 39364 39366 39368 39368 39376 39378 39381 39381 39384 39384 39387 39387 39389 39389 39391 39391 39394 39394 39405 39406 39409 39410 39416 39416 39419 39419 39423 39423 39425 39425 39429 39429 39438 39439 39442 39443 39449 39449 39464 39464 39467 39467 39472 39472 39479 39479 39486 39486 39488 39488 39490 39491 39493 39493 39501 39501 39509 39509 39511 39511 39514 39515 39519 39519 39522 39522 39524 39525 39529 39531 39592 39592 39597 39597 39600 39600 39608 39608 39612 39612 39616 39616 39620 39620 39631 39631 39633 39633 39635 39636 39640 39640 39646 39647 39650 39651 39654 39654 39658 39659 39661 39663 39665 39665 39668 39668 39671 39671 39675 39675 39686 39686 39704 39704 39706 39706 39711 39711 39714 39715 39717 39717 39719 39722 39726 39727 39729 39730 39739 39740 39745 39749 39757 39759 39761 39761 39764 39764 39768 39768 39770 39770 39791 39791 39796 39796 39811 39811 39822 39822 39825 39827 39830 39831 39839 39840 39848 39848 39850 39851 39853 39854 39860 39860 39865 39865 39872 39872 39878 39878 39881 39882 39887 39887 39889 39890 39892 39892 39894 39894 39899 39899 39905 39908 39912 39912 39920 39922 39925 39925 39940 39940 39942 39942 39944 39946 39948 39949 39952 39952 39954 39957 39963 39963 39969 39969 39972 39973 39981 39984 39986 39986 39993 39995 39998 39998 40006 40008 40018 40018 40023 40023 40026 40026 40032 40032 40039 40039 40054 40054 40056 40056 40165 40165 40167 40167 40169 40169 40171 40172 40176 40176 40179 40180 40182 40182 40195 40195 40198 40201 40206 40206 40210 40210 40213 40213 40219 40219 40223 40223 40227 40227 40230 40230 40232 40232 40234 40236 40251 40251 40254 40255 40257 40257 40260 40260 40262 40262 40264 40264 40272 40273 40281 40281 40284 40286 40288 40289 40292 40292 40300 40300 40303 40303 40306 40306 40314 40314 40327 40327 40329 40329 40335 40335 40346 40346 40356 40356 40361 40361 40363 40363 40367 40367 40370 40370 40372 40372 40376 40376 40378 40379 40385 40386 40388 40388 40390 40390 40399 40399 40403 40403 40409 40409 40422 40422 40429 40429 40431 40431 40434 40434 40440 40442 40445 40445 40474 40475 40478 40478 40565 40565 40568 40569 40573 40573 40575 40575 40577 40577 40584 40584 40587 40588 40593 40595 40597 40597 40599 40599 40605 40605 40607 40607 40613 40614 40617 40618 40621 40621 40632 40636 40638 40639 40644 40644 40652 40656 40658 40658 40660 40660 40664 40665 40667 40670 40672 40672 40677 40677 40680 40680 40687 40687 40692 40692 40694 40695 40697 40697 40699 40701 40711 40712 40718 40718 40723 40723 40725 40725 40736 40737 40748 40748 40763 40763 40766 40766 40778 40779 40782 40783 40786 40786 40788 40788 40799 40803 40806 40807 40810 40810 40812 40812 40818 40818 40822 40823 40845 40845 40853 40853 40860 40861 40864 40864 65281 65281 65283 65286 65288 65292 65294 65373 65507 65507 65509 65509)) (make-character-set :mib-enum 2009 :name "IBM850" :aliases '("csPC850Multilingual" "850" "cp850") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges #(0 127 160 255 305 305 402 402 8215 8215 9472 9472 9474 9474 9484 9484 9488 9488 9492 9492 9496 9496 9500 9500 9508 9508 9516 9516 9524 9524 9532 9532 9552 9553 9556 9556 9559 9559 9562 9562 9565 9565 9568 9568 9571 9571 9574 9574 9577 9577 9580 9580 9600 9600 9604 9604 9608 9608 9617 9619 9632 9632)) (make-character-set :mib-enum 7 :name "ISO_8859-4:1988" :aliases '("csISOLatin4" "l4" "latin4" #6="ISO-8859-4" "ISO_8859-4" "iso-ir-110") :mime-encoding '#6# :source '"ECMA registry" :comments '("Alias: ISO-8859-4 (preferred MIME name)") :references '("[RFC1345,KXS2]") :ranges #(0 160 164 164 167 168 173 173 175 176 180 180 184 184 193 198 201 201 203 203 205 206 212 216 218 220 223 223 225 230 233 233 235 235 237 238 244 248 250 252 256 257 260 261 268 269 272 275 278 281 290 291 296 299 302 303 310 312 315 316 325 326 330 333 342 343 352 353 358 363 370 371 381 382 711 711 729 729 731 731)) (make-character-set :mib-enum 2047 :name "IBM857" :aliases '("csIBM857" "857" "cp857") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges #(0 127 160 207 209 220 223 239 241 252 255 255 286 287 304 305 350 351 9472 9472 9474 9474 9484 9484 9488 9488 9492 9492 9496 9496 9500 9500 9508 9508 9516 9516 9524 9524 9532 9532 9552 9553 9556 9556 9559 9559 9562 9562 9565 9565 9568 9568 9571 9571 9574 9574 9577 9577 9580 9580 9600 9600 9604 9604 9608 9608 9617 9619 9632 9632)) (make-character-set :mib-enum 40 :name #7="ISO-2022-JP-2" :aliases '("csISO2022JP2") :mime-encoding '#7# :source '"RFC-1554" :comments 'nil :references '("[RFC1554,Ohta]") :ranges #(0 275 278 290 292 299 302 333 336 382 461 476 501 501 711 711 713 713 720 720 728 731 733 733 890 890 900 902 904 906 908 908 910 929 931 974 1025 1036 1038 1103 1105 1116 1118 1119 8208 8208 8213 8214 8216 8217 8220 8221 8224 8225 8229 8230 8240 8240 8242 8243 8251 8251 8254 8254 8308 8308 8319 8319 8321 8324 8364 8364 8367 8367 8451 8451 8457 8457 8467 8467 8470 8470 8481 8482 8486 8486 8491 8491 8531 8532 8539 8542 8544 8555 8560 8569 8592 8601 8658 8658 8660 8660 8704 8704 8706 8707 8711 8712 8715 8715 8719 8719 8721 8722 8730 8730 8733 8734 8736 8736 8741 8741 8743 8748 8750 8750 8756 8759 8764 8765 8776 8776 8780 8780 8786 8786 8800 8801 8804 8807 8810 8811 8814 8815 8834 8835 8838 8839 8857 8857 8869 8869 8978 8978 9312 9326 9332 9397 9424 9449 9472 9547 9618 9618 9632 9633 9635 9641 9650 9651 9654 9655 9660 9661 9664 9665 9670 9672 9675 9675 9678 9681 9711 9711 9733 9734 9742 9743 9756 9756 9758 9758 9792 9792 9794 9794 9824 9825 9827 9829 9831 9834 9836 9837 9839 9839 12288 12291 12293 12311 12316 12316 12353 12435 12443 12446 12449 12534 12539 12542 12549 12585 12593 12686 12800 12828 12832 12841 12896 12923 12927 12927 13184 13188 13192 13258 13263 13264 13267 13267 13270 13270 13272 13272 13275 13277 19968 19973 19975 19982 19984 19999 20001 20008 20010 20018 20020 20022 20024 20037 20039 20041 20043 20058 20060 20067 20070 20070 20072 20073 20075 20075 20077 20077 20080 20081 20083 20087 20089 20089 20094 20096 20098 20098 20101 20102 20104 20130 20132 20137 20139 20144 20146 20147 20149 20150 20153 20155 20159 20167 20169 20171 20173 20177 20179 20187 20189 20197 20200 20200 20202 20211 20213 20215 20219 20219 20221 20227 20232 20242 20245 20256 20258 20258 20260 20263 20266 20267 20270 20286 20288 20288 20290 20291 20294 20297 20299 20320 20323 20325 20327 20327 20329 20330 20332 20332 20334 20337 20339 20351 20353 20358 20360 20372 20374 20379 20381 20385 20387 20387 20389 20399 20402 20402 20405 20407 20409 20409 20411 20422 20424 20436 20439 20440 20442 20454 20456 20458 20461 20467 20469 20470 20472 20472 20474 20474 20476 20482 20484 20487 20489 20500 20502 20511 20513 20526 20528 20528 20530 20531 20533 20534 20537 20540 20542 20542 20544 20547 20549 20554 20556 20556 20558 20563 20565 20567 20569 20570 20572 20572 20575 20576 20578 20579 20581 20583 20586 20586 20588 20589 20592 20594 20596 20600 20603 20603 20605 20609 20611 20614 20616 20616 20618 20618 20621 20628 20630 20630 20632 20636 20638 20643 20645 20645 20647 20650 20652 20653 20655 20656 20658 20661 20663 20663 20665 20667 20669 20670 20672 20672 20674 20677 20679 20679 20681 20682 20684 20689 20691 20694 20696 20696 20698 20698 20700 20703 20706 20713 20716 20719 20721 20723 20725 20726 20729 20731 20734 20740 20742 20745 20747 20750 20752 20752 20754 20754 20756 20767 20769 20769 20771 20771 20775 20776 20778 20778 20780 20781 20783 20783 20785 20789 20791 20796 20799 20824 20826 20826 20828 20828 20831 20831 20834 20834 20836 20846 20848 20849 20851 20857 20859 20862 20864 20870 20872 20883 20885 20889 20891 20893 20896 20902 20904 20909 20911 20920 20922 20928 20930 20930 20932 20937 20939 20941 20943 20943 20945 20947 20949 20950 20952 20952 20955 20958 20960 20962 20964 20967 20969 20971 20973 21000 21002 21003 21005 21006 21009 21019 21021 21021 21024 21024 21026 21026 21028 21029 21031 21035 21037 21038 21040 21043 21045 21053 21055 21061 21063 21063 21065 21069 21071 21073 21076 21080 21082 21089 21091 21095 21097 21098 21102 21109 21111 21113 21117 21117 21119 21123 21125 21125 21127 21130 21132 21133 21136 21144 21146 21165 21167 21185 21187 21193 21195 21197 21199 21202 21204 21209 21211 21226 21228 21228 21232 21243 21246 21251 21253 21254 21256 21256 21258 21261 21263 21265 21267 21267 21269 21281 21283 21283 21285 21299 21301 21301 21304 21327 21329 21340 21342 21353 21355 21365 21367 21371 21373 21375 21378 21385 21387 21390 21395 21398 21400 21402 21405 21405 21407 21414 21416 21419 21421 21424 21426 21432 21434 21435 21437 21437 21439 21443 21445 21445 21448 21455 21457 21467 21469 21491 21493 21501 21505 21508 21510 21510 21512 21523 21525 21527 21530 21531 21533 21537 21539 21539 21542 21551 21553 21558 21560 21561 21563 21566 21568 21568 21570 21572 21574 21579 21581 21593 21595 21596 21598 21599 21602 21602 21604 21604 21606 21611 21613 21614 21616 21624 21627 21629 21631 21638 21640 21641 21643 21650 21652 21654 21657 21661 21663 21663 21665 21679 21681 21684 21687 21698 21700 21700 21702 21706 21708 21717 21719 21722 21724 21730 21733 21738 21740 21743 21746 21747 21750 21750 21754 21754 21756 21761 21764 21769 21772 21777 21780 21782 21787 21788 21792 21792 21794 21796 21799 21799 21802 21804 21806 21811 21813 21817 21819 21825 21827 21831 21833 21834 21836 21837 21839 21841 21843 21843 21845 21848 21850 21854 21856 21857 21859 21863 21866 21866 21868 21870 21877 21880 21883 21884 21886 21892 21894 21899 21902 21903 21905 21908 21911 21914 21916 21919 21923 21924 21927 21934 21936 21939 21941 21943 21945 21945 21947 21947 21949 21951 21953 21953 21955 21959 21961 21961 21963 21966 21969 21972 21974 21976 21978 21983 21985 21990 21992 21996 21999 21999 22002 22003 22005 22007 22009 22009 22013 22017 22021 22022 22024 22026 22028 22034 22036 22036 22038 22041 22043 22043 22046 22047 22051 22052 22055 22055 22057 22057 22060 22061 22063 22073 22075 22077 22079 22084 22086 22086 22089 22089 22091 22096 22099 22100 22103 22105 22107 22108 22110 22110 22112 22116 22118 22118 22120 22125 22127 22127 22129 22130 22132 22134 22136 22136 22138 22140 22144 22144 22148 22152 22154 22156 22158 22159 22163 22165 22169 22170 22173 22176 22178 22179 22181 22185 22187 22191 22193 22193 22195 22196 22198 22199 22204 22204 22206 22206 22208 22211 22213 22213 22216 22225 22227 22228 22231 22248 22251 22251 22253 22254 22256 22263 22265 22266 22269 22276 22278 22285 22287 22287 22289 22291 22293 22294 22296 22296 22298 22301 22303 22304 22306 22314 22316 22320 22323 22324 22327 22331 22333 22336 22338 22338 22341 22343 22346 22346 22348 22354 22359 22359 22362 22370 22372 22379 22381 22385 22387 22391 22393 22396 22398 22399 22401 22406 22408 22409 22411 22412 22418 22421 22423 22423 22425 22436 22438 22446 22448 22448 22450 22452 22456 22456 22461 22461 22464 22464 22466 22467 22470 22472 22475 22476 22478 22479 22482 22486 22488 22490 22492 22497 22499 22500 22502 22503 22505 22505 22509 22509 22511 22512 22516 22522 22524 22528 22530 22541 22545 22545 22549 22549 22553 22553 22555 22555 22557 22561 22564 22564 22566 22567 22570 22570 22573 22573 22575 22578 22580 22581 22585 22586 22589 22589 22591 22593 22596 22596 22601 22605 22607 22610 22612 22613 22615 22618 22622 22623 22625 22626 22628 22629 22631 22633 22635 22636 22640 22640 22642 22642 22645 22645 22648 22649 22652 22652 22654 22657 22659 22659 22661 22661 22663 22666 22668 22669 22671 22672 22674 22676 22678 22679 22681 22682 22684 22690 22694 22694 22696 22697 22699 22699 22702 22702 22705 22707 22712 22716 22718 22718 22721 22722 22724 22725 22727 22728 22730 22730 22732 22734 22736 22746 22748 22751 22753 22754 22756 22757 22761 22761 22763 22764 22766 22771 22774 22775 22777 22781 22786 22786 22788 22791 22793 22797 22799 22800 22802 22806 22808 22813 22815 22815 22817 22821 22823 22842 22844 22844 22846 22847 22849 22852 22854 22857 22859 22859 22862 22875 22877 22883 22885 22885 22887 22895 22898 22902 22904 22905 22907 22909 22913 22916 22918 22920 22922 22926 22930 22931 22933 22935 22937 22937 22939 22939 22941 22943 22947 22949 22951 22960 22962 22963 22967 22967 22969 22972 22974 22974 22977 22977 22979 22980 22982 22982 22984 22987 22989 22989 22992 22996 22999 23002 23004 23007 23011 23016 23018 23020 23022 23023 23025 23026 23028 23028 23030 23033 23035 23035 23039 23041 23043 23049 23052 23054 23057 23059 23064 23064 23066 23068 23070 23072 23075 23077 23079 23082 23085 23085 23087 23090 23092 23094 23100 23100 23104 23105 23108 23114 23116 23116 23120 23120 23125 23125 23130 23130 23134 23134 23138 23139 23141 23143 23146 23146 23148 23149 23156 23159 23162 23163 23166 23167 23179 23179 23184 23184 23186 23187 23190 23190 23193 23196 23198 23200 23202 23202 23204 23204 23207 23207 23210 23210 23212 23212 23217 23219 23221 23221 23224 23224 23226 23231 23233 23234 23236 23236 23238 23238 23240 23241 23243 23244 23247 23248 23250 23250 23252 23252 23254 23256 23258 23258 23260 23260 23264 23265 23267 23267 23269 23270 23273 23275 23278 23278 23281 23281 23285 23286 23290 23291 23293 23293 23296 23297 23301 23301 23304 23305 23307 23308 23318 23319 23321 23321 23323 23323 23325 23325 23329 23330 23333 23333 23338 23338 23340 23341 23344 23344 23346 23346 23348 23348 23350 23352 23358 23358 23360 23361 23363 23363 23365 23365 23371 23372 23376 23391 23394 23398 23400 23404 23406 23409 23411 23411 23413 23413 23416 23416 23418 23418 23420 23425 23427 23441 23443 23462 23464 23482 23484 23495 23497 23497 23500 23501 23503 23504 23506 23508 23510 23515 23517 23522 23524 23529 23531 23532 23534 23537 23539 23542 23544 23551 23553 23554 23556 23567 23569 23569 23571 23578 23580 23584 23586 23593 23595 23598 23600 23602 23604 23606 23608 23618 23621 23622 23624 23627 23629 23633 23635 23635 23637 23637 23641 23644 23646 23646 23648 23657 23660 23665 23668 23670 23673 23677 23679 23679 23681 23682 23687 23688 23690 23690 23692 23693 23695 23698 23700 23700 23702 23709 23711 23715 23718 23718 23720 23725 23729 23736 23738 23745 23748 23749 23751 23751 23753 23753 23755 23755 23762 23762 23767 23767 23769 23769 23773 23773 23776 23777 23780 23782 23784 23786 23789 23794 23796 23796 23798 23798 23802 23803 23805 23805 23809 23811 23814 23815 23819 23819 23821 23822 23825 23826 23828 23835 23838 23839 23842 23844 23846 23847 23849 23849 23851 23851 23853 23854 23857 23857 23860 23860 23865 23865 23869 23871 23874 23875 23878 23880 23882 23884 23886 23886 23888 23890 23893 23893 23896 23897 23899 23901 23903 23906 23908 23908 23913 23917 23919 23920 23923 23924 23926 23926 23929 23930 23934 23935 23937 23940 23943 23944 23946 23948 23952 23952 23954 23957 23961 23961 23963 23963 23965 23965 23967 23968 23970 23970 23975 23975 23978 23980 23982 23982 23984 23984 23986 23986 23988 23988 23991 23994 23996 23997 24003 24003 24005 24005 24007 24007 24009 24009 24011 24014 24016 24016 24018 24019 24022 24022 24024 24025 24027 24027 24029 24030 24032 24041 24043 24043 24046 24047 24049 24053 24055 24057 24059 24059 24061 24062 24064 24067 24069 24072 24075 24077 24079 24082 24084 24086 24088 24093 24095 24096 24101 24104 24107 24107 24109 24115 24117 24120 24123 24128 24130 24133 24135 24135 24137 24137 24139 24140 24142 24142 24144 24145 24148 24152 24155 24156 24158 24159 24161 24164 24168 24168 24170 24174 24176 24176 24178 24193 24195 24196 24198 24199 24202 24203 24206 24209 24211 24215 24217 24218 24220 24220 24222 24224 24226 24226 24228 24232 24234 24237 24241 24241 24243 24243 24245 24249 24253 24255 24257 24259 24262 24262 24264 24268 24270 24278 24282 24291 24293 24293 24296 24300 24304 24305 24307 24308 24310 24312 24314 24316 24318 24324 24326 24337 24339 24345 24347 24349 24351 24369 24372 24385 24388 24389 24391 24392 24394 24394 24396 24398 24400 24409 24411 24413 24416 24420 24422 24423 24425 24429 24431 24437 24439 24453 24455 24461 24463 24467 24469 24473 24476 24478 24480 24482 24484 24484 24487 24497 24499 24501 24503 24505 24508 24509 24515 24521 24523 24525 24527 24532 24534 24537 24540 24542 24544 24546 24548 24548 24551 24563 24565 24566 24568 24568 24570 24583 24586 24586 24589 24592 24594 24605 24607 24609 24612 24619 24621 24621 24623 24623 24625 24625 24627 24627 24629 24629 24634 24636 24639 24643 24646 24653 24656 24658 24660 24663 24665 24666 24669 24669 24671 24677 24679 24685 24687 24689 24691 24691 24693 24703 24705 24710 24712 24718 24721 24728 24730 24731 24733 24736 24738 24749 24751 24760 24763 24766 24770 24770 24772 24779 24782 24783 24785 24785 24787 24789 24792 24803 24805 24809 24811 24829 24832 24835 24838 24842 24844 24855 24857 24860 24862 24868 24870 24872 24874 24876 24880 24881 24884 24887 24889 24889 24892 24895 24897 24898 24900 24910 24913 24913 24915 24915 24917 24917 24920 24922 24925 24928 24930 24933 24935 24936 24939 24940 24942 24952 24955 24964 24967 24967 24970 24971 24973 24974 24976 24980 24982 24986 24988 24989 24991 24992 24996 24997 24999 25006 25010 25010 25014 25018 25020 25020 25022 25022 25024 25027 25030 25042 25044 25045 25052 25055 25057 25059 25061 25063 25065 25065 25068 25069 25071 25071 25074 25074 25076 25080 25082 25082 25084 25089 25091 25092 25094 25112 25114 25127 25129 25132 25134 25140 25142 25145 25147 25147 25149 25156 25158 25161 25163 25166 25168 25174 25176 25176 25178 25180 25182 25182 25184 25184 25187 25188 25190 25201 25203 25203 25206 25206 25209 25210 25212 25216 25218 25220 25225 25226 25229 25240 25242 25244 25246 25250 25252 25254 25256 25256 25259 25260 25265 25265 25267 25267 25269 25271 25273 25279 25282 25282 25284 25290 25292 25309 25311 25315 25317 25322 25324 25327 25329 25335 25340 25343 25345 25348 25351 25358 25360 25361 25363 25363 25366 25366 25368 25371 25373 25381 25383 25387 25389 25389 25391 25391 25394 25394 25397 25398 25401 25407 25409 25414 25417 25424 25426 25429 25431 25432 25435 25436 25438 25439 25441 25443 25445 25449 25451 25454 25457 25458 25460 25464 25466 25469 25471 25472 25474 25476 25479 25482 25484 25484 25486 25488 25490 25490 25492 25494 25496 25499 25502 25520 25522 25525 25527 25528 25530 25534 25536 25537 25539 25542 25544 25545 25549 25558 25562 25564 25566 25566 25568 25569 25571 25571 25573 25573 25577 25578 25580 25582 25586 25594 25597 25597 25599 25602 25605 25606 25609 25613 25615 25616 25618 25620 25622 25624 25627 25628 25630 25630 25632 25634 25636 25638 25640 25642 25644 25645 25647 25648 25652 25654 25658 25658 25661 25663 25665 25666 25668 25672 25674 25675 25678 25679 25681 25684 25688 25688 25690 25697 25699 25699 25703 25703 25705 25705 25709 25709 25711 25711 25715 25716 25718 25718 25720 25723 25725 25725 25730 25733 25735 25736 25743 25747 25749 25750 25752 25755 25757 25759 25761 25761 25763 25766 25768 25769 25771 25774 25776 25776 25778 25779 25781 25781 25783 25794 25796 25797 25799 25799 25801 25806 25808 25810 25812 25813 25815 25816 25818 25818 25822 25822 25824 25831 25833 25834 25836 25837 25839 25842 25844 25847 25850 25851 25853 25857 25860 25861 25864 25866 25871 25871 25874 25876 25878 25878 25880 25881 25883 25887 25890 25894 25897 25900 25902 25903 25905 25905 25908 25919 25923 25923 25925 25925 25927 25929 25932 25938 25940 25945 25947 25947 25949 25952 25954 25955 25958 25959 25963 25965 25968 25968 25970 25970 25972 25973 25975 25976 25978 25978 25981 25982 25985 25987 25989 25989 25991 25996 25998 25998 26000 26003 26005 26005 26007 26009 26011 26013 26015 26017 26019 26023 26025 26025 26027 26032 26034 26036 26039 26039 26041 26041 26044 26045 26047 26047 26049 26054 26056 26057 26059 26060 26062 26064 26066 26066 26068 26068 26070 26073 26075 26075 26079 26083 26085 26089 26092 26098 26100 26103 26105 26112 26114 26116 26118 26122 26124 26134 26137 26137 26140 26161 26163 26167 26169 26172 26174 26182 26185 26188 26190 26191 26193 26210 26212 26220 26222 26224 26227 26236 26238 26244 26247 26249 26251 26254 26256 26258 26262 26269 26271 26272 26274 26274 26276 26276 26278 26280 26283 26283 26285 26286 26289 26293 26296 26297 26299 26300 26302 26308 26310 26313 26316 26316 26318 26319 26324 26324 26326 26326 26329 26333 26335 26336 26342 26342 26344 26345 26347 26348 26350 26350 26352 26352 26354 26357 26359 26368 26371 26371 26373 26373 26375 26379 26381 26384 26387 26391 26393 26393 26395 26400 26402 26402 26406 26408 26410 26415 26417 26417 26419 26424 26426 26426 26429 26435 26437 26441 26444 26444 26446 26449 26451 26454 26457 26457 26460 26470 26472 26474 26476 26487 26491 26492 26494 26495 26497 26497 26500 26501 26503 26503 26505 26505 26507 26508 26510 26513 26515 26515 26517 26526 26528 26531 26533 26539 26541 26541 26543 26553 26555 26558 26560 26566 26568 26570 26574 26580 26583 26586 26588 26590 26592 26594 26596 26599 26601 26601 26604 26604 26606 26615 26617 26617 26619 26619 26621 26624 26626 26629 26631 26636 26638 26639 26641 26644 26646 26647 26649 26649 26653 26655 26657 26658 26663 26669 26671 26676 26679 26681 26683 26694 26696 26698 26700 26702 26704 26709 26711 26713 26715 26717 26719 26729 26731 26731 26733 26738 26740 26743 26745 26748 26750 26751 26753 26758 26760 26760 26765 26765 26767 26767 26771 26772 26774 26776 26778 26781 26783 26787 26789 26794 26797 26803 26805 26806 26809 26812 26816 26816 26818 26818 26820 26822 26824 26829 26831 26842 26844 26845 26847 26849 26851 26851 26853 26853 26855 26856 26858 26866 26869 26870 26873 26877 26880 26881 26884 26886 26888 26899 26902 26903 26905 26908 26911 26920 26922 26922 26925 26925 26928 26929 26931 26934 26936 26937 26939 26939 26941 26941 26943 26943 26946 26946 26949 26949 26953 26954 26958 26958 26963 26965 26967 26967 26969 26974 26976 26982 26984 26997 26999 27010 27012 27012 27014 27018 27021 27022 27025 27026 27028 27030 27032 27032 27035 27036 27040 27041 27045 27048 27051 27051 27053 27055 27057 27058 27060 27060 27063 27064 27066 27068 27070 27071 27073 27073 27075 27075 27077 27077 27079 27080 27082 27086 27088 27089 27091 27092 27094 27097 27099 27099 27101 27104 27106 27106 27109 27109 27111 27112 27114 27115 27117 27119 27121 27123 27125 27125 27129 27129 27131 27131 27133 27139 27141 27141 27146 27148 27151 27151 27153 27157 27159 27163 27165 27172 27176 27179 27182 27186 27188 27195 27197 27199 27204 27211 27214 27214 27216 27219 27221 27222 27224 27225 27227 27227 27231 27231 27233 27234 27236 27239 27242 27243 27249 27251 27256 27257 27260 27260 27262 27265 27267 27268 27270 27271 27273 27273 27275 27275 27277 27278 27280 27281 27287 27287 27291 27296 27298 27299 27301 27301 27305 27308 27310 27313 27315 27316 27320 27320 27323 27323 27325 27327 27329 27331 27334 27334 27336 27337 27340 27340 27344 27345 27347 27350 27354 27359 27364 27364 27367 27368 27370 27370 27372 27372 27376 27378 27382 27382 27386 27389 27394 27399 27401 27402 27404 27404 27407 27410 27414 27415 27419 27419 27421 27428 27431 27432 27435 27436 27439 27439 27442 27442 27445 27451 27453 27455 27459 27459 27462 27463 27465 27466 27468 27470 27472 27472 27474 27476 27478 27478 27480 27481 27483 27483 27485 27485 27487 27495 27497 27499 27502 27504 27506 27509 27511 27513 27515 27527 27529 27531 27533 27533 27538 27539 27541 27544 27546 27547 27550 27556 27560 27573 27575 27590 27593 27593 27595 27599 27602 27611 27615 27615 27617 27617 27619 27619 27622 27623 27626 27628 27630 27631 27633 27633 27635 27635 27637 27637 27639 27639 27641 27641 27645 27645 27647 27647 27650 27650 27652 27657 27661 27675 27679 27679 27681 27684 27686 27690 27692 27692 27694 27696 27698 27704 27706 27707 27709 27714 27718 27719 27721 27723 27725 27728 27730 27730 27732 27733 27735 27735 27737 27746 27748 27748 27751 27755 27757 27757 27759 27760 27762 27764 27766 27766 27768 27771 27773 27774 27777 27779 27781 27785 27788 27789 27791 27792 27794 27804 27807 27807 27809 27815 27817 27819 27821 27822 27824 27828 27832 27839 27841 27842 27844 27846 27849 27850 27852 27853 27855 27863 27865 27870 27872 27875 27877 27877 27879 27884 27886 27896 27898 27902 27905 27905 27908 27908 27911 27911 27914 27916 27918 27919 27921 27923 27927 27927 27929 27931 27934 27935 27941 27947 27950 27951 27953 27955 27957 27958 27960 27961 27963 27967 27969 27969 27971 27976 27978 27979 27981 27983 27985 27988 27991 27991 27993 27994 27996 27996 27998 28001 28003 28007 28009 28010 28012 28012 28014 28016 28020 28020 28023 28025 28028 28028 28031 28031 28034 28034 28037 28037 28039 28041 28044 28046 28049 28057 28059 28065 28067 28068 28070 28076 28078 28079 28082 28082 28084 28085 28087 28089 28092 28093 28095 28096 28099 28104 28106 28108 28110 28111 28113 28114 28117 28118 28120 28123 28125 28130 28132 28134 28136 28140 28142 28145 28147 28156 28160 28160 28164 28165 28167 28174 28176 28177 28179 28183 28185 28187 28189 28199 28201 28201 28203 28207 28210 28210 28212 28212 28214 28214 28216 28222 28227 28229 28232 28235 28237 28239 28241 28244 28246 28248 28251 28255 28258 28259 28263 28264 28267 28267 28270 28271 28274 28275 28278 28278 28282 28283 28285 28288 28290 28291 28293 28294 28297 28297 28300 28301 28303 28304 28307 28307 28310 28310 28312 28313 28316 28317 28319 28320 28322 28322 28325 28325 28327 28327 28330 28331 28333 28335 28337 28340 28342 28343 28346 28347 28349 28349 28351 28357 28359 28367 28369 28369 28371 28373 28375 28375 28378 28378 28381 28386 28388 28390 28392 28393 28395 28399 28402 28402 28404 28404 28407 28409 28411 28411 28413 28415 28417 28418 28420 28420 28422 28422 28424 28426 28428 28429 28431 28431 28433 28433 28435 28438 28440 28440 28442 28443 28448 28448 28450 28452 28454 28454 28457 28461 28463 28467 28470 28470 28472 28472 28475 28476 28478 28479 28481 28481 28485 28487 28491 28491 28493 28493 28495 28495 28497 28500 28503 28511 28513 28514 28516 28516 28518 28518 28520 28520 28524 28528 28530 28530 28532 28532 28536 28536 28538 28538 28540 28542 28544 28548 28550 28553 28555 28558 28560 28564 28566 28567 28570 28570 28572 28572 28575 28577 28579 28584 28586 28586 28590 28593 28595 28595 28597 28598 28601 28601 28604 28604 28606 28606 28608 28611 28613 28618 28625 28626 28628 28629 28632 28632 28634 28635 28638 28641 28644 28644 28648 28649 28651 28652 28654 28657 28659 28659 28661 28662 28665 28666 28668 28670 28672 28673 28677 28679 28681 28681 28683 28683 28685 28685 28687 28687 28689 28689 28693 28693 28695 28696 28698 28704 28707 28707 28710 28712 28716 28716 28719 28720 28722 28722 28724 28725 28727 28727 28729 28729 28732 28732 28734 28734 28739 28740 28744 28748 28750 28753 28756 28757 28760 28760 28765 28766 28771 28773 28779 28784 28789 28790 28792 28792 28796 28801 28805 28806 28809 28810 28814 28814 28818 28818 28820 28829 28833 28833 28836 28836 28843 28849 28851 28852 28855 28861 28864 28867 28872 28872 28874 28875 28879 28879 28881 28881 28883 28886 28888 28889 28891 28893 28895 28895 28900 28900 28902 28905 28907 28909 28911 28911 28913 28913 28919 28919 28921 28922 28925 28925 28931 28935 28937 28940 28943 28944 28947 28950 28952 28954 28956 28956 28958 28958 28960 28961 28966 28966 28971 28971 28973 28973 28975 28977 28982 28982 28984 28984 28988 28988 28993 28993 28997 28999 29001 29004 29006 29006 29008 29008 29010 29010 29013 29015 29017 29018 29020 29020 29022 29022 29024 29024 29026 29026 29028 29033 29036 29036 29038 29038 29042 29043 29048 29050 29053 29053 29056 29056 29060 29061 29063 29066 29068 29068 29071 29071 29074 29074 29076 29077 29080 29083 29087 29088 29090 29090 29096 29096 29100 29100 29103 29107 29109 29109 29113 29114 29118 29121 29123 29124 29128 29129 29131 29132 29134 29134 29136 29136 29138 29143 29145 29146 29148 29148 29151 29152 29157 29159 29164 29166 29173 29173 29176 29177 29179 29180 29182 29184 29190 29193 29197 29197 29200 29200 29203 29203 29207 29207 29210 29211 29213 29213 29215 29215 29220 29220 29224 29224 29226 29229 29231 29234 29236 29251 29253 29256 29259 29264 29266 29267 29269 29270 29272 29283 29286 29289 29291 29291 29294 29295 29297 29298 29300 29301 29303 29314 29316 29316 29319 29319 29321 29323 29325 29327 29330 29331 29334 29334 29339 29339 29343 29344 29346 29346 29351 29352 29356 29362 29364 29364 29366 29369 29374 29374 29376 29380 29382 29385 29388 29390 29392 29392 29394 29394 29397 29401 29403 29403 29406 29410 29413 29413 29416 29417 29420 29428 29431 29438 29441 29445 29447 29447 29450 29451 29453 29454 29458 29459 29461 29465 29467 29471 29473 29474 29476 29477 29479 29484 29486 29487 29489 29490 29492 29499 29501 29503 29507 29509 29517 29520 29522 29522 29526 29528 29533 29536 29539 29539 29542 29554 29557 29557 29559 29564 29566 29566 29568 29569 29571 29575 29577 29577 29579 29579 29582 29582 29584 29585 29587 29592 29595 29596 29598 29600 29602 29602 29605 29607 29609 29611 29613 29616 29618 29619 29621 29621 29623 29623 29625 29629 29631 29632 29634 29634 29637 29638 29640 29651 29654 29654 29657 29657 29661 29662 29664 29665 29667 29671 29673 29674 29677 29678 29681 29682 29684 29685 29687 29691 29693 29697 29699 29703 29705 29706 29711 29713 29715 29715 29722 29723 29728 29730 29732 29734 29736 29750 29752 29754 29756 29756 29759 29761 29763 29764 29766 29767 29771 29771 29773 29773 29777 29778 29781 29781 29783 29783 29785 29792 29794 29803 29805 29811 29814 29815 29822 29822 29824 29827 29829 29831 29833 29833 29835 29835 29838 29842 29848 29850 29852 29852 29854 29859 29861 29867 29870 29874 29877 29877 29881 29883 29885 29885 29887 29887 29894 29894 29896 29898 29900 29900 29903 29904 29906 29908 29912 29912 29914 29916 29918 29920 29922 29924 29926 29931 29934 29938 29940 29940 29942 29944 29946 29948 29951 29951 29953 29953 29955 29958 29964 29967 29969 29971 29973 29980 29982 29985 29987 29997 29999 30003 30005 30016 30019 30036 30039 30039 30041 30050 30052 30055 30057 30059 30061 30061 30063 30079 30081 30083 30085 30087 30089 30091 30094 30103 30105 30106 30108 30109 30111 30117 30123 30124 30126 30133 30136 30138 30140 30154 30156 30159 30162 30162 30164 30169 30171 30172 30174 30180 30182 30188 30190 30196 30201 30202 30204 30204 30206 30213 30215 30221 30223 30224 30226 30227 30229 30233 30235 30247 30249 30251 30253 30253 30256 30256 30258 30261 30264 30268 30270 30286 30290 30290 30292 30294 30296 30297 30300 30300 30302 30303 30305 30309 30311 30322 30324 30324 30326 30326 30328 30328 30330 30334 30336 30344 30347 30350 30352 30353 30355 30355 30357 30358 30361 30365 30367 30368 30370 30376 30378 30378 30381 30382 30384 30386 30388 30388 30391 30394 30397 30397 30399 30399 30401 30403 30405 30406 30408 30418 30420 30420 30422 30425 30427 30428 30430 30433 30435 30440 30442 30442 30444 30444 30446 30450 30452 30452 30454 30454 30456 30457 30459 30460 30462 30462 30464 30465 30468 30468 30470 30478 30482 30482 30484 30485 30487 30487 30489 30492 30494 30496 30498 30498 30500 30502 30504 30505 30509 30511 30516 30522 30524 30526 30528 30531 30533 30535 30538 30538 30541 30546 30550 30551 30554 30556 30558 30568 30570 30572 30576 30576 30578 30580 30585 30586 30589 30592 30596 30597 30603 30606 30609 30610 30612 30614 30618 30618 30622 30624 30626 30626 30629 30629 30631 30631 30633 30634 30636 30641 30643 30643 30645 30646 30649 30649 30651 30655 30659 30659 30663 30663 30665 30665 30669 30669 30673 30674 30677 30677 30679 30679 30681 30684 30686 30688 30690 30695 30697 30705 30707 30708 30710 30710 30712 30712 30715 30722 30725 30726 30729 30729 30732 30734 30737 30738 30740 30744 30746 30746 30748 30749 30751 30755 30757 30759 30761 30761 30764 30766 30768 30768 30770 30770 30772 30773 30775 30780 30782 30784 30787 30789 30791 30792 30796 30796 30798 30800 30802 30802 30805 30807 30812 30814 30816 30817 30819 30820 30824 30824 30826 30831 30834 30834 30836 30836 30839 30839 30842 30842 30844 30844 30846 30846 30849 30849 30854 30855 30857 30858 30860 30863 30865 30865 30867 30869 30871 30872 30874 30879 30881 30881 30883 30885 30887 30890 30892 30893 30895 30901 30905 30911 30913 30913 30917 30924 30926 30926 30928 30934 30937 30939 30943 30945 30948 30948 30950 30952 30954 30954 30956 30956 30959 30959 30962 30967 30970 30971 30973 30973 30975 30977 30981 30983 30988 30988 30990 30990 30992 30995 30998 30998 31001 31002 31004 31004 31006 31008 31012 31015 31017 31021 31025 31025 31028 31029 31034 31041 31044 31051 31055 31057 31059 31064 31066 31072 31074 31074 31077 31077 31079 31081 31083 31083 31085 31085 31087 31087 31090 31090 31095 31100 31102 31105 31108 31109 31114 31119 31121 31121 31123 31126 31128 31128 31130 31133 31137 31137 31142 31147 31150 31153 31155 31156 31160 31163 31165 31172 31174 31179 31181 31181 31183 31183 31185 31186 31188 31190 31192 31192 31194 31194 31197 31207 31209 31213 31215 31217 31224 31224 31227 31229 31232 31232 31234 31235 31237 31246 31249 31249 31252 31253 31255 31260 31262 31265 31267 31267 31271 31271 31275 31275 31277 31296 31298 31305 31308 31313 31317 31319 31321 31321 31324 31325 31327 31331 31333 31333 31335 31335 31337 31339 31341 31341 31344 31344 31348 31354 31357 31366 31368 31368 31370 31371 31373 31373 31376 31384 31388 31392 31395 31395 31397 31398 31400 31402 31404 31408 31411 31411 31413 31414 31417 31420 31423 31423 31427 31439 31441 31443 31445 31447 31449 31459 31461 31462 31464 31469 31471 31473 31476 31476 31478 31478 31480 31483 31485 31487 31490 31492 31494 31496 31498 31499 31503 31503 31505 31505 31508 31509 31512 31513 31515 31515 31518 31520 31523 31537 31539 31542 31544 31546 31548 31553 31557 31561 31563 31570 31572 31574 31576 31576 31578 31579 31581 31581 31584 31584 31586 31586 31588 31591 31593 31594 31596 31605 31607 31607 31609 31611 31613 31614 31616 31616 31620 31623 31625 31625 31627 31627 31629 31634 31636 31650 31653 31661 31663 31666 31668 31670 31672 31672 31674 31677 31680 31682 31684 31692 31695 31695 31697 31700 31702 31703 31705 31707 31709 31709 31712 31713 31716 31718 31720 31722 31725 31726 31729 31738 31740 31740 31742 31742 31744 31748 31750 31751 31753 31753 31755 31759 31761 31764 31766 31767 31769 31769 31771 31771 31774 31777 31779 31779 31781 31784 31786 31788 31793 31793 31795 31796 31798 31802 31805 31809 31811 31811 31814 31814 31818 31818 31820 31821 31823 31830 31832 31841 31843 31845 31847 31847 31849 31849 31852 31854 31856 31856 31858 31861 31865 31865 31867 31870 31873 31875 31878 31879 31881 31881 31883 31883 31885 31885 31887 31890 31892 31893 31895 31896 31899 31906 31908 31912 31914 31915 31917 31918 31920 31923 31926 31927 31929 31938 31940 31941 31943 31946 31948 31951 31954 31962 31964 31968 31970 31970 31974 31977 31979 31979 31983 31983 31986 31986 31988 31990 31992 31992 31994 31995 31998 31998 32000 32000 32002 32011 32013 32013 32015 32030 32032 32035 32038 32039 32042 32051 32053 32053 32057 32058 32060 32072 32075 32081 32083 32083 32086 32087 32089 32094 32097 32099 32101 32104 32106 32106 32110 32110 32112 32115 32117 32123 32125 32125 32127 32127 32129 32131 32133 32134 32136 32137 32139 32143 32145 32145 32147 32147 32150 32151 32153 32160 32162 32163 32166 32167 32170 32187 32189 32191 32194 32199 32202 32207 32209 32210 32213 32218 32220 32222 32224 32230 32232 32237 32239 32239 32241 32242 32244 32246 32249 32251 32256 32257 32260 32261 32264 32267 32272 32274 32277 32277 32279 32279 32283 32291 32294 32296 32299 32303 32305 32307 32309 32311 32313 32315 32317 32319 32321 32321 32323 32327 32330 32331 32333 32334 32336 32336 32338 32338 32340 32342 32344 32346 32349 32351 32353 32354 32357 32359 32361 32363 32365 32368 32371 32371 32376 32377 32379 32383 32385 32387 32390 32394 32396 32406 32408 32408 32410 32429 32431 32435 32437 32442 32445 32469 32471 32483 32485 32491 32493 32504 32506 32521 32523 32527 32529 32541 32543 32566 32568 32568 32570 32575 32578 32581 32583 32583 32588 32597 32599 32600 32602 32605 32607 32619 32621 32622 32624 32626 32628 32629 32631 32633 32637 32643 32645 32648 32650 32657 32660 32660 32662 32663 32666 32666 32668 32671 32673 32676 32678 32682 32685 32688 32690 32690 32692 32692 32694 32694 32696 32697 32700 32701 32703 32705 32707 32707 32709 32710 32712 32712 32714 32714 32716 32716 32718 32719 32722 32722 32724 32725 32728 32728 32731 32731 32735 32737 32739 32739 32741 32742 32744 32745 32747 32748 32750 32755 32761 32769 32771 32793 32796 32802 32804 32810 32812 32814 32816 32817 32819 32832 32834 32836 32838 32838 32842 32845 32850 32850 32852 32852 32854 32854 32856 32856 32858 32858 32862 32866 32868 32868 32870 32870 32872 32874 32877 32877 32879 32887 32889 32889 32893 32897 32899 32905 32907 32908 32910 32910 32915 32915 32918 32918 32920 32920 32922 32930 32932 32935 32937 32943 32945 32946 32948 32948 32951 32954 32956 32964 32966 32966 32968 32968 32972 32975 32978 32978 32980 32990 32992 32993 32996 32997 32999 33012 33014 33014 33016 33018 33020 33022 33026 33027 33029 33035 33037 33044 33046 33048 33050 33052 33054 33054 33056 33056 33059 33060 33063 33063 33065 33065 33067 33068 33071 33075 33077 33078 33080 33082 33084 33084 33086 33086 33093 33096 33098 33100 33102 33102 33104 33109 33111 33111 33113 33114 33119 33121 33125 33129 33131 33131 33133 33137 33140 33140 33143 33158 33160 33160 33162 33163 33166 33169 33171 33171 33173 33174 33176 33176 33178 33182 33184 33184 33186 33188 33190 33190 33192 33194 33198 33198 33200 33200 33202 33205 33208 33208 33210 33211 33213 33219 33221 33222 33224 33231 33233 33233 33235 33235 33237 33237 33239 33243 33245 33249 33251 33253 33255 33256 33258 33261 33264 33270 33272 33290 33292 33296 33298 33300 33302 33311 33313 33315 33320 33339 33342 33342 33344 33344 33347 33351 33353 33353 33355 33355 33358 33359 33361 33361 33366 33366 33368 33370 33372 33373 33375 33376 33378 33380 33382 33384 33386 33387 33389 33396 33398 33403 33405 33412 33415 33419 33421 33423 33425 33426 33428 33428 33430 33437 33439 33441 33443 33460 33463 33471 33473 33473 33476 33480 33482 33493 33495 33500 33502 33512 33514 33515 33517 33517 33519 33519 33521 33521 33523 33524 33526 33527 33529 33531 33533 33534 33536 33548 33550 33551 33553 33553 33556 33560 33562 33567 33569 33571 33575 33576 33579 33594 33596 33597 33600 33600 33602 33607 33609 33610 33613 33624 33626 33628 33630 33633 33635 33648 33651 33651 33653 33653 33655 33656 33659 33661 33663 33664 33666 33666 33668 33671 33673 33674 33677 33678 33682 33686 33688 33696 33698 33698 33702 33709 33712 33722 33724 33729 33733 33733 33735 33735 33737 33738 33740 33740 33742 33745 33747 33748 33750 33750 33752 33752 33756 33757 33759 33761 33765 33765 33768 33771 33775 33778 33780 33780 33782 33785 33787 33789 33793 33793 33795 33796 33798 33799 33802 33807 33809 33809 33811 33811 33813 33813 33816 33817 33820 33821 33824 33824 33826 33826 33828 33834 33836 33836 33839 33839 33841 33841 33845 33845 33848 33849 33852 33853 33861 33866 33869 33871 33873 33874 33878 33884 33888 33895 33897 33905 33907 33914 33916 33917 33921 33922 33924 33925 33927 33929 33931 33932 33934 33934 33936 33936 33938 33941 33943 33943 33945 33945 33948 33948 33950 33951 33953 33953 33958 33958 33960 33962 33965 33965 33967 33967 33969 33970 33972 33972 33976 33986 33988 33988 33990 33997 33999 34001 34003 34003 34006 34006 34009 34010 34012 34013 34015 34016 34019 34019 34021 34023 34026 34026 34028 34028 34030 34034 34036 34036 34039 34039 34042 34045 34047 34048 34050 34051 34054 34055 34060 34060 34062 34062 34064 34065 34067 34069 34071 34072 34074 34074 34076 34076 34078 34079 34081 34087 34090 34093 34095 34095 34098 34109 34111 34113 34115 34115 34118 34118 34120 34123 34126 34131 34133 34138 34140 34148 34152 34155 34157 34157 34159 34159 34162 34162 34164 34164 34167 34167 34169 34171 34173 34177 34180 34188 34191 34193 34195 34196 34199 34201 34203 34205 34207 34208 34210 34210 34212 34224 34228 34228 34230 34234 34236 34239 34241 34242 34247 34247 34249 34251 34253 34256 34259 34259 34261 34261 34264 34264 34266 34266 34268 34269 34271 34272 34276 34278 34280 34282 34285 34285 34291 34291 34294 34295 34297 34300 34302 34304 34306 34306 34308 34311 34314 34315 34317 34318 34320 34323 34326 34331 34334 34334 34337 34338 34343 34343 34345 34345 34349 34349 34351 34352 34358 34358 34360 34360 34362 34362 34364 34365 34367 34370 34374 34374 34381 34404 34407 34407 34409 34409 34411 34412 34414 34415 34417 34417 34421 34423 34425 34434 34440 34440 34442 34445 34449 34449 34451 34451 34453 34454 34456 34456 34458 34458 34460 34461 34465 34465 34467 34468 34470 34477 34479 34481 34483 34490 34495 34497 34499 34503 34505 34507 34509 34514 34516 34517 34519 34524 34526 34528 34531 34533 34535 34535 34537 34537 34540 34548 34552 34558 34560 34560 34562 34571 34573 34581 34583 34586 34588 34588 34590 34591 34593 34595 34597 34597 34600 34601 34606 34607 34609 34610 34612 34612 34615 34615 34617 34624 34627 34627 34629 34629 34631 34633 34635 34638 34643 34643 34645 34645 34647 34649 34653 34653 34655 34657 34659 34662 34664 34664 34666 34666 34670 34674 34676 34676 34678 34678 34680 34680 34683 34687 34690 34697 34699 34701 34704 34704 34707 34707 34709 34709 34711 34713 34718 34720 34722 34723 34727 34728 34731 34735 34737 34737 34739 34739 34741 34741 34746 34747 34749 34753 34756 34756 34758 34763 34766 34766 34768 34771 34773 34774 34777 34780 34783 34784 34786 34789 34794 34799 34801 34803 34806 34811 34814 34815 34817 34817 34819 34819 34821 34822 34825 34827 34829 34838 34840 34844 34846 34847 34849 34851 34855 34856 34861 34862 34864 34866 34869 34870 34873 34876 34880 34886 34888 34894 34897 34917 34920 34921 34923 34924 34926 34926 34928 34930 34933 34933 34935 34935 34937 34937 34939 34939 34941 34946 34948 34949 34952 34952 34955 34955 34957 34957 34962 34962 34966 34972 34974 34976 34978 34978 34980 34980 34984 34984 34986 34987 34989 34990 34992 34993 34996 34997 34999 34999 35002 35002 35004 35014 35017 35023 35025 35029 35032 35033 35035 35039 35041 35045 35047 35048 35055 35061 35063 35065 35068 35070 35073 35074 35076 35076 35078 35079 35082 35082 35084 35088 35090 35091 35093 35094 35096 35102 35104 35105 35109 35112 35114 35115 35120 35122 35124 35126 35128 35131 35134 35134 35136 35142 35145 35145 35148 35149 35151 35151 35154 35154 35158 35159 35162 35164 35166 35172 35174 35174 35178 35179 35181 35184 35186 35189 35191 35191 35194 35199 35201 35201 35203 35203 35206 35211 35213 35213 35215 35216 35219 35224 35226 35228 35231 35233 35237 35239 35241 35242 35244 35244 35247 35248 35250 35255 35258 35258 35260 35261 35263 35266 35268 35276 35278 35282 35284 35288 35290 35290 35292 35294 35299 35299 35301 35303 35305 35305 35307 35307 35309 35309 35311 35311 35313 35313 35315 35316 35318 35318 35320 35321 35325 35325 35327 35328 35330 35333 35335 35336 35338 35338 35340 35340 35342 35352 35355 35355 35357 35360 35362 35366 35370 35373 35375 35375 35377 35377 35379 35383 35386 35390 35392 35393 35395 35395 35397 35401 35405 35406 35408 35416 35419 35422 35424 35427 35429 35431 35433 35433 35435 35438 35440 35443 35445 35447 35449 35452 35454 35456 35458 35463 35465 35469 35471 35475 35477 35482 35486 35489 35491 35498 35500 35504 35506 35507 35510 35511 35513 35513 35515 35516 35518 35519 35522 35524 35526 35533 35535 35535 35537 35543 35546 35554 35556 35556 35558 35559 35562 35566 35568 35569 35571 35576 35578 35578 35580 35580 35582 35586 35588 35591 35594 35596 35598 35598 35600 35601 35604 35604 35606 35607 35609 35617 35622 35622 35624 35624 35627 35629 35632 35632 35635 35635 35639 35639 35641 35641 35644 35644 35646 35646 35649 35654 35656 35657 35660 35663 35666 35668 35670 35670 35672 35676 35678 35679 35683 35683 35686 35686 35691 35693 35695 35698 35700 35700 35702 35705 35708 35710 35712 35713 35715 35717 35722 35728 35730 35734 35737 35738 35740 35740 35742 35755 35757 35760 35762 35770 35772 35782 35784 35791 35793 35817 35819 35848 35850 35869 35871 35898 35901 35903 35905 35905 35909 35916 35918 35921 35923 35925 35927 35931 35933 35933 35937 35940 35942 35942 35944 35949 35955 35955 35957 35958 35960 35964 35966 35966 35970 35970 35973 35975 35977 35982 35984 35984 35986 35988 35992 35993 35995 35998 36000 36002 36004 36004 36007 36016 36018 36020 36022 36029 36031 36043 36045 36047 36049 36049 36051 36051 36053 36054 36057 36062 36064 36068 36070 36070 36072 36072 36074 36074 36076 36077 36079 36080 36082 36082 36084 36085 36087 36088 36090 36095 36097 36097 36099 36101 36103 36107 36109 36109 36111 36112 36114 36116 36118 36119 36123 36123 36125 36127 36129 36176 36179 36182 36184 36190 36192 36199 36201 36201 36203 36206 36208 36209 36211 36215 36223 36223 36225 36226 36228 36229 36232 36232 36234 36235 36237 36237 36240 36241 36244 36245 36249 36249 36254 36256 36259 36259 36262 36262 36264 36264 36267 36268 36271 36271 36273 36277 36279 36284 36286 36288 36290 36296 36298 36300 36302 36303 36305 36305 36308 36311 36313 36315 36317 36319 36321 36321 36323 36325 36327 36328 36330 36332 36335 36341 36343 36349 36351 36351 36353 36353 36356 36358 36360 36364 36367 36369 36372 36372 36374 36374 36381 36387 36390 36391 36393 36394 36396 36396 36398 36401 36403 36410 36413 36413 36416 36418 36420 36420 36423 36434 36436 36437 36441 36441 36443 36452 36454 36454 36457 36457 36460 36461 36463 36466 36468 36468 36470 36470 36473 36476 36479 36479 36481 36485 36487 36487 36489 36491 36493 36493 36495 36501 36505 36510 36513 36514 36519 36519 36521 36531 36533 36533 36538 36539 36542 36542 36544 36545 36547 36552 36554 36559 36561 36562 36564 36564 36571 36572 36575 36575 36578 36579 36584 36584 36587 36587 36589 36590 36592 36593 36599 36606 36608 36608 36610 36611 36613 36613 36615 36618 36620 36620 36623 36624 36626 36633 36635 36641 36643 36643 36645 36650 36652 36655 36659 36667 36670 36679 36681 36681 36684 36687 36689 36693 36695 36696 36700 36703 36705 36713 36715 36735 36737 36747 36749 36753 36755 36769 36771 36777 36779 36779 36781 36786 36789 36802 36804 36808 36810 36811 36813 36814 36816 36821 36824 36832 36834 36838 36840 36843 36845 36859 36861 36862 36864 36870 36872 36891 36893 36899 36902 36906 36908 36911 36913 36921 36923 36924 36926 36927 36929 36933 36935 36935 36937 36953 36955 36958 36960 36963 36965 36969 36972 36976 36978 36978 36980 36986 36988 36989 36991 36997 36999 37004 37006 37009 37011 37011 37013 37013 37015 37017 37019 37019 37021 37021 37024 37027 37029 37030 37032 37032 37034 37034 37036 37036 37038 37046 37048 37051 37053 37054 37057 37057 37059 37061 37063 37064 37066 37066 37068 37068 37070 37075 37077 37077 37079 37081 37083 37087 37089 37090 37092 37096 37099 37099 37101 37101 37103 37104 37108 37112 37117 37120 37122 37122 37124 37126 37128 37128 37133 37133 37136 37136 37138 37138 37140 37146 37148 37148 37150 37150 37152 37152 37154 37155 37157 37157 37159 37159 37161 37161 37165 37170 37172 37172 37174 37175 37177 37178 37180 37181 37187 37187 37190 37200 37202 37204 37206 37211 37213 37214 37217 37221 37223 37223 37225 37226 37228 37243 37245 37247 37249 37251 37253 37255 37257 37262 37264 37269 37271 37272 37274 37276 37278 37278 37281 37284 37286 37286 37288 37288 37290 37302 37304 37304 37306 37309 37311 37315 37317 37329 37331 37332 37334 37343 37345 37345 37347 37351 37353 37354 37356 37361 37365 37367 37369 37369 37371 37373 37375 37377 37380 37383 37385 37386 37388 37390 37392 37400 37404 37406 37411 37414 37416 37417 37420 37420 37422 37424 37427 37434 37436 37436 37438 37440 37442 37451 37453 37457 37463 37470 37472 37474 37476 37481 37486 37489 37492 37497 37499 37504 37507 37507 37509 37509 37512 37514 37517 37518 37521 37523 37525 37532 37535 37536 37540 37541 37543 37544 37547 37547 37549 37551 37554 37555 37558 37565 37567 37571 37573 37576 37579 37584 37586 37587 37589 37589 37591 37593 37596 37597 37599 37601 37603 37605 37607 37610 37612 37614 37616 37616 37618 37619 37624 37628 37631 37632 37634 37634 37636 37636 37638 37638 37640 37640 37645 37645 37647 37649 37652 37653 37656 37658 37660 37676 37678 37679 37682 37687 37690 37691 37694 37694 37700 37700 37703 37707 37709 37709 37712 37714 37716 37720 37722 37724 37726 37726 37728 37728 37732 37733 37735 37735 37737 37738 37740 37745 37747 37750 37754 37754 37756 37762 37768 37768 37770 37773 37775 37775 37778 37778 37780 37784 37786 37787 37790 37790 37793 37793 37795 37796 37798 37801 37803 37806 37808 37808 37812 37814 37817 37818 37825 37825 37827 37837 37840 37841 37843 37843 37846 37849 37852 37855 37857 37858 37860 37864 37878 37883 37885 37885 37889 37892 37895 37897 37901 37904 37907 37914 37919 37919 37921 37921 37925 37925 37931 37931 37934 37935 37937 37942 37944 37944 37946 37947 37949 37951 37953 37953 37955 37957 37960 37960 37962 37962 37964 37964 37969 37971 37973 37973 37977 37980 37982 37987 37992 37992 37994 37995 37997 38002 38005 38005 38007 38007 38012 38015 38017 38017 38019 38032 38034 38037 38039 38039 38041 38086 38088 38094 38096 38098 38101 38105 38107 38117 38119 38138 38140 38171 38173 38175 38177 38182 38184 38194 38196 38204 38206 38210 38212 38215 38217 38218 38220 38228 38230 38233 38235 38239 38241 38253 38255 38259 38262 38265 38270 38272 38274 38276 38279 38287 38289 38292 38294 38294 38296 38297 38301 38313 38315 38317 38321 38322 38324 38324 38326 38326 38329 38335 38339 38339 38342 38349 38352 38358 38360 38362 38364 38370 38372 38374 38376 38379 38381 38398 38400 38406 38408 38418 38420 38423 38425 38426 38428 38431 38433 38434 38436 38438 38440 38440 38442 38442 38444 38444 38446 38447 38449 38461 38463 38466 38468 38473 38475 38477 38479 38480 38482 38482 38484 38488 38491 38495 38497 38506 38508 38508 38510 38510 38512 38512 38514 38520 38522 38527 38529 38534 38536 38539 38541 38545 38548 38557 38559 38560 38563 38570 38574 38580 38582 38590 38592 38593 38596 38599 38601 38607 38609 38610 38613 38614 38616 38624 38626 38627 38632 38635 38639 38643 38646 38647 38649 38651 38654 38654 38656 38666 38669 38671 38673 38673 38675 38675 38678 38678 38681 38686 38689 38692 38695 38696 38698 38698 38701 38701 38704 38707 38712 38713 38717 38718 38721 38724 38726 38726 38728 38730 38734 38735 38737 38739 38741 38748 38750 38750 38752 38763 38765 38766 38769 38769 38771 38772 38774 38781 38783 38785 38788 38790 38793 38793 38795 38795 38797 38797 38799 38802 38804 38810 38812 38812 38814 38816 38818 38819 38822 38822 38824 38824 38827 38831 38833 38838 38840 38842 38844 38844 38846 38847 38849 38849 38851 38862 38864 38865 38867 38868 38871 38873 38875 38878 38880 38881 38884 38884 38886 38887 38889 38895 38897 38904 38906 38907 38911 38915 38917 38920 38922 38922 38924 38932 38934 38938 38940 38940 38942 38942 38944 38945 38947 38950 38955 38960 38962 38965 38967 38969 38971 38974 38980 38980 38982 38983 38986 38991 38993 39003 39006 39006 39010 39011 39013 39015 39018 39020 39023 39025 39027 39050 39052 39053 39055 39057 39059 39060 39062 39064 39066 39074 39076 39080 39082 39083 39085 39089 39092 39092 39094 39096 39098 39099 39103 39103 39106 39112 39116 39116 39118 39118 39121 39123 39125 39125 39128 39132 39134 39135 39137 39139 39141 39147 39149 39151 39154 39156 39158 39158 39164 39166 39170 39171 39173 39173 39175 39178 39180 39181 39184 39192 39194 39202 39204 39204 39206 39208 39211 39212 39214 39214 39217 39221 39225 39230 39232 39234 39237 39241 39243 39246 39248 39250 39252 39253 39255 39257 39259 39260 39262 39264 39267 39267 39269 39269 39271 39282 39284 39287 39290 39290 39292 39293 39295 39297 39300 39304 39306 39307 39309 39309 39311 39321 39323 39323 39325 39325 39327 39327 39333 39334 39336 39336 39340 39342 39344 39349 39353 39354 39356 39357 39359 39359 39361 39361 39363 39366 39368 39369 39376 39381 39384 39391 39394 39394 39399 39399 39402 39406 39408 39410 39412 39413 39416 39417 39419 39419 39421 39423 39425 39429 39432 39432 39435 39436 39438 39443 39446 39446 39449 39449 39454 39454 39456 39456 39458 39460 39463 39464 39467 39467 39469 39470 39472 39472 39475 39475 39477 39480 39486 39486 39488 39493 39495 39495 39498 39502 39505 39505 39508 39511 39514 39515 39517 39517 39519 39519 39522 39522 39524 39525 39529 39537 39539 39554 39556 39560 39562 39564 39567 39571 39574 39576 39578 39589 39591 39592 39594 39594 39596 39602 39604 39612 39614 39622 39624 39624 39627 39628 39630 39640 39643 39644 39646 39655 39657 39663 39665 39669 39671 39671 39673 39675 39677 39677 39679 39686 39688 39689 39691 39696 39698 39699 39702 39702 39704 39708 39711 39712 39714 39715 39717 39723 39725 39727 39729 39733 39735 39735 39737 39741 39745 39749 39751 39753 39755 39759 39761 39761 39764 39768 39770 39771 39774 39774 39777 39777 39779 39779 39781 39782 39784 39784 39786 39791 39795 39797 39799 39801 39807 39808 39811 39815 39817 39819 39821 39828 39830 39831 39834 39834 39837 39840 39846 39854 39856 39858 39860 39860 39863 39865 39867 39868 39870 39873 39878 39882 39886 39890 39892 39892 39894 39896 39899 39899 39901 39901 39903 39903 39905 39909 39911 39912 39914 39915 39919 39923 39925 39925 39927 39930 39933 39933 39935 39936 39938 39938 39940 39940 39942 39942 39944 39949 39951 39958 39960 39964 39966 39966 39969 39978 39981 39986 39989 39991 39993 39995 39997 39998 40001 40001 40003 40010 40014 40016 40018 40020 40022 40024 40026 40032 40035 40035 40039 40043 40046 40046 40048 40048 40050 40050 40053 40056 40059 40060 40063 40063 40065 40066 40069 40072 40075 40075 40077 40078 40080 40082 40084 40085 40090 40092 40094 40105 40107 40107 40109 40110 40112 40120 40122 40125 40131 40135 40138 40144 40147 40153 40156 40159 40162 40162 40165 40167 40169 40169 40171 40172 40176 40176 40178 40180 40182 40183 40185 40185 40194 40195 40198 40201 40203 40203 40206 40206 40209 40210 40213 40213 40215 40216 40219 40223 40227 40227 40230 40230 40232 40232 40234 40236 40239 40240 40242 40244 40250 40255 40257 40264 40266 40266 40272 40273 40275 40276 40281 40281 40284 40293 40297 40300 40303 40304 40306 40306 40310 40311 40314 40316 40318 40318 40323 40324 40326 40327 40329 40330 40333 40335 40338 40339 40341 40344 40346 40346 40353 40353 40356 40356 40361 40364 40366 40367 40369 40370 40372 40373 40376 40380 40383 40383 40385 40388 40390 40391 40393 40394 40399 40399 40403 40407 40409 40410 40414 40416 40421 40423 40425 40425 40427 40427 40429 40432 40434 40436 40440 40442 40445 40446 40450 40450 40455 40455 40458 40458 40462 40462 40464 40466 40469 40470 40473 40483 40485 40486 40488 40493 40495 40495 40497 40499 40501 40506 40509 40511 40513 40524 40526 40527 40529 40529 40533 40533 40535 40536 40538 40540 40542 40542 40547 40548 40550 40557 40560 40561 40563 40563 40565 40565 40568 40581 40583 40584 40587 40588 40590 40591 40593 40595 40597 40600 40603 40603 40605 40607 40612 40614 40616 40618 40620 40624 40627 40629 40632 40639 40643 40644 40646 40646 40648 40649 40651 40658 40660 40661 40664 40665 40667 40672 40674 40674 40676 40677 40679 40682 40684 40690 40692 40697 40699 40703 40706 40707 40711 40713 40715 40715 40717 40727 40729 40731 40735 40738 40742 40742 40746 40748 40751 40751 40753 40754 40756 40756 40759 40759 40761 40767 40769 40769 40771 40775 40778 40779 40782 40792 40794 40794 40797 40803 40806 40810 40812 40819 40821 40823 40826 40826 40829 40829 40831 40832 40835 40845 40847 40850 40852 40855 40857 40867 40869 40869 44032 44033 44036 44036 44039 44042 44048 44055 44057 44061 44064 44064 44068 44068 44076 44077 44079 44081 44088 44089 44092 44092 44096 44096 44107 44107 44109 44109 44116 44116 44120 44120 44124 44124 44144 44145 44148 44148 44151 44152 44154 44154 44160 44161 44163 44166 44169 44172 44176 44176 44180 44180 44188 44189 44191 44193 44200 44202 44204 44204 44207 44208 44216 44217 44219 44221 44225 44225 44228 44228 44232 44232 44236 44236 44245 44245 44247 44247 44256 44257 44260 44260 44263 44264 44266 44266 44268 44268 44271 44273 44275 44275 44277 44278 44284 44285 44288 44288 44292 44292 44294 44294 44300 44301 44303 44303 44305 44305 44312 44312 44316 44316 44320 44320 44329 44329 44332 44333 44340 44341 44344 44344 44348 44348 44356 44357 44359 44359 44361 44361 44368 44368 44372 44372 44376 44376 44385 44385 44387 44387 44396 44397 44400 44400 44403 44406 44411 44413 44415 44415 44417 44418 44424 44425 44428 44428 44432 44432 44444 44445 44452 44452 44471 44471 44480 44481 44484 44484 44488 44488 44496 44497 44499 44499 44508 44508 44512 44512 44516 44516 44536 44537 44540 44540 44543 44545 44552 44553 44555 44555 44557 44557 44564 44564 44592 44593 44596 44596 44599 44600 44602 44602 44608 44609 44611 44611 44613 44614 44618 44618 44620 44622 44624 44624 44628 44628 44630 44630 44636 44637 44639 44641 44645 44645 44648 44649 44652 44652 44656 44656 44664 44665 44667 44669 44676 44677 44684 44684 44732 44734 44736 44736 44740 44740 44748 44749 44751 44753 44760 44761 44764 44764 44776 44776 44779 44779 44781 44781 44788 44788 44792 44792 44796 44796 44807 44808 44813 44813 44816 44816 44844 44845 44848 44848 44850 44850 44852 44852 44860 44861 44863 44863 44865 44867 44872 44873 44880 44880 44892 44893 44900 44901 44921 44921 44928 44928 44932 44932 44936 44936 44944 44945 44949 44949 44956 44956 44984 44985 44988 44988 44992 44992 44999 45001 45003 45003 45005 45006 45012 45012 45020 45020 45032 45033 45040 45041 45044 45044 45048 45048 45056 45057 45060 45060 45068 45068 45072 45072 45076 45076 45084 45085 45096 45096 45124 45125 45128 45128 45130 45130 45132 45132 45134 45134 45139 45141 45143 45143 45145 45145 45149 45149 45180 45181 45184 45184 45188 45188 45196 45197 45199 45199 45201 45201 45208 45210 45212 45212 45215 45218 45224 45225 45227 45231 45233 45233 45235 45237 45240 45240 45244 45244 45252 45253 45255 45257 45264 45265 45268 45268 45272 45272 45280 45280 45285 45285 45320 45321 45323 45324 45328 45328 45330 45331 45336 45337 45339 45341 45347 45349 45352 45352 45356 45356 45364 45365 45367 45369 45376 45377 45380 45380 45384 45384 45392 45393 45396 45397 45400 45400 45404 45404 45408 45408 45432 45433 45436 45436 45440 45440 45442 45442 45448 45449 45451 45451 45453 45453 45458 45460 45464 45464 45468 45468 45480 45480 45516 45516 45520 45520 45524 45524 45532 45533 45535 45535 45544 45545 45548 45548 45552 45552 45561 45561 45563 45563 45565 45565 45572 45573 45576 45576 45579 45580 45588 45589 45591 45591 45593 45593 45600 45600 45620 45620 45628 45628 45656 45656 45660 45660 45664 45664 45672 45673 45684 45685 45692 45692 45700 45701 45705 45705 45712 45713 45716 45716 45720 45722 45728 45729 45731 45731 45733 45734 45738 45738 45740 45740 45744 45744 45748 45748 45768 45769 45772 45772 45776 45776 45778 45778 45784 45785 45787 45787 45789 45789 45794 45794 45796 45798 45800 45800 45803 45807 45811 45813 45815 45819 45823 45825 45828 45828 45832 45832 45840 45841 45843 45845 45852 45852 45908 45910 45912 45912 45915 45916 45918 45919 45924 45925 45927 45927 45929 45929 45931 45931 45934 45934 45936 45937 45940 45940 45944 45944 45952 45953 45955 45957 45964 45964 45968 45968 45972 45972 45984 45985 45992 45992 45996 45996 46020 46021 46024 46024 46027 46028 46030 46030 46032 46032 46036 46037 46039 46039 46041 46041 46043 46043 46045 46045 46048 46048 46052 46052 46056 46056 46076 46076 46096 46096 46104 46104 46108 46108 46112 46112 46120 46121 46123 46123 46132 46132 46160 46161 46164 46164 46168 46168 46176 46177 46179 46179 46181 46181 46188 46188 46208 46208 46216 46216 46237 46237 46244 46244 46248 46248 46252 46252 46261 46261 46263 46263 46265 46265 46272 46272 46276 46276 46280 46280 46288 46288 46293 46293 46300 46301 46304 46304 46307 46308 46310 46310 46316 46317 46319 46319 46321 46321 46328 46328 46356 46357 46360 46360 46363 46364 46372 46373 46375 46378 46384 46385 46388 46388 46392 46392 46400 46401 46403 46405 46411 46413 46416 46416 46420 46420 46428 46429 46431 46433 46496 46497 46500 46500 46504 46504 46506 46507 46512 46513 46515 46517 46523 46525 46528 46528 46532 46532 46540 46541 46543 46545 46552 46552 46572 46572 46608 46609 46612 46612 46616 46616 46629 46629 46636 46636 46644 46644 46664 46664 46692 46692 46696 46696 46748 46749 46752 46752 46756 46756 46763 46764 46769 46769 46804 46804 46832 46832 46836 46836 46840 46840 46848 46849 46853 46853 46888 46889 46892 46892 46895 46896 46904 46905 46907 46907 46916 46916 46920 46920 46924 46924 46932 46933 46944 46944 46948 46948 46952 46952 46960 46961 46963 46963 46965 46965 46972 46973 46976 46976 46980 46980 46988 46989 46991 46994 46998 47001 47004 47004 47008 47008 47016 47017 47019 47021 47028 47029 47032 47032 47047 47047 47049 47049 47084 47085 47088 47088 47092 47092 47100 47101 47103 47105 47111 47113 47116 47116 47120 47120 47128 47129 47131 47131 47133 47133 47140 47141 47144 47144 47148 47148 47156 47157 47159 47161 47168 47168 47172 47172 47185 47185 47187 47187 47196 47197 47200 47200 47204 47204 47212 47213 47215 47215 47217 47217 47224 47224 47228 47228 47245 47245 47272 47272 47280 47280 47284 47284 47288 47288 47296 47297 47299 47299 47301 47301 47308 47308 47312 47312 47316 47316 47325 47325 47327 47327 47329 47329 47336 47337 47340 47340 47344 47344 47352 47353 47355 47355 47357 47357 47364 47364 47384 47384 47392 47392 47420 47421 47424 47424 47428 47428 47436 47436 47439 47439 47441 47441 47448 47449 47452 47452 47456 47456 47464 47465 47467 47467 47469 47469 47476 47477 47480 47480 47484 47484 47492 47493 47495 47495 47497 47498 47501 47502 47532 47533 47536 47536 47540 47540 47548 47549 47551 47551 47553 47553 47560 47561 47564 47564 47566 47570 47576 47577 47579 47579 47581 47582 47585 47585 47587 47589 47592 47592 47596 47596 47604 47605 47607 47610 47616 47617 47624 47624 47637 47637 47672 47673 47676 47676 47680 47680 47682 47682 47688 47689 47691 47691 47693 47694 47699 47701 47704 47704 47708 47708 47716 47717 47719 47721 47728 47729 47732 47732 47736 47736 47747 47749 47751 47751 47756 47756 47784 47785 47787 47788 47792 47792 47794 47794 47800 47801 47803 47803 47805 47805 47812 47812 47816 47816 47832 47833 47868 47868 47872 47872 47876 47876 47885 47885 47887 47887 47889 47889 47896 47896 47900 47900 47904 47904 47913 47913 47915 47915 47924 47926 47928 47928 47931 47934 47940 47941 47943 47943 47945 47945 47949 47949 47951 47952 47956 47956 47960 47960 47969 47969 47971 47971 47980 47980 48008 48008 48012 48012 48016 48016 48036 48036 48040 48040 48044 48044 48052 48052 48055 48055 48064 48064 48068 48068 48072 48072 48080 48080 48083 48083 48120 48121 48124 48124 48127 48128 48130 48130 48136 48137 48139 48141 48143 48143 48145 48145 48148 48152 48155 48159 48164 48165 48167 48167 48169 48169 48173 48173 48176 48177 48180 48180 48184 48184 48192 48193 48195 48197 48201 48201 48204 48205 48208 48208 48221 48221 48260 48261 48264 48264 48267 48268 48270 48270 48276 48277 48279 48279 48281 48282 48288 48289 48292 48292 48295 48296 48304 48305 48307 48309 48316 48317 48320 48320 48324 48324 48333 48333 48335 48337 48341 48341 48344 48344 48348 48348 48372 48374 48376 48376 48380 48380 48388 48389 48391 48391 48393 48393 48400 48400 48404 48404 48420 48420 48428 48428 48448 48448 48456 48457 48460 48460 48464 48464 48472 48473 48484 48484 48488 48488 48512 48513 48516 48516 48519 48522 48528 48529 48531 48531 48533 48533 48537 48538 48540 48540 48548 48548 48560 48560 48568 48568 48596 48597 48600 48600 48604 48604 48617 48617 48624 48624 48628 48628 48632 48632 48640 48640 48643 48643 48645 48645 48652 48653 48656 48656 48660 48660 48668 48669 48671 48671 48708 48709 48712 48712 48716 48716 48718 48718 48724 48725 48727 48727 48729 48731 48736 48737 48740 48740 48744 48744 48746 48746 48752 48753 48755 48757 48763 48765 48768 48768 48772 48772 48780 48781 48783 48785 48792 48793 48808 48808 48848 48849 48852 48852 48855 48856 48864 48864 48867 48869 48876 48876 48897 48897 48904 48905 48920 48921 48923 48925 48960 48961 48964 48964 48968 48968 48976 48977 48981 48981 49044 49044 49072 49072 49093 49093 49100 49101 49104 49104 49108 49108 49116 49116 49119 49119 49121 49121 49212 49212 49233 49233 49240 49240 49244 49244 49248 49248 49256 49257 49296 49297 49300 49300 49304 49304 49312 49313 49315 49315 49317 49317 49324 49325 49327 49328 49331 49334 49340 49341 49343 49345 49349 49349 49352 49353 49356 49356 49360 49360 49368 49369 49371 49373 49380 49381 49384 49384 49388 49388 49396 49397 49399 49399 49401 49401 49408 49408 49412 49412 49416 49416 49424 49424 49429 49429 49436 49440 49443 49444 49446 49447 49452 49453 49455 49457 49462 49462 49464 49465 49468 49468 49472 49472 49480 49481 49483 49485 49492 49493 49496 49496 49500 49500 49508 49509 49511 49513 49520 49520 49524 49524 49528 49528 49541 49541 49548 49550 49552 49552 49556 49556 49558 49558 49564 49565 49567 49567 49569 49569 49573 49573 49576 49577 49580 49580 49584 49584 49597 49597 49604 49604 49608 49608 49612 49612 49620 49620 49623 49624 49632 49632 49636 49636 49640 49640 49648 49649 49651 49651 49660 49661 49664 49664 49668 49668 49676 49677 49679 49679 49681 49681 49688 49689 49692 49692 49695 49696 49704 49705 49707 49707 49709 49709 49711 49711 49713 49714 49716 49716 49736 49736 49744 49745 49748 49748 49752 49752 49760 49760 49765 49765 49772 49773 49776 49776 49780 49780 49788 49789 49791 49791 49793 49793 49800 49801 49808 49808 49816 49816 49819 49819 49821 49821 49828 49829 49832 49832 49836 49837 49844 49845 49847 49847 49849 49849 49884 49885 49888 49888 49891 49892 49899 49901 49903 49903 49905 49905 49910 49910 49912 49913 49915 49916 49920 49920 49928 49929 49932 49933 49939 49941 49944 49944 49948 49948 49956 49957 49960 49961 49989 49989 50024 50025 50028 50028 50032 50032 50034 50034 50040 50041 50044 50045 50052 50052 50056 50056 50060 50060 50112 50112 50136 50137 50140 50140 50143 50144 50146 50146 50152 50153 50157 50157 50164 50165 50168 50168 50184 50184 50192 50192 50212 50212 50220 50220 50224 50224 50228 50228 50236 50237 50248 50248 50276 50277 50280 50280 50284 50284 50292 50293 50297 50297 50304 50304 50324 50324 50332 50332 50360 50360 50364 50364 50409 50409 50416 50417 50420 50420 50424 50424 50426 50426 50431 50433 50444 50444 50448 50448 50452 50452 50460 50460 50472 50473 50476 50476 50480 50480 50488 50489 50491 50491 50493 50493 50500 50501 50504 50506 50508 50510 50515 50517 50519 50521 50525 50526 50528 50529 50532 50532 50536 50536 50544 50545 50547 50549 50556 50557 50560 50560 50564 50564 50567 50567 50572 50573 50575 50575 50577 50577 50581 50581 50583 50584 50588 50588 50592 50592 50601 50601 50612 50613 50616 50617 50619 50622 50628 50634 50636 50636 50638 50638 50640 50641 50644 50644 50648 50648 50656 50657 50659 50659 50661 50661 50668 50670 50672 50672 50676 50676 50678 50679 50684 50689 50693 50696 50700 50700 50704 50704 50712 50713 50715 50716 50724 50725 50728 50728 50732 50734 50736 50736 50739 50741 50743 50743 50745 50745 50747 50747 50752 50753 50756 50756 50760 50760 50768 50769 50771 50773 50780 50781 50784 50784 50796 50796 50799 50799 50801 50801 50808 50809 50812 50812 50816 50816 50824 50825 50827 50827 50829 50829 50836 50837 50840 50840 50844 50844 50852 50853 50855 50855 50857 50857 50864 50865 50868 50868 50872 50874 50880 50881 50883 50883 50885 50885 50892 50893 50896 50896 50900 50900 50908 50909 50912 50913 50920 50921 50924 50924 50928 50928 50936 50937 50941 50941 50948 50949 50952 50952 50956 50956 50964 50965 50967 50967 50969 50969 50976 50977 50980 50980 50984 50984 50992 50993 50995 50995 50997 50997 50999 50999 51004 51005 51008 51008 51012 51012 51018 51018 51020 51021 51023 51023 51025 51032 51036 51036 51040 51040 51048 51048 51051 51051 51060 51061 51064 51064 51068 51070 51075 51077 51079 51082 51086 51086 51088 51089 51092 51092 51094 51096 51098 51098 51104 51105 51107 51110 51116 51117 51120 51120 51124 51124 51132 51133 51135 51137 51144 51145 51148 51148 51150 51150 51152 51152 51160 51160 51165 51165 51172 51172 51176 51176 51180 51180 51200 51201 51204 51204 51208 51208 51210 51210 51216 51217 51219 51219 51221 51222 51228 51229 51232 51232 51236 51236 51244 51245 51247 51247 51249 51249 51256 51256 51260 51260 51264 51264 51272 51273 51276 51277 51284 51284 51312 51313 51316 51316 51320 51320 51322 51322 51328 51329 51331 51331 51333 51335 51339 51341 51348 51348 51357 51357 51359 51359 51361 51361 51368 51368 51388 51389 51396 51396 51400 51400 51404 51404 51412 51413 51415 51415 51417 51417 51424 51425 51428 51428 51445 51445 51452 51453 51456 51456 51460 51462 51468 51469 51471 51471 51473 51473 51480 51480 51500 51500 51508 51508 51536 51537 51540 51540 51544 51544 51552 51553 51555 51555 51564 51564 51568 51568 51572 51572 51580 51580 51592 51593 51596 51596 51600 51600 51608 51609 51611 51611 51613 51613 51648 51649 51652 51652 51655 51656 51658 51658 51664 51665 51667 51667 51669 51670 51673 51674 51676 51677 51680 51680 51682 51682 51684 51684 51687 51687 51692 51693 51695 51697 51704 51705 51708 51708 51712 51712 51720 51721 51723 51725 51732 51732 51736 51736 51753 51753 51788 51789 51792 51792 51796 51796 51804 51805 51807 51809 51816 51816 51837 51837 51844 51844 51864 51864 51900 51901 51904 51904 51908 51908 51916 51917 51919 51919 51921 51921 51923 51923 51928 51929 51936 51936 51948 51948 51956 51956 51976 51976 51984 51984 51988 51988 51992 51992 52000 52001 52033 52033 52040 52041 52044 52044 52048 52048 52056 52057 52061 52061 52068 52068 52088 52089 52124 52124 52152 52152 52180 52180 52196 52196 52199 52199 52201 52201 52236 52237 52240 52240 52244 52244 52252 52253 52257 52258 52263 52265 52268 52268 52270 52270 52272 52272 52280 52281 52283 52286 52292 52293 52296 52296 52300 52300 52308 52309 52311 52313 52320 52320 52324 52324 52326 52326 52328 52328 52336 52336 52341 52341 52376 52377 52380 52380 52384 52384 52392 52393 52395 52397 52404 52405 52408 52408 52412 52412 52420 52421 52423 52423 52425 52425 52432 52432 52436 52436 52452 52452 52460 52460 52464 52464 52481 52481 52488 52489 52492 52492 52496 52496 52504 52505 52507 52507 52509 52509 52516 52516 52520 52520 52524 52524 52537 52537 52572 52572 52576 52576 52580 52580 52588 52589 52591 52591 52593 52593 52600 52600 52616 52616 52628 52629 52632 52632 52636 52636 52644 52645 52647 52647 52649 52649 52656 52656 52676 52676 52684 52684 52688 52688 52712 52712 52716 52716 52720 52720 52728 52729 52731 52731 52733 52733 52740 52740 52744 52744 52748 52748 52756 52756 52761 52761 52768 52769 52772 52772 52776 52776 52784 52785 52787 52787 52789 52789 52824 52825 52828 52828 52831 52833 52840 52841 52843 52843 52845 52845 52852 52853 52856 52856 52860 52860 52868 52869 52871 52871 52873 52873 52880 52881 52884 52884 52888 52888 52896 52897 52899 52901 52908 52909 52929 52929 52964 52965 52968 52968 52971 52972 52980 52981 52983 52985 52992 52993 52996 52996 53000 53000 53008 53009 53011 53011 53013 53013 53020 53020 53024 53024 53028 53028 53036 53037 53039 53041 53048 53048 53076 53077 53080 53080 53084 53084 53092 53093 53095 53095 53097 53097 53104 53105 53108 53108 53112 53112 53120 53120 53125 53125 53132 53132 53153 53153 53160 53160 53168 53168 53188 53188 53216 53217 53220 53220 53224 53224 53232 53233 53235 53235 53237 53237 53244 53244 53248 53248 53252 53252 53265 53265 53272 53272 53293 53293 53300 53301 53304 53304 53308 53308 53316 53317 53319 53319 53321 53321 53328 53328 53332 53332 53336 53336 53344 53344 53356 53357 53360 53360 53364 53364 53372 53373 53377 53377 53412 53413 53416 53416 53420 53420 53428 53429 53431 53431 53433 53433 53440 53441 53444 53444 53448 53449 53456 53457 53459 53461 53468 53469 53472 53472 53476 53476 53484 53485 53487 53489 53496 53496 53517 53517 53552 53553 53556 53556 53560 53560 53562 53562 53568 53569 53571 53573 53580 53581 53584 53584 53588 53588 53596 53597 53599 53599 53601 53601 53608 53608 53612 53612 53628 53628 53636 53636 53640 53640 53664 53665 53668 53668 53672 53672 53680 53681 53683 53683 53685 53685 53690 53690 53692 53692 53696 53696 53720 53720 53748 53748 53752 53752 53767 53767 53769 53769 53776 53776 53804 53805 53808 53808 53812 53812 53820 53821 53823 53823 53825 53825 53832 53832 53852 53852 53860 53860 53888 53889 53892 53892 53896 53896 53904 53905 53909 53909 53916 53916 53920 53920 53924 53924 53932 53932 53937 53937 53944 53945 53948 53948 53951 53952 53954 53954 53960 53961 53963 53963 53972 53972 53976 53976 53980 53980 53988 53989 54000 54001 54004 54004 54008 54008 54016 54017 54019 54019 54021 54021 54028 54030 54032 54032 54036 54036 54038 54038 54044 54045 54047 54049 54053 54053 54056 54057 54060 54060 54064 54064 54072 54073 54075 54077 54084 54085 54140 54141 54144 54144 54148 54148 54156 54157 54159 54161 54168 54169 54172 54172 54176 54176 54184 54185 54187 54187 54189 54189 54196 54196 54200 54200 54204 54204 54212 54213 54216 54217 54224 54224 54232 54232 54241 54241 54243 54243 54252 54253 54256 54256 54260 54260 54268 54269 54271 54271 54273 54273 54280 54280 54301 54301 54336 54336 54340 54340 54364 54364 54368 54368 54372 54372 54381 54381 54383 54383 54392 54393 54396 54396 54399 54400 54402 54402 54408 54409 54411 54411 54413 54413 54420 54420 54441 54441 54476 54476 54480 54480 54484 54484 54492 54492 54495 54495 54504 54504 54508 54508 54512 54512 54520 54520 54523 54523 54525 54525 54532 54532 54536 54536 54540 54540 54548 54549 54551 54551 54588 54589 54592 54592 54596 54596 54604 54605 54607 54607 54609 54609 54616 54617 54620 54620 54624 54624 54629 54629 54632 54633 54635 54635 54637 54637 54644 54645 54648 54648 54652 54652 54660 54661 54663 54665 54672 54672 54693 54693 54728 54729 54732 54732 54736 54736 54738 54738 54744 54745 54747 54747 54749 54749 54756 54757 54760 54760 54764 54764 54772 54773 54775 54775 54777 54777 54784 54785 54788 54788 54792 54792 54800 54801 54803 54805 54812 54812 54816 54816 54820 54820 54829 54829 54840 54841 54844 54844 54848 54848 54853 54853 54856 54857 54859 54859 54861 54861 54865 54865 54868 54869 54872 54872 54876 54876 54887 54887 54889 54889 54896 54897 54900 54900 54915 54915 54917 54917 54924 54925 54928 54928 54932 54932 54941 54941 54943 54943 54945 54945 54952 54952 54956 54956 54960 54960 54969 54969 54971 54971 54980 54981 54984 54984 54988 54988 54993 54993 54996 54996 54999 54999 55001 55001 55008 55008 55012 55012 55016 55016 55024 55024 55029 55029 55036 55037 55040 55040 55044 55044 55057 55057 55064 55065 55068 55068 55072 55072 55080 55081 55083 55083 55085 55085 55092 55093 55096 55096 55100 55100 55108 55108 55111 55111 55113 55113 55120 55121 55124 55124 55126 55129 55136 55137 55139 55139 55141 55141 55145 55145 55148 55148 55152 55152 55156 55156 55164 55165 55169 55169 55176 55177 55180 55180 55184 55184 55192 55193 55195 55195 55197 55197 63744 64011 65281 65374 65377 65439 65504 65507 65509 65510 917504 917631)) (make-character-set :mib-enum 2259 :name "TIS-620" :aliases 'nil :mime-encoding 'nil :source '"Thai Industrial Standards Institute (TISI) [Tantsetthi]" :comments 'nil :references 'nil :ranges #(0 127 3585 3642 3647 3675 917504 917631)) (make-character-set :mib-enum 8 :name "ISO_8859-5:1988" :aliases '("csISOLatinCyrillic" "cyrillic" #8="ISO-8859-5" "ISO_8859-5" "iso-ir-144") :mime-encoding '#8# :source '"ECMA registry" :comments '("Alias: ISO-8859-5 (preferred MIME name)") :references '("[RFC1345,KXS2]") :ranges #(0 160 167 167 173 173 1025 1036 1038 1103 1105 1116 1118 1119 8470 8470)) (make-character-set :mib-enum 9 :name "ISO_8859-6:1987" :aliases '("csISOLatinArabic" "arabic" "ASMO-708" "ECMA-114" #9="ISO-8859-6" "ISO_8859-6" "iso-ir-127") :mime-encoding '#9# :source '"ECMA registry" :comments '("Alias: ISO-8859-6 (preferred MIME name)") :references '("[RFC1345,KXS2]") :ranges #(0 160 164 164 173 173 1548 1548 1563 1563 1567 1567 1569 1594 1600 1618)) (make-character-set :mib-enum 2046 :name "IBM855" :aliases '("csIBM855" "855" "cp855") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges #(0 127 160 160 164 164 167 167 171 171 173 173 187 187 1025 1036 1038 1103 1105 1116 1118 1119 8470 8470 9472 9472 9474 9474 9484 9484 9488 9488 9492 9492 9496 9496 9500 9500 9508 9508 9516 9516 9524 9524 9532 9532 9552 9553 9556 9556 9559 9559 9562 9562 9565 9565 9568 9568 9571 9571 9574 9574 9577 9577 9580 9580 9600 9600 9604 9604 9608 9608 9617 9619 9632 9632)) (make-character-set :mib-enum 10 :name "ISO_8859-7:1987" :aliases '("csISOLatinGreek" "greek8" "greek" "ECMA-118" "ELOT_928" #10="ISO-8859-7" "ISO_8859-7" "iso-ir-126") :mime-encoding '#10# :source '"ECMA registry" :comments '("Alias: ISO-8859-7 (preferred MIME name)") :references '("[RFC1947,RFC1345,KXS2]") :ranges #(0 160 163 163 166 169 171 173 176 179 183 183 187 187 189 189 890 890 900 902 904 906 908 908 910 929 931 974 8213 8213 8216 8217 8364 8364 8367 8367)) (make-character-set :mib-enum 13 :name #11="ISO-8859-10" :aliases '("latin6" "csISOLatin6" "ISO_8859-10:1992" "l6" "iso-ir-157") :mime-encoding '#11# :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges #(0 160 167 167 173 173 176 176 183 183 193 198 201 201 203 203 205 208 211 214 216 216 218 223 225 230 233 233 235 235 237 240 243 246 248 248 250 254 256 257 260 261 268 269 272 275 278 281 290 291 296 299 302 303 310 312 315 316 325 326 330 333 352 353 358 363 370 371 381 382 8213 8213)) (make-character-set :mib-enum 4 :name "ISO_8859-1:1987" :aliases '("csISOLatin1" "CP819" "IBM819" "l1" "latin1" #12="ISO-8859-1" "ISO_8859-1" "iso-ir-100") :mime-encoding '#12# :source '"ECMA registry" :comments '("Alias: ISO-8859-1 (preferred MIME name)") :references '("[RFC1345,KXS2]") :ranges #(0 255)) (make-character-set :mib-enum 106 :name "UTF-8" :aliases 'nil :mime-encoding 'nil :source '"RFC 3629" :comments 'nil :references '("[RFC3629]") :ranges #(0 1114111)) (make-character-set :mib-enum 105 :name "ISO-2022-CN-EXT" :aliases 'nil :mime-encoding 'nil :source '"RFC-1922" :comments 'nil :references '("[RFC1922]") :ranges #(0 127 162 165 167 168 176 177 183 183 215 215 224 225 232 234 236 237 242 243 247 247 249 250 252 252 257 257 275 275 283 283 299 299 324 324 328 328 333 333 363 363 462 462 464 464 466 466 468 468 470 470 472 472 474 474 476 476 593 593 609 609 711 711 713 715 729 729 913 929 931 937 945 961 963 969 1025 1025 1040 1103 1105 1105 7743 7743 8211 8214 8216 8217 8220 8221 8229 8230 8240 8240 8242 8243 8245 8245 8251 8251 8254 8254 8451 8451 8453 8453 8457 8457 8470 8470 8544 8555 8560 8569 8592 8595 8598 8601 8712 8712 8719 8719 8721 8721 8725 8725 8730 8730 8733 8736 8741 8741 8743 8747 8750 8750 8756 8759 8764 8765 8776 8776 8780 8780 8786 8786 8800 8801 8804 8807 8814 8815 8857 8857 8869 8869 8895 8895 8978 8978 9216 9247 9249 9249 9312 9321 9332 9371 9472 9547 9552 9552 9566 9566 9569 9569 9578 9578 9581 9587 9601 9615 9620 9621 9632 9633 9650 9651 9660 9661 9670 9671 9675 9675 9678 9679 9698 9701 9733 9734 9737 9737 9792 9794 12288 12291 12293 12293 12296 12311 12317 12318 12321 12329 12343 12343 12353 12435 12449 12534 12539 12539 12549 12585 12832 12841 12963 12963 12992 13003 13144 13168 13198 13199 13212 13214 13217 13217 13252 13252 13262 13262 13265 13266 13269 13269 13280 13310 13312 13313 13316 13317 13324 13324 13334 13334 13340 13340 13345 13345 13348 13348 13352 13353 13355 13358 13360 13364 13368 13372 13377 13381 13385 13393 13399 13407 13411 13415 13422 13425 13427 13431 13433 13454 13457 13463 13465 13473 13476 13483 13485 13485 13487 13488 13490 13503 13506 13509 13511 13516 13518 13521 13523 13528 13530 13540 13543 13545 13548 13551 13553 13566 13568 13575 13578 13587 13589 13589 13591 13594 13596 13598 13600 13610 13612 13650 13652 13660 13662 13671 13673 13683 13686 13692 13696 13703 13711 13720 13727 13738 13748 13773 13776 13776 13779 13788 13794 13805 13808 13814 13819 13826 13829 13837 13840 13841 13843 13846 13849 13869 13871 13876 13878 13883 13887 13893 13895 13898 13901 13907 13909 13909 13913 13918 13920 13925 13927 13932 13935 13948 13950 13950 13952 13957 13959 13959 13961 13968 13970 13976 13978 13978 13980 13998 14000 14015 14017 14021 14026 14026 14029 14046 14053 14078 14082 14099 14101 14110 14112 14123 14126 14149 14151 14152 14154 14154 14156 14169 14171 14176 14178 14183 14185 14194 14196 14220 14223 14236 14239 14239 14241 14253 14255 14263 14265 14273 14275 14277 14279 14292 14294 14304 14309 14317 14319 14326 14328 14338 14340 14365 14368 14370 14373 14378 14381 14383 14385 14386 14388 14395 14397 14412 14414 14432 14434 14435 14437 14443 14445 14459 14461 14470 14472 14497 14499 14499 14501 14506 14508 14508 14510 14512 14514 14518 14520 14520 14522 14526 14528 14537 14539 14548 14552 14560 14562 14562 14564 14566 14571 14573 14575 14578 14581 14583 14586 14591 14593 14614 14617 14634 14636 14636 14638 14651 14654 14678 14682 14697 14699 14714 14716 14727 14729 14744 14746 14751 14753 14768 14770 14770 14772 14798 14802 14810 14817 14831 14833 14871 14873 14890 14893 14912 14915 14926 14928 14928 14930 14942 14944 14954 14956 14957 14959 14967 14969 14978 14980 14981 14983 14985 14987 14991 14993 14995 14997 14998 15002 15002 15004 15014 15016 15017 15019 15025 15028 15036 15038 15045 15050 15051 15053 15061 15063 15073 15076 15079 15081 15083 15086 15101 15105 15120 15122 15125 15127 15134 15136 15139 15141 15143 15145 15158 15160 15161 15163 15164 15167 15167 15169 15172 15175 15176 15178 15180 15185 15189 15192 15202 15208 15218 15224 15240 15243 15263 15265 15265 15267 15267 15269 15290 15295 15312 15315 15334 15338 15347 15349 15355 15358 15366 15368 15377 15380 15387 15389 15415 15417 15439 15442 15442 15444 15452 15454 15464 15466 15469 15471 15478 15480 15503 15506 15528 15530 15533 15535 15550 15552 15560 15562 15570 15574 15582 15588 15598 15603 15626 15631 15646 15653 15672 15675 15686 15690 15705 15709 15739 15741 15745 15748 15752 15756 15759 15761 15768 15770 15772 15774 15777 15779 15780 15782 15784 15786 15792 15794 15797 15801 15804 15806 15808 15810 15819 15821 15833 15839 15846 15851 15856 15859 15865 15867 15868 15870 15877 15880 15923 15925 15934 15936 15943 15945 15975 15979 15983 15985 16005 16007 16012 16014 16024 16026 16033 16035 16046 16048 16053 16055 16058 16063 16068 16072 16078 16081 16087 16093 16097 16103 16104 16107 16114 16117 16122 16125 16127 16130 16130 16132 16132 16135 16135 16137 16196 16198 16206 16208 16210 16213 16242 16244 16245 16247 16251 16253 16304 16310 16319 16321 16335 16337 16339 16341 16351 16353 16395 16397 16412 16414 16420 16423 16447 16449 16469 16471 16480 16482 16489 16491 16522 16524 16536 16538 16551 16553 16564 16566 16578 16583 16591 16593 16606 16608 16615 16617 16622 16624 16635 16637 16649 16651 16661 16664 16669 16671 16674 16676 16690 16694 16696 16698 16711 16714 16734 16736 16745 16748 16773 16776 16779 16781 16813 16815 16819 16821 16835 16837 16841 16843 16882 16885 16894 16896 16935 16938 16966 16968 16995 16997 17035 17037 17057 17059 17092 17096 17116 17118 17162 17164 17205 17218 17230 17232 17247 17249 17306 17308 17309 17311 17316 17318 17323 17325 17364 17366 17372 17374 17388 17391 17413 17415 17449 17451 17468 17470 17493 17495 17512 17514 17517 17519 17526 17529 17533 17535 17542 17544 17552 17554 17560 17562 17581 17584 17597 17601 17619 17623 17639 17645 17658 17660 17701 17705 17729 17731 17743 17745 17755 17757 17762 17764 17781 17784 17795 17797 17835 17837 17853 17855 17877 17879 17900 17902 17906 17908 17912 17914 17914 17916 17946 17948 17949 17951 17958 17960 17969 17971 17993 17998 18002 18004 18026 18028 18037 18039 18042 18044 18068 18070 18083 18085 18091 18093 18130 18132 18210 18218 18226 18228 18248 18250 18264 18266 18266 18268 18299 18301 18310 18312 18315 18321 18353 18355 18417 18420 18443 18445 18453 18455 18457 18459 18489 18491 18499 18501 18544 18546 18551 18553 18554 18556 18559 18563 18565 18567 18571 18573 18574 18576 18582 18585 18594 18596 18617 18619 18632 18634 18641 18643 18661 18663 18674 18676 18687 18689 18722 18724 18728 18730 18737 18739 18747 18749 18758 18760 18770 18772 18779 18781 18808 18823 18824 18826 18842 18844 18856 18858 18863 18865 18869 18873 18877 18881 18887 18889 18894 18896 18920 18922 18922 18924 18924 18926 18969 18971 19011 19013 19021 19023 19030 19032 19102 19104 19113 19115 19121 19123 19278 19280 19291 19293 19305 19307 19394 19398 19432 19434 19450 19452 19462 19464 19501 19503 19506 19508 19509 19511 19560 19563 19571 19573 19590 19593 19607 19609 19612 19621 19637 19639 19684 19686 19704 19706 19730 19738 19751 19753 19884 19887 19889 19891 19893 19968 19973 19975 20022 20024 20035 20037 20041 20043 20052 20054 20058 20060 20067 20070 20070 20072 20074 20080 20081 20083 20085 20089 20089 20094 20105 20107 20111 20113 20137 20139 20156 20158 20177 20179 20204 20206 20264 20266 20387 20389 20394 20396 20396 20398 20451 20453 20538 20540 20540 20542 20721 20723 20846 20848 20857 20859 20889 20891 20902 20904 20904 20906 20965 20968 20968 20971 21093 21095 21104 21106 21134 21136 21248 21251 21376 21378 21392 21394 21428 21430 21435 21437 21497 21499 21501 21503 21523 21525 21654 21656 21659 21661 21719 21721 21722 21724 21787 21789 21789 21792 21792 21794 21796 21798 21864 21866 21880 21882 21935 21937 21943 21945 21947 21949 21996 21998 22000 22002 22041 22043 22048 22050 22052 22054 22106 22108 22108 22110 22137 22139 22176 22179 22179 22181 22221 22223 22228 22231 22247 22249 22309 22311 22326 22329 22407 22410 22441 22443 22446 22449 22450 22452 22485 22488 22549 22551 22591 22594 22637 22639 22639 22641 22709 22711 22711 22714 22730 22733 22742 22744 22756 22758 22761 22763 22764 22766 22813 22815 22842 22844 23153 23155 23281 23283 23349 23351 23389 23391 23404 23406 23440 23442 23464 23466 23496 23498 23553 23555 23589 23591 23596 23599 23601 23603 23618 23620 23669 23671 23682 23684 23739 23741 23741 23743 23745 23747 23748 23750 23775 23777 23899 23901 23925 23927 24041 24043 24043 24046 24059 24061 24136 24138 24163 24165 24291 24293 24328 24330 24335 24337 24341 24343 24384 24386 24388 24390 24411 24413 24633 24635 24637 24639 24694 24696 25075 25077 25155 25157 25172 25175 25191 25193 25367 25369 25382 25384 25524 25526 25528 25530 25530 25532 25594 25597 25603 25605 25665 25667 25820 25822 25980 25983 25989 25991 26047 26049 26068 26070 26072 26074 26174 26176 26242 26244 26361 26364 26364 26366 26408 26410 26415 26417 26432 26434 26465 26469 26469 26471 26527 26530 26533 26535 26536 26538 26625 26628 26636 26638 26710 26712 26714 26718 26718 26720 26764 26766 26809 26812 26812 26815 26901 26903 26904 26908 26912 26916 26917 26921 27005 27008 27008 27010 27017 27021 27100 27103 27178 27180 27181 27183 27183 27185 27249 27254 27255 27257 27258 27260 27336 27338 27363 27365 27382 27384 27396 27398 27403 27405 27412 27414 27422 27424 27481 27483 27568 27570 27614 27616 27629 27631 27661 27663 27670 27672 27705 27707 27719 27721 27745 27747 27979 27981 28059 28061 28178 28180 28180 28182 28281 28283 28289 28291 28299 28301 28569 28571 28664 28666 28749 28751 28751 28753 28947 28949 28968 28970 28987 28989 28989 28991 28991 28993 29012 29014 29076 29078 29172 29176 29234 29236 29275 29277 29343 29345 29470 29473 29538 29541 29680 29682 29712 29714 29714 29716 29926 29928 29935 29939 29943 29945 29947 29949 29956 29958 30003 30005 30011 30013 30033 30036 30047 30049 30056 30058 30066 30068 30081 30083 30092 30094 30124 30126 30184 30186 30213 30215 30300 30302 30309 30311 30329 30331 30475 30477 30610 30612 30663 30665 30666 30668 30782 30784 30810 30812 30833 30837 30900 30902 30934 30936 30964 30966 30997 30999 31029 31031 31219 31221 31227 31229 31267 31269 31298 31300 31311 31313 31313 31315 31324 31326 31330 31332 31426 31428 31446 31448 31489 31491 31494 31496 31544 31546 31548 31550 31609 31611 31611 31614 31641 31643 31694 31696 31697 31699 31762 31765 31766 31768 31792 31794 31822 31824 31840 31842 31869 31871 31873 31875 31886 31889 31914 31916 31916 31918 31935 31937 31959 31961 31992 31994 32037 32039 32074 32076 32153 32156 32211 32214 32260 32263 32295 32297 32329 32332 32358 32360 32386 32388 32399 32401 32571 32573 32584 32586 32594 32596 32597 32599 32681 32683 32865 32867 33034 33037 33074 33076 33076 33078 33078 33080 33109 33112 33187 33190 33205 33207 33234 33236 33243 33245 33302 33304 33325 33327 33356 33358 33363 33365 33372 33374 33375 33377 33476 33479 33624 33626 33716 33718 33722 33724 33782 33784 33816 33818 33823 33825 33825 33827 33924 33926 33929 33931 34008 34010 34011 34013 34101 34103 34220 34222 34321 34323 34323 34325 34351 34353 34371 34373 34474 34476 34508 34510 34542 34544 34627 34629 34634 34636 34686 34688 34725 34728 34767 34769 34989 34991 34991 34993 35010 35013 35014 35016 35075 35077 35099 35102 35140 35142 35142 35144 35175 35177 35190 35192 35255 35257 35328 35330 35378 35380 35500 35503 35545 35547 35616 35618 35674 35676 35697 35699 35726 35728 35791 35793 36045 36047 36324 36326 36341 36343 36365 36367 36396 36398 36476 36479 36479 36481 36506 36508 36525 36527 36532 36534 36538 36540 36541 36543 36548 36550 36551 36553 36577 36580 36619 36621 36683 36685 36713 36715 36747 36749 36790 36792 36793 36797 36825 36827 36849 36851 36902 36904 36920 36922 36949 36951 36963 36965 37073 37075 37210 37212 37221 37223 37270 37272 37283 37285 37303 37305 37319 37321 37329 37331 37344 37346 37369 37373 37415 37419 37419 37421 37488 37490 37494 37496 37550 37552 37617 37619 37689 37692 37695 37698 37699 37701 37764 37766 37766 37768 37816 37819 37822 37824 37871 37873 37920 37922 37924 37927 37952 37954 37970 37972 38215 38217 38218 38220 38228 38230 38281 38283 38293 38295 38303 38305 38313 38315 38350 38352 38373 38375 38500 38503 38521 38523 38634 38636 38731 38733 38733 38736 38768 38770 38789 38791 38799 38801 38955 38957 39081 39083 39091 39093 39108 39110 39135 39137 39149 39151 39182 39184 39265 39267 39282 39284 39304 39306 39364 39366 39409 39411 39441 39444 39463 39465 39773 39775 39799 39802 39829 39832 39856 39859 39859 39861 39885 39890 39920 39924 39924 39926 39959 39963 39982 39985 40006 40008 40025 40029 40040 40044 40047 40049 40060 40063 40066 40068 40072 40074 40075 40077 40078 40080 40105 40107 40107 40109 40110 40112 40120 40122 40125 40127 40129 40131 40135 40138 40144 40146 40153 40155 40160 40162 40163 40165 40175 40177 40205 40207 40234 40237 40261 40265 40291 40294 40332 40336 40362 40364 40389 40391 40506 40509 40542 40544 40557 40559 40561 40563 40567 40569 40632 40635 40638 40640 40736 40738 40801 40803 40869 65072 65074 65077 65092 65097 65102 65104 65106 65108 65111 65113 65126 65128 65131 65281 65374 65504 65505 65507 65507 65509 65509 131072 131072 131075 131077 131079 131081 131083 131083 131090 131090 131092 131092 131096 131098 131104 131106 131109 131109 131113 131113 131116 131118 131131 131131 131137 131137 131139 131139 131144 131144 131157 131157 131159 131159 131169 131170 131172 131175 131177 131177 131179 131179 131181 131182 131184 131186 131188 131188 131191 131191 131197 131199 131202 131202 131204 131204 131206 131208 131213 131213 131215 131215 131220 131221 131224 131225 131228 131228 131230 131230 131232 131232 131234 131237 131240 131241 131244 131244 131246 131251 131253 131255 131257 131258 131260 131263 131266 131268 131270 131270 131273 131273 131275 131275 131279 131282 131285 131286 131294 131297 131300 131301 131303 131303 131309 131309 131312 131315 131318 131318 131320 131320 131324 131326 131332 131333 131335 131343 131345 131351 131353 131355 131357 131364 131368 131368 131372 131374 131376 131377 131380 131381 131383 131383 131385 131385 131395 131395 131400 131400 131404 131404 131407 131407 131411 131412 131414 131417 131422 131427 131433 131436 131440 131440 131456 131458 131462 131463 131465 131466 131468 131468 131470 131471 131474 131474 131484 131485 131491 131492 131494 131494 131496 131497 131501 131501 131503 131504 131506 131506 131508 131516 131522 131523 131531 131531 131535 131536 131544 131550 131569 131570 131572 131572 131582 131585 131587 131601 131605 131606 131618 131618 131623 131626 131628 131647 131666 131666 131668 131670 131672 131672 131681 131694 131699 131699 131702 131702 131722 131724 131729 131730 131732 131732 131734 131734 131746 131758 131760 131771 131774 131774 131777 131778 131793 131798 131803 131803 131805 131805 131809 131811 131815 131840 131848 131849 131851 131852 131863 131864 131868 131868 131872 131873 131881 131895 131897 131900 131902 131904 131908 131908 131912 131912 131928 131928 131934 131935 131938 131938 131943 131948 131950 131963 131970 131971 131992 131995 131998 131998 132001 132002 132014 132019 132022 132036 132039 132040 132042 132042 132052 132052 132054 132055 132065 132068 132071 132080 132084 132084 132096 132096 132102 132102 132104 132110 132122 132123 132129 132136 132145 132147 132149 132150 132154 132159 132162 132162 132164 132165 132172 132174 132177 132179 132183 132187 132191 132191 132196 132196 132201 132203 132207 132207 132210 132210 132214 132215 132217 132219 132221 132225 132227 132230 132234 132234 132236 132237 132240 132240 132246 132246 132248 132249 132254 132254 132258 132258 132264 132264 132269 132269 132272 132274 132277 132278 132280 132281 132287 132287 132294 132294 132296 132296 132299 132300 132302 132303 132311 132311 132315 132317 132319 132321 132324 132325 132327 132327 132330 132331 132333 132334 132337 132337 132339 132340 132342 132344 132349 132349 132352 132356 132358 132364 132367 132368 132370 132371 132373 132381 132383 132384 132389 132389 132391 132393 132399 132399 132401 132401 132406 132406 132408 132409 132412 132414 132417 132420 132424 132424 132426 132427 132429 132430 132432 132436 132438 132438 132440 132440 132442 132443 132445 132448 132450 132457 132460 132462 132464 132464 132466 132467 132469 132469 132473 132475 132484 132484 132490 132490 132492 132492 132499 132500 132503 132503 132506 132506 132508 132508 132511 132512 132515 132515 132518 132519 132521 132521 132523 132523 132529 132529 132534 132537 132546 132550 132552 132558 132567 132573 132578 132578 132581 132584 132593 132598 132602 132608 132612 132615 132618 132621 132626 132626 132630 132632 132637 132639 132641 132645 132647 132647 132649 132649 132655 132655 132657 132659 132661 132664 132668 132670 132678 132683 132687 132690 132695 132698 132703 132704 132706 132706 132717 132717 132725 132731 132734 132737 132742 132743 132747 132747 132749 132751 132753 132754 132758 132761 132763 132763 132765 132767 132769 132769 132771 132771 132773 132778 132780 132788 132791 132804 132809 132809 132813 132827 132832 132832 132837 132850 132852 132857 132859 132859 132866 132866 132870 132871 132873 132873 132876 132876 132880 132893 132895 132896 132901 132902 132904 132904 132912 132933 132937 132937 132946 132946 132952 132955 132957 132965 132967 132970 132977 132977 132989 133008 133016 133016 133020 133021 133028 133042 133047 133047 133051 133055 133058 133080 133084 133084 133087 133087 133094 133105 133107 133107 133109 133109 133114 133127 133131 133131 133133 133136 133138 133138 133143 133143 133147 133150 133152 133155 133158 133159 133162 133163 133166 133172 133174 133177 133179 133179 133185 133188 133196 133197 133201 133205 133214 133218 133222 133222 133227 133234 133240 133241 133243 133248 133252 133257 133262 133263 133266 133271 133273 133273 133280 133287 133293 133293 133295 133300 133302 133303 133305 133308 133311 133313 133315 133327 133329 133330 133332 133332 133334 133338 133342 133345 133347 133355 133358 133361 133363 133365 133368 133370 133373 133376 133380 133381 133383 133387 133390 133397 133399 133404 133406 133407 133410 133411 133413 133413 133418 133420 133422 133425 133427 133429 133432 133434 133436 133436 133438 133444 133449 133452 133454 133454 133456 133459 133462 133462 133465 133470 133474 133475 133478 133478 133481 133484 133486 133489 133492 133494 133496 133496 133498 133499 133501 133502 133504 133504 133506 133507 133509 133512 133516 133517 133521 133525 133528 133532 133538 133540 133546 133548 133556 133559 133568 133568 133572 133572 133576 133576 133582 133585 133587 133588 133591 133596 133598 133605 133608 133611 133618 133629 133632 133635 133637 133640 133643 133643 133645 133646 133648 133648 133650 133652 133654 133654 133656 133664 133666 133667 133669 133669 133671 133671 133676 133682 133684 133691 133696 133700 133706 133711 133718 133728 133732 133732 133734 133746 133752 133757 133759 133759 133764 133764 133766 133773 133775 133775 133777 133781 133784 133791 133796 133798 133802 133803 133805 133808 133811 133811 133817 133820 133823 133823 133832 133833 133836 133836 133838 133838 133840 133840 133842 133845 133847 133847 133849 133850 133854 133856 133860 133862 133864 133868 133872 133873 133875 133875 133881 133884 133887 133890 133893 133896 133902 133902 133904 133905 133907 133907 133912 133912 133914 133919 133921 133923 133925 133935 133937 133939 133944 133948 133951 133955 133959 133959 133961 133967 133972 133985 133987 133987 133989 133992 133998 134006 134008 134008 134011 134012 134014 134015 134017 134017 134019 134020 134022 134023 134025 134027 134029 134030 134032 134035 134037 134044 134046 134046 134048 134055 134058 134069 134071 134071 134081 134081 134088 134110 134113 134113 134124 134124 134126 134126 134131 134131 134133 134134 134148 134149 134152 134174 134177 134177 134194 134194 134197 134198 134200 134200 134207 134207 134222 134222 134224 134249 134251 134259 134283 134284 134286 134286 134288 134288 134291 134291 134295 134295 134313 134315 134317 134350 134379 134379 134382 134385 134388 134388 134391 134395 134403 134403 134433 134435 134438 134467 134474 134474 134481 134483 134496 134498 134501 134501 134506 134506 134512 134512 134514 134514 134517 134517 134519 134519 134521 134521 134567 134574 134576 134581 134583 134584 134586 134607 134609 134623 134631 134631 134648 134648 134651 134654 134656 134656 134701 134702 134704 134707 134709 134715 134719 134748 134750 134763 134783 134784 134798 134799 134803 134803 134820 134820 134860 134864 134868 134897 134902 134902 134933 134933 134936 134936 134938 134938 134940 134940 134942 134942 134947 134947 135004 135005 135010 135030 135032 135045 135048 135052 135062 135063 135077 135079 135082 135082 135087 135088 135109 135143 135162 135165 135184 135184 135186 135187 135225 135226 135228 135229 135231 135231 135233 135241 135243 135251 135253 135255 135272 135273 135275 135277 135306 135307 135311 135337 135350 135350 135389 135389 135392 135407 135415 135415 135432 135434 135441 135451 135456 135456 135459 135459 135473 135483 135489 135489 135508 135508 135511 135514 135516 135519 135521 135521 135533 135534 135536 135537 135542 135542 135544 135551 135557 135558 135561 135561 135566 135571 135584 135585 135587 135587 135591 135593 135600 135600 135602 135608 135611 135612 135614 135615 135617 135617 135619 135620 135622 135630 135633 135640 135643 135643 135648 135652 135658 135658 135664 135671 135673 135673 135676 135680 135687 135687 135689 135695 135697 135697 135701 135706 135711 135711 135714 135716 135722 135722 135725 135726 135729 135729 135731 135731 135735 135737 135740 135740 135742 135743 135748 135748 135754 135754 135762 135762 135768 135771 135773 135773 135775 135778 135788 135788 135793 135795 135797 135799 135808 135823 135827 135827 135838 135838 135843 135846 135852 135852 135860 135870 135896 135896 135899 135902 135904 135904 135911 135928 135937 135937 135942 135942 135954 135955 135957 135961 135967 135967 135972 135975 135977 135988 135992 135993 136010 136010 136015 136015 136017 136017 136019 136021 136032 136033 136036 136055 136058 136059 136078 136078 136080 136080 136085 136087 136103 136108 136110 136113 136115 136131 136135 136136 136151 136151 136169 136171 136173 136184 136201 136201 136206 136206 136208 136209 136212 136213 136219 136219 136221 136230 136232 136235 136240 136243 136254 136254 136258 136258 136263 136266 136271 136271 136280 136284 136286 136292 136294 136294 136310 136314 136322 136322 136326 136326 136328 136334 136336 136336 136338 136339 136342 136342 136353 136353 136355 136356 136360 136360 136367 136372 136380 136381 136393 136394 136397 136397 136400 136404 136409 136411 136419 136420 136422 136422 136428 136428 136432 136438 136440 136440 136444 136444 136447 136447 136449 136450 136455 136459 136463 136463 136469 136469 136471 136475 136477 136479 136482 136482 136484 136486 136488 136488 136492 136492 136495 136496 136501 136503 136505 136505 136507 136510 136517 136518 136523 136526 136529 136531 136533 136534 136536 136536 136538 136547 136551 136556 136558 136559 136562 136562 136564 136564 136566 136566 136569 136577 136580 136580 136582 136582 136584 136584 136586 136587 136589 136589 136593 136597 136599 136599 136602 136602 136604 136607 136610 136612 136617 136621 136623 136624 136626 136628 136630 136633 136637 136639 136641 136641 136643 136643 136646 136646 136648 136648 136652 136652 136658 136659 136661 136661 136668 136674 136677 136678 136680 136680 136688 136688 136692 136692 136695 136703 136706 136706 136708 136710 136713 136713 136715 136720 136733 136733 136735 136736 136738 136739 136745 136745 136747 136747 136752 136752 136754 136754 136756 136764 136769 136769 136772 136772 136775 136778 136780 136780 136782 136784 136789 136792 136794 136794 136796 136797 136800 136800 136808 136814 136818 136818 136822 136829 136832 136833 136837 136842 136844 136844 136847 136849 136854 136855 136859 136860 136864 136864 136868 136868 136872 136872 136879 136881 136888 136894 136909 136910 136912 136912 136914 136914 136918 136930 136951 136951 136953 136953 136957 136958 136960 136975 136977 136977 136987 136989 136991 136993 136995 136995 136997 137014 137016 137016 137021 137021 137034 137034 137036 137037 137039 137039 137041 137041 137049 137067 137074 137074 137104 137105 137107 137108 137112 137124 137126 137135 137169 137169 137172 137174 137181 137190 137192 137204 137207 137207 137213 137213 137224 137224 137227 137227 137232 137236 137239 137239 137241 137248 137250 137250 137253 137255 137271 137272 137277 137277 137282 137283 137288 137293 137295 137303 137305 137308 137311 137311 137317 137317 137320 137320 137337 137337 137340 137343 137346 137346 137350 137355 137361 137373 137379 137379 137393 137394 137396 137397 137399 137400 137408 137411 137413 137417 137419 137426 137428 137429 137441 137441 137444 137444 137449 137451 137453 137457 137463 137464 137468 137473 137480 137480 137483 137484 137487 137487 137490 137490 137494 137499 137505 137509 137512 137513 137515 137516 137518 137519 137521 137522 137526 137526 137529 137530 137532 137532 137534 137536 137539 137539 137541 137545 137549 137553 137559 137559 137563 137566 137574 137574 137576 137578 137581 137581 137590 137591 137593 137594 137597 137597 137603 137606 137611 137612 137614 137615 137617 137617 137621 137621 137623 137624 137629 137635 137641 137641 137645 137645 137653 137653 137657 137657 137660 137663 137666 137666 137672 137672 137675 137679 137686 137690 137692 137692 137698 137698 137705 137713 137716 137716 137722 137723 137728 137738 137741 137743 137747 137748 137756 137756 137758 137760 137762 137769 137780 137780 137782 137782 137787 137801 137817 137817 137819 137819 137823 137834 137836 137837 137850 137862 137870 137872 137875 137876 137878 137880 137883 137883 137887 137893 137908 137908 137910 137910 137912 137912 137914 137914 137916 137926 137938 137940 137946 137951 137961 137961 137964 137969 137971 137971 137975 137975 137979 137982 137987 137991 137994 137994 137996 137997 138001 138003 138006 138006 138008 138011 138013 138013 138015 138016 138023 138024 138026 138026 138028 138028 138030 138033 138035 138036 138041 138043 138045 138046 138049 138050 138054 138054 138056 138056 138058 138062 138064 138067 138069 138069 138073 138074 138077 138080 138085 138085 138089 138091 138095 138095 138099 138100 138105 138105 138109 138114 138126 138126 138128 138128 138133 138133 138137 138137 138142 138143 138145 138145 138150 138151 138160 138161 138171 138171 138175 138175 138178 138178 138180 138180 138185 138186 138189 138189 138191 138192 138194 138194 138196 138196 138198 138198 138200 138201 138203 138206 138208 138211 138213 138218 138220 138222 138226 138232 138234 138235 138242 138244 138247 138247 138249 138254 138256 138258 138260 138264 138268 138269 138272 138272 138274 138278 138281 138287 138294 138294 138296 138296 138298 138298 138300 138307 138315 138325 138336 138344 138352 138354 138356 138356 138359 138359 138361 138371 138380 138380 138382 138382 138385 138386 138388 138401 138403 138403 138409 138410 138412 138422 138427 138427 138430 138430 138434 138434 138436 138441 138445 138445 138447 138449 138456 138456 138462 138465 138471 138472 138475 138477 138484 138484 138488 138488 138494 138498 138500 138502 138504 138504 138507 138511 138513 138515 138517 138521 138523 138527 138529 138529 138532 138537 138539 138541 138543 138547 138552 138552 138555 138556 138559 138561 138566 138566 138570 138571 138574 138575 138577 138577 138579 138590 138595 138595 138606 138606 138608 138609 138617 138618 138620 138620 138622 138622 138626 138643 138658 138658 138660 138660 138665 138673 138675 138675 138680 138681 138693 138695 138697 138697 138700 138700 138703 138703 138706 138730 138733 138734 138744 138744 138760 138762 138764 138764 138766 138766 138768 138780 138782 138794 138796 138796 138805 138805 138819 138819 138822 138822 138826 138827 138829 138829 138831 138831 138834 138834 138836 138836 138850 138853 138855 138864 138866 138867 138869 138878 138886 138886 138888 138888 138890 138890 138898 138898 138900 138900 138905 138906 138909 138909 138913 138913 138923 138935 138937 138943 138945 138945 138951 138951 138955 138955 138957 138957 138961 138961 138967 138986 138988 138994 138996 138997 139006 139006 139018 139022 139024 139037 139045 139045 139055 139056 139062 139062 139066 139066 139068 139082 139088 139088 139091 139093 139096 139096 139098 139105 139107 139111 139116 139117 139125 139125 139128 139128 139130 139130 139133 139133 139136 139136 139138 139138 139141 139146 139148 139149 139152 139153 139156 139157 139160 139167 139174 139175 139177 139177 139182 139186 139191 139191 139195 139198 139201 139201 139206 139212 139215 139215 139217 139217 139220 139222 139224 139224 139227 139229 139232 139235 139237 139237 139239 139249 139255 139257 139259 139259 139261 139268 139271 139274 139278 139278 139280 139283 139288 139289 139292 139293 139296 139297 139299 139299 139305 139305 139311 139311 139316 139316 139318 139319 139321 139321 139323 139323 139327 139333 139340 139340 139344 139344 139346 139355 139362 139370 139372 139377 139379 139381 139385 139395 139398 139399 139402 139403 139405 139405 139407 139416 139418 139418 139421 139424 139429 139430 139433 139436 139438 139439 139441 139442 139444 139458 139462 139462 139467 139485 139491 139492 139495 139496 139498 139515 139521 139521 139524 139527 139530 139536 139539 139544 139546 139548 139550 139559 139568 139578 139580 139583 139586 139586 139593 139595 139597 139607 139609 139611 139614 139618 139622 139622 139624 139627 139629 139634 139637 139637 139640 139641 139643 139647 139651 139653 139655 139659 139661 139662 139665 139666 139673 139676 139679 139679 139682 139682 139692 139692 139695 139695 139697 139700 139702 139704 139707 139713 139718 139719 139722 139725 139727 139727 139729 139730 139732 139732 139734 139742 139744 139744 139747 139755 139757 139757 139759 139760 139762 139772 139778 139778 139780 139781 139783 139788 139799 139799 139801 139813 139820 139821 139826 139846 139848 139848 139861 139862 139864 139885 139892 139892 139894 139894 139903 139911 139913 139913 139918 139918 139920 139920 139922 139929 139931 139933 139944 139944 139946 139946 139949 139958 139962 139964 139969 139975 139980 139980 139985 139988 139994 139994 139996 139997 140001 140003 140006 140007 140010 140010 140013 140013 140015 140018 140024 140024 140027 140032 140034 140036 140038 140041 140043 140043 140045 140045 140049 140053 140059 140059 140061 140062 140070 140070 140072 140072 140075 140077 140079 140079 140081 140081 140083 140085 140088 140088 140090 140095 140097 140102 140106 140106 140109 140112 140114 140114 140116 140126 140128 140128 140130 140131 140134 140136 140139 140140 140142 140147 140150 140155 140159 140161 140163 140164 140166 140167 140170 140170 140172 140174 140176 140179 140184 140186 140188 140189 140191 140192 140194 140203 140205 140205 140208 140210 140214 140219 140225 140225 140229 140233 140242 140250 140260 140260 140262 140266 140268 140268 140270 140280 140284 140286 140288 140296 140298 140300 140303 140303 140306 140310 140313 140313 140317 140321 140324 140329 140332 140333 140335 140335 140338 140340 140343 140348 140350 140356 140358 140365 140368 140380 140382 140382 140385 140388 140390 140390 140392 140395 140397 140397 140399 140403 140405 140409 140413 140417 140419 140420 140424 140426 140428 140428 140431 140433 140436 140439 140443 140449 140452 140455 140457 140464 140466 140469 140471 140473 140477 140480 140482 140491 140495 140496 140498 140504 140508 140512 140514 140515 140521 140536 140540 140542 140544 140548 140550 140561 140568 140568 140570 140570 140572 140573 140575 140586 140589 140589 140593 140593 140595 140600 140611 140611 140615 140616 140621 140639 140647 140647 140650 140657 140662 140663 140665 140668 140670 140670 140675 140676 140680 140682 140686 140690 140695 140703 140706 140711 140713 140717 140722 140731 140733 140733 140737 140737 140739 140739 140743 140750 140752 140757 140759 140760 140763 140763 140780 140780 140782 140782 140785 140786 140793 140795 140799 140822 140832 140832 140835 140835 140838 140840 140842 140842 140852 140856 140858 140878 140886 140886 140898 140898 140902 140902 140910 140910 140912 140945 140951 140951 140966 140966 140975 140976 140986 140987 140993 141038 141078 141079 141082 141082 141091 141093 141096 141141 141143 141143 141149 141152 141165 141166 141170 141170 141181 141181 141191 141191 141193 141194 141198 141210 141212 141235 141238 141238 141251 141252 141258 141258 141276 141277 141280 141284 141286 141292 141294 141312 141322 141322 141340 141340 141342 141345 141356 141356 141358 141358 141361 141387 141390 141401 141410 141410 141412 141413 141427 141428 141432 141432 141437 141439 141452 141453 141458 141479 141488 141489 141513 141514 141517 141526 141528 141538 141554 141554 141558 141558 141563 141580 141582 141587 141589 141590 141592 141593 141604 141604 141606 141622 141633 141633 141635 141636 141643 141651 141655 141656 141658 141663 141665 141665 141669 141673 141679 141682 141691 141694 141701 141701 141704 141705 141710 141712 141715 141718 141721 141730 141734 141740 141750 141755 141759 141761 141766 141773 141777 141778 141780 141782 141784 141784 141788 141788 141791 141792 141794 141794 141796 141801 141804 141804 141811 141818 141822 141823 141831 141838 141840 141844 141849 141851 141854 141855 141857 141857 141859 141862 141865 141866 141871 141871 141874 141874 141876 141876 141879 141882 141886 141886 141889 141889 141892 141896 141899 141899 141901 141901 141905 141907 141909 141910 141912 141913 141917 141917 141920 141920 141922 141922 141925 141926 141928 141929 141931 141934 141936 141940 141954 141975 142004 142008 142010 142016 142018 142018 142050 142050 142052 142080 142083 142083 142086 142086 142110 142110 142122 142124 142127 142158 142162 142163 142180 142180 142184 142184 142209 142212 142214 142234 142236 142244 142247 142248 142254 142254 142280 142280 142284 142284 142313 142364 142376 142376 142400 142400 142402 142403 142405 142405 142407 142407 142431 142444 142446 142452 142454 142460 142462 142464 142485 142486 142488 142488 142512 142512 142515 142526 142528 142537 142539 142539 142541 142550 142552 142554 142561 142562 142592 142592 142624 142638 142640 142657 142659 142660 142664 142664 142669 142671 142719 142749 142758 142758 142773 142773 142791 142792 142795 142813 142820 142821 142829 142829 142838 142857 142883 142900 142914 142914 142916 142916 142925 142925 142927 142929 142931 142938 142943 142943 142956 142965 142978 142988 142993 142993 142997 142998 143006 143010 143013 143014 143020 143020 143024 143025 143028 143031 143038 143038 143041 143044 143048 143048 143050 143050 143053 143055 143060 143061 143063 143063 143066 143067 143069 143070 143072 143072 143077 143079 143081 143082 143084 143087 143089 143092 143094 143095 143097 143099 143101 143102 143109 143121 143124 143125 143128 143128 143132 143139 143141 143141 143143 143144 143146 143146 143148 143151 143158 143158 143162 143163 143165 143165 143167 143179 143183 143184 143191 143192 143195 143195 143197 143201 143204 143210 143212 143216 143218 143223 143226 143226 143231 143232 143234 143241 143243 143245 143247 143248 143250 143252 143257 143262 143264 143264 143267 143269 143271 143279 143281 143281 143283 143290 143292 143294 143302 143307 143309 143310 143312 143318 143320 143321 143323 143323 143326 143329 143332 143333 143336 143342 143346 143349 143351 143353 143357 143362 143366 143366 143369 143370 143374 143378 143380 143382 143384 143384 143386 143386 143389 143390 143392 143393 143395 143400 143402 143407 143409 143409 143411 143411 143413 143415 143418 143418 143420 143420 143427 143427 143434 143435 143438 143439 143442 143442 143447 143447 143449 143449 143452 143455 143458 143459 143467 143468 143473 143473 143475 143479 143482 143484 143487 143490 143492 143492 143494 143494 143497 143498 143500 143500 143503 143503 143505 143505 143508 143509 143513 143513 143518 143528 143530 143531 143533 143535 143537 143538 143541 143542 143544 143549 143551 143555 143558 143558 143560 143560 143562 143565 143567 143569 143572 143572 143574 143574 143576 143577 143581 143583 143586 143586 143590 143594 143599 143599 143603 143603 143605 143605 143607 143607 143611 143617 143624 143626 143630 143633 143636 143636 143640 143642 143645 143650 143652 143652 143654 143656 143658 143659 143662 143662 143664 143666 143668 143672 143675 143676 143678 143681 143686 143692 143694 143694 143696 143696 143702 143702 143706 143719 143727 143727 143729 143732 143735 143742 143748 143748 143753 143755 143762 143774 143776 143776 143783 143783 143785 143785 143787 143787 143794 143808 143834 143834 143842 143852 143854 143859 143862 143862 143866 143867 143885 143885 143887 143887 143903 143905 143908 143914 143926 143926 143940 143940 143944 143944 143946 143946 143953 143964 143977 143981 143984 143984 143994 143999 144001 144004 144006 144006 144020 144021 144025 144027 144029 144033 144035 144040 144046 144046 144052 144052 144054 144054 144056 144056 144061 144061 144068 144069 144073 144077 144079 144080 144083 144083 144087 144087 144094 144095 144099 144099 144101 144101 144111 144111 144114 144120 144127 144127 144133 144133 144135 144136 144141 144141 144143 144143 144147 144147 144150 144152 144156 144156 144159 144159 144163 144163 144166 144169 144172 144173 144188 144190 144195 144196 144198 144200 144207 144207 144209 144212 144214 144214 144216 144217 144219 144231 144236 144236 144238 144238 144244 144250 144260 144261 144268 144269 144272 144272 144274 144276 144279 144279 144282 144284 144287 144287 144291 144292 144297 144297 144301 144302 144305 144309 144312 144316 144319 144323 144325 144325 144331 144331 144336 144338 144340 144353 144370 144371 144374 144374 144376 144376 144379 144379 144381 144381 144385 144385 144387 144387 144391 144403 144432 144432 144437 144452 144485 144485 144488 144488 144490 144491 144493 144493 144497 144497 144504 144505 144510 144521 144527 144527 144552 144557 144559 144559 144566 144572 144576 144609 144615 144618 144654 144655 144657 144662 144683 144687 144689 144718 144720 144723 144767 144771 144775 144775 144778 144778 144803 144805 144808 144808 144810 144818 144820 144831 144833 144835 144848 144848 144883 144885 144887 144888 144890 144891 144901 144901 144903 144903 144912 144914 144917 144947 144955 144955 144959 144959 144961 144963 144987 144987 144996 144996 145008 145014 145019 145042 145044 145062 145064 145066 145071 145071 145110 145110 145112 145112 145114 145114 145131 145131 145136 145149 145151 145160 145165 145166 145187 145192 145209 145210 145217 145246 145253 145253 145255 145256 145271 145271 145273 145273 145275 145276 145278 145278 145286 145287 145289 145289 145291 145291 145296 145311 145315 145316 145328 145328 145330 145330 145333 145333 145335 145335 145348 145362 145368 145368 145384 145384 145388 145388 145391 145392 145394 145398 145400 145406 145409 145409 145420 145420 145422 145424 145428 145428 145433 145441 145453 145454 145463 145472 145475 145475 145478 145478 145481 145482 145484 145487 145496 145496 145499 145499 145502 145502 145504 145504 145507 145507 145509 145509 145511 145511 145513 145515 145517 145517 145523 145524 145526 145528 145530 145530 145532 145532 145536 145543 145545 145555 145559 145571 145575 145578 145580 145588 145594 145595 145597 145597 145608 145619 145621 145622 145625 145625 145629 145641 145644 145644 145647 145648 145650 145667 145671 145682 145684 145684 145687 145690 145692 145692 145696 145699 145701 145701 145705 145705 145708 145709 145713 145714 145716 145719 145721 145724 145726 145733 145735 145753 145760 145760 145762 145763 145765 145771 145773 145773 145778 145780 145784 145791 145793 145797 145799 145801 145803 145803 145812 145817 145820 145823 145825 145826 145830 145832 145839 145839 145841 145842 145845 145853 145855 145863 145865 145878 145885 145902 145904 145913 145915 145921 145923 145923 145925 145937 145942 145958 145960 145960 145967 145967 145969 145977 145979 145979 145988 145993 145995 146007 146009 146009 146013 146019 146024 146029 146031 146036 146038 146039 146042 146044 146046 146048 146050 146051 146053 146054 146056 146056 146059 146064 146069 146071 146073 146073 146075 146075 146080 146081 146083 146085 146089 146090 146092 146099 146102 146105 146107 146113 146124 146125 146128 146131 146134 146134 146136 146138 146142 146143 146145 146153 146155 146157 146159 146160 146164 146164 146169 146170 146178 146182 146184 146199 146202 146204 146209 146211 146217 146222 146229 146229 146232 146242 146244 146245 146247 146247 146268 146275 146285 146286 146289 146301 146312 146325 146339 146339 146343 146356 146361 146361 146370 146370 146373 146383 146385 146387 146389 146389 146395 146397 146399 146399 146402 146402 146404 146418 146423 146430 146438 146438 146441 146446 146448 146448 146452 146452 146454 146454 146458 146460 146462 146467 146472 146472 146475 146478 146482 146482 146486 146488 146491 146492 146495 146496 146500 146501 146503 146507 146510 146515 146517 146518 146521 146524 146526 146526 146528 146529 146532 146532 146534 146534 146538 146539 146542 146543 146548 146551 146560 146564 146566 146566 146571 146571 146574 146581 146589 146593 146610 146626 146628 146629 146634 146635 146648 146651 146653 146653 146659 146679 146689 146689 146705 146706 146708 146710 146718 146748 146750 146750 146754 146754 146782 146782 146786 146786 146788 146788 146790 146790 146792 146793 146796 146796 146801 146801 146807 146838 146840 146847 146849 146854 146869 146869 146878 146879 146907 146907 146909 146909 146911 146911 146913 146914 146916 146916 146918 146919 146921 146921 146933 146934 146939 146977 147014 147015 147017 147018 147020 147022 147034 147034 147037 147055 147057 147073 147084 147088 147116 147116 147119 147122 147124 147124 147148 147149 147151 147186 147199 147199 147225 147227 147229 147229 147231 147235 147259 147259 147267 147276 147278 147312 147315 147318 147325 147325 147332 147333 147363 147363 147368 147374 147397 147428 147441 147444 147460 147464 147467 147467 147470 147470 147473 147473 147490 147511 147513 147513 147518 147518 147529 147530 147532 147533 147551 147551 147553 147591 147594 147594 147617 147619 147621 147622 147634 147643 147645 147650 147652 147652 147658 147658 147669 147669 147671 147674 147683 147683 147689 147693 147695 147698 147700 147705 147707 147710 147721 147721 147726 147729 147731 147741 147750 147750 147752 147755 147764 147771 147773 147773 147777 147777 147781 147783 147786 147790 147793 147794 147803 147803 147805 147805 147808 147812 147814 147814 147816 147819 147821 147821 147824 147828 147831 147833 147835 147837 147839 147840 147842 147846 147851 147851 147853 147858 147866 147866 147869 147871 147887 147887 147889 147890 147892 147892 147900 147905 147911 147911 147929 147931 147933 147933 147935 147937 147947 147947 147951 147954 147956 147959 147965 147965 147985 147986 147989 147990 148002 148003 148005 148018 148025 148025 148042 148042 148049 148049 148061 148061 148063 148063 148065 148071 148073 148079 148089 148091 148119 148121 148123 148124 148143 148143 148146 148146 148148 148164 148166 148167 148200 148202 148204 148204 148207 148209 148211 148211 148225 148225 148227 148227 148232 148246 148251 148253 148280 148285 148301 148301 148304 148304 148307 148317 148326 148327 148350 148350 148354 148354 148375 148376 148378 148378 148381 148405 148407 148408 148414 148416 148440 148443 148445 148448 148461 148464 148468 148480 148498 148498 148501 148501 148503 148503 148510 148511 148518 148525 148527 148531 148535 148536 148546 148547 148549 148550 148554 148555 148562 148564 148566 148567 148572 148572 148578 148578 148583 148584 148593 148593 148595 148602 148604 148610 148614 148614 148617 148617 148627 148627 148631 148631 148636 148636 148638 148638 148641 148644 148646 148647 148651 148652 148654 148654 148666 148670 148672 148672 148676 148677 148680 148682 148687 148688 148690 148690 148692 148693 148695 148695 148698 148698 148700 148705 148709 148710 148714 148719 148721 148724 148726 148728 148733 148734 148736 148739 148743 148743 148746 148746 148748 148748 148750 148750 148752 148754 148756 148757 148759 148760 148764 148764 148768 148768 148770 148778 148780 148780 148782 148782 148784 148786 148793 148793 148800 148800 148805 148805 148808 148809 148811 148811 148813 148813 148816 148817 148819 148819 148821 148821 148824 148824 148826 148827 148829 148832 148834 148843 148845 148855 148858 148862 148865 148865 148869 148877 148879 148880 148883 148883 148885 148894 148896 148896 148898 148903 148905 148916 148919 148919 148922 148926 148928 148930 148932 148933 148935 148943 148945 148945 148951 148956 148960 148960 148962 148963 148965 148966 148968 148975 148977 148977 148979 148984 148986 148987 148991 148992 148995 148997 149000 149001 149004 149005 149008 149009 149012 149012 149014 149014 149016 149016 149018 149031 149035 149036 149042 149044 149048 149056 149058 149058 149065 149066 149068 149069 149071 149071 149073 149077 149079 149080 149083 149090 149092 149092 149096 149096 149098 149099 149101 149101 149104 149109 149111 149113 149122 149124 149128 149130 149132 149142 149150 149150 149152 149152 149160 149174 149180 149183 149186 149186 149193 149201 149211 149211 149215 149215 149217 149223 149225 149225 149227 149227 149231 149236 149238 149238 149241 149243 149245 149248 149250 149253 149255 149257 149259 149261 149263 149266 149268 149268 149270 149270 149273 149273 149275 149277 149281 149284 149286 149286 149288 149288 149291 149291 149295 149312 149314 149315 149318 149318 149324 149325 149327 149340 149342 149345 149347 149348 149350 149350 149352 149352 149356 149356 149358 149378 149384 149384 149399 149399 149401 149411 149413 149413 149423 149424 149426 149426 149432 149433 149438 149440 149443 149458 149460 149461 149463 149463 149465 149466 149468 149485 149492 149494 149496 149496 149498 149499 149501 149501 149511 149511 149517 149530 149532 149537 149540 149541 149547 149548 149557 149557 149561 149575 149582 149582 149585 149585 149591 149593 149596 149614 149616 149622 149625 149628 149631 149631 149635 149635 149637 149637 149642 149658 149660 149662 149664 149664 149666 149667 149670 149674 149679 149679 149684 149691 149699 149699 149701 149701 149704 149707 149709 149710 149712 149715 149719 149721 149723 149725 149727 149728 149731 149732 149735 149739 149742 149744 149746 149746 149748 149749 149752 149756 149768 149768 149773 149773 149775 149779 149784 149784 149800 149800 149802 149802 149809 149810 149813 149820 149838 149838 149844 149852 149873 149873 149879 149880 149884 149889 149891 149891 149904 149906 149920 149922 149925 149926 149928 149928 149934 149940 149948 149948 149974 149975 149977 149977 149984 149984 149986 149986 149991 149991 149994 150000 150002 150002 150010 150010 150029 150029 150031 150032 150036 150045 150072 150075 150080 150089 150091 150091 150098 150098 150111 150111 150115 150116 150120 150121 150123 150130 150132 150133 150147 150151 150155 150160 150178 150179 150185 150190 150196 150196 150201 150201 150206 150208 150213 150214 150217 150218 150220 150221 150228 150229 150232 150232 150243 150245 150248 150253 150255 150263 150266 150268 150270 150270 150273 150275 150279 150281 150284 150288 150290 150290 150294 150296 150298 150301 150304 150308 150310 150310 150312 150314 150316 150320 150324 150327 150330 150332 150334 150340 150348 150357 150359 150360 150363 150371 150374 150378 150380 150380 150384 150384 150387 150388 150393 150400 150405 150411 150413 150416 150419 150420 150422 150422 150424 150429 150433 150434 150438 150443 150445 150451 150453 150453 150456 150461 150465 150465 150471 150473 150475 150478 150480 150480 150483 150487 150490 150491 150493 150499 150502 150503 150508 150508 150511 150511 150514 150515 150519 150519 150525 150525 150528 150528 150531 150531 150533 150536 150542 150542 150545 150545 150549 150549 150555 150555 150557 150563 150568 150582 150603 150608 150610 150610 150613 150614 150622 150622 150627 150638 150641 150641 150643 150643 150646 150646 150652 150654 150659 150660 150667 150667 150669 150670 150673 150685 150691 150691 150695 150695 150699 150704 150706 150706 150709 150715 150717 150719 150725 150725 150728 150732 150735 150735 150738 150744 150747 150747 150751 150752 150756 150756 150761 150767 150770 150771 150774 150774 150777 150777 150779 150780 150783 150786 150788 150789 150791 150792 150795 150796 150798 150798 150800 150803 150805 150805 150807 150809 150812 150817 150820 150827 150830 150833 150835 150836 150839 150851 150855 150855 150859 150859 150861 150861 150865 150865 150868 150868 150871 150889 150891 150891 150893 150893 150903 150913 150917 150918 150921 150922 150924 150924 150931 150949 150952 150955 150966 150967 150976 150993 150995 151004 151008 151008 151013 151013 151031 151033 151035 151055 151057 151065 151070 151072 151074 151074 151076 151076 151081 151103 151113 151113 151117 151117 151119 151119 151131 151148 151153 151153 151155 151156 151158 151158 151161 151161 151163 151163 151168 151169 151172 151197 151206 151209 151223 151241 151245 151245 151253 151262 151266 151267 151269 151269 151272 151272 151278 151279 151281 151290 151296 151302 151307 151309 151312 151314 151318 151322 151324 151325 151327 151333 151335 151335 151337 151338 151340 151340 151343 151346 151351 151351 151353 151354 151356 151358 151361 151363 151366 151370 151372 151374 151376 151376 151380 151380 151382 151382 151384 151387 151397 151399 151404 151404 151407 151408 151417 151421 151423 151423 151432 151434 151445 151445 151448 151449 151451 151454 151456 151464 151466 151469 151474 151476 151478 151478 151480 151480 151483 151484 151486 151486 151488 151488 151491 151491 151493 151499 151502 151506 151509 151517 151519 151521 151525 151525 151527 151531 151534 151534 151539 151543 151545 151545 151551 151551 151553 151556 151559 151563 151565 151569 151572 151577 151579 151580 151582 151583 151585 151590 151592 151592 151595 151597 151599 151602 151604 151606 151609 151610 151612 151613 151615 151615 151617 151625 151627 151627 151630 151638 151642 151644 151646 151649 151657 151665 151670 151676 151683 151685 151687 151688 151690 151690 151699 151705 151712 151713 151716 151721 151724 151724 151729 151731 151733 151738 151740 151740 151742 151742 151744 151747 151751 151754 151757 151758 151763 151766 151768 151769 151772 151772 151777 151777 151780 151780 151782 151787 151794 151805 151808 151808 151810 151833 151835 151838 151845 151845 151847 151847 151849 151849 151857 151873 151876 151876 151881 151881 151891 151891 151895 151907 151909 151918 151920 151921 151923 151923 151926 151926 151929 151929 151932 151932 151941 151945 151947 151974 151984 151984 151987 151987 151989 151990 152003 152007 152009 152022 152024 152033 152036 152036 152043 152043 152046 152046 152052 152053 152062 152064 152066 152067 152069 152092 152105 152106 152119 152120 152123 152159 152162 152162 152166 152166 152176 152176 152180 152194 152196 152202 152208 152208 152213 152213 152231 152232 152234 152260 152269 152269 152272 152272 152281 152293 152296 152296 152299 152301 152303 152304 152315 152315 152319 152336 152341 152343 152346 152351 152353 152353 152355 152355 152360 152362 152365 152370 152373 152374 152378 152388 152390 152390 152393 152396 152399 152399 152403 152405 152407 152407 152410 152410 152414 152421 152423 152424 152426 152435 152437 152447 152450 152455 152457 152464 152466 152474 152476 152476 152481 152481 152484 152492 152496 152498 152501 152502 152504 152514 152521 152521 152526 152527 152532 152532 152536 152538 152540 152544 152546 152546 152554 152556 152559 152560 152562 152565 152567 152567 152571 152572 152574 152574 152576 152577 152579 152580 152593 152593 152595 152595 152597 152602 152605 152606 152612 152612 152617 152620 152634 152634 152636 152636 152641 152641 152644 152660 152664 152666 152674 152675 152681 152681 152687 152688 152690 152694 152696 152706 152719 152719 152722 152722 152724 152724 152732 152732 152740 152740 152743 152758 152765 152765 152768 152769 152774 152775 152778 152791 152794 152794 152813 152813 152817 152817 152826 152842 152848 152848 152866 152866 152872 152875 152877 152885 152899 152899 152901 152905 152908 152913 152915 152920 152922 152922 152929 152929 152934 152934 152944 152959 152971 152972 152983 152993 153002 153004 153011 153012 153015 153015 153019 153026 153033 153033 153042 153043 153048 153049 153053 153055 153059 153059 153066 153070 153073 153074 153076 153076 153079 153080 153082 153083 153086 153087 153089 153089 153091 153094 153096 153096 153101 153101 153109 153110 153126 153126 153131 153134 153136 153137 153154 153154 153156 153156 153161 153163 153165 153167 153188 153188 153192 153192 153195 153202 153207 153208 153224 153229 153244 153244 153254 153259 153280 153283 153285 153288 153300 153300 153304 153313 153326 153332 153339 153341 153343 153343 153347 153349 153359 153359 153361 153364 153370 153371 153375 153376 153379 153379 153382 153383 153385 153386 153388 153388 153391 153394 153396 153396 153399 153401 153404 153407 153409 153409 153411 153413 153415 153416 153418 153421 153424 153424 153427 153430 153432 153432 153442 153455 153466 153468 153470 153478 153490 153490 153495 153502 153513 153513 153519 153519 153521 153532 153541 153541 153549 153564 153566 153566 153591 153592 153594 153595 153597 153614 153633 153634 153649 153655 153657 153658 153660 153665 153667 153667 153669 153670 153684 153684 153690 153693 153695 153712 153715 153716 153721 153721 153728 153729 153735 153736 153738 153743 153745 153750 153758 153758 153773 153774 153776 153776 153780 153789 153811 153811 153814 153818 153820 153820 153822 153824 153829 153830 153832 153842 153847 153847 153854 153854 153856 153859 153861 153863 153866 153868 153870 153870 153873 153876 153879 153880 153882 153882 153884 153884 153886 153887 153890 153892 153895 153899 153901 153902 153904 153904 153908 153919 153927 153940 153943 153943 153947 153947 153950 153950 153952 153961 153974 153992 153994 154001 154011 154018 154020 154026 154034 154034 154037 154038 154040 154047 154053 154053 154055 154055 154058 154058 154064 154064 154066 154080 154082 154082 154085 154085 154092 154109 154122 154122 154125 154136 154145 154146 154154 154158 154160 154167 154171 154173 154175 154178 154186 154188 154190 154190 154192 154192 154194 154201 154208 154214 154221 154222 154225 154230 154235 154235 154238 154244 154250 154257 154261 154261 154264 154267 154277 154279 154284 154284 154287 154289 154291 154291 154293 154294 154299 154301 154303 154303 154307 154307 154312 154313 154317 154318 154320 154320 154326 154326 154329 154338 154351 154353 154355 154365 154375 154375 154380 154391 154393 154395 154397 154399 154410 154425 154427 154432 154443 154443 154448 154472 154474 154481 154487 154488 154501 154501 154509 154526 154528 154528 154530 154539 154541 154543 154577 154618 154620 154623 154626 154626 154629 154629 154633 154633 154648 154690 154692 154695 154701 154704 154729 154729 154741 154753 154756 154770 154773 154796 154798 154799 154811 154813 154822 154874 154879 154882 154899 154900 154913 154930 154932 154939 154941 154943 154948 154949 154960 154960 154963 154963 154972 154998 155000 155001 155005 155005 155014 155016 155018 155039 155050 155051 155060 155081 155088 155089 155092 155104 155106 155108 155112 155122 155124 155124 155128 155128 155132 155136 155139 155139 155141 155141 155143 155147 155152 155153 155158 155160 155164 155164 155169 155171 155173 155173 155175 155176 155179 155181 155183 155183 155187 155192 155197 155198 155201 155203 155205 155216 155221 155221 155226 155226 155228 155234 155236 155236 155245 155245 155250 155263 155272 155272 155275 155275 155288 155300 155315 155315 155318 155318 155320 155320 155329 155350 155364 155376 155379 155379 155391 155401 155411 155411 155416 155426 155428 155429 155446 155459 155461 155461 155463 155463 155465 155466 155471 155473 155479 155483 155491 155491 155493 155495 155500 155502 155504 155508 155510 155522 155524 155527 155530 155530 155532 155539 155542 155542 155545 155550 155552 155568 155578 155579 155587 155603 155605 155605 155612 155612 155615 155615 155622 155642 155644 155644 155655 155655 155657 155657 155666 155687 155715 155716 155718 155718 155720 155742 155745 155745 155748 155749 155760 155761 155764 155764 155776 155785 155787 155797 155799 155810 155828 155829 155831 155831 155841 155841 155843 155865 155867 155872 155874 155880 155888 155889 155913 155932 155953 155954 155964 155989 156007 156008 156010 156010 156012 156012 156019 156019 156021 156038 156040 156047 156053 156055 156059 156071 156073 156076 156079 156080 156086 156086 156091 156101 156104 156104 156110 156111 156113 156113 156115 156124 156130 156131 156133 156133 156135 156140 156144 156147 156150 156158 156160 156161 156163 156163 156165 156165 156167 156167 156194 156195 156197 156201 156203 156210 156212 156214 156216 156220 156225 156226 156231 156233 156238 156240 156245 156246 156249 156250 156253 156256 156258 156259 156261 156263 156265 156271 156275 156275 156279 156281 156283 156284 156286 156291 156296 156296 156299 156299 156301 156312 156316 156321 156323 156324 156327 156331 156333 156335 156339 156340 156342 156342 156348 156351 156356 156365 156369 156369 156374 156388 156391 156391 156395 156405 156409 156409 156411 156419 156421 156422 156425 156426 156429 156439 156444 156452 156456 156462 156465 156472 156474 156476 156478 156483 156486 156488 156490 156492 156494 156496 156498 156498 156500 156501 156503 156504 156506 156511 156517 156522 156525 156526 156530 156530 156537 156544 156547 156547 156549 156555 156557 156557 156564 156564 156567 156570 156573 156573 156578 156583 156585 156585 156587 156587 156591 156593 156596 156596 156599 156604 156609 156609 156611 156611 156613 156621 156625 156625 156629 156634 156636 156643 156647 156651 156653 156653 156655 156656 156658 156658 156660 156668 156672 156672 156674 156686 156691 156691 156693 156700 156702 156702 156706 156714 156716 156723 156727 156734 156736 156736 156742 156753 156760 156768 156770 156778 156784 156790 156792 156798 156803 156808 156810 156810 156813 156822 156827 156829 156831 156832 156834 156835 156837 156838 156840 156842 156844 156847 156849 156851 156854 156856 156858 156859 156862 156862 156864 156865 156867 156868 156878 156880 156882 156884 156886 156890 156893 156894 156896 156896 156900 156901 156904 156904 156906 156906 156908 156908 156910 156913 156916 156917 156919 156926 156929 156934 156937 156937 156939 156945 156947 156949 156951 156952 156955 156962 156965 156966 156968 156973 156975 156977 156981 156981 156983 156985 156988 156993 156999 156999 157002 157005 157007 157016 157018 157018 157024 157026 157029 157030 157041 157041 157045 157056 157058 157058 157061 157061 157064 157070 157072 157072 157084 157084 157090 157100 157113 157113 157116 157123 157130 157130 157133 157133 157136 157143 157145 157146 157151 157161 157167 157167 157171 157175 157182 157182 157187 157189 157192 157195 157197 157197 157202 157205 157208 157208 157211 157211 157213 157216 157219 157219 157224 157229 157234 157240 157242 157243 157245 157259 157261 157261 157264 157265 157270 157272 157275 157276 157279 157282 157287 157308 157311 157315 157320 157321 157324 157326 157329 157331 157336 157339 157341 157358 157362 157362 157368 157371 157373 157373 157377 157381 157390 157392 157394 157409 157411 157415 157417 157420 157427 157428 157430 157431 157433 157433 157442 157444 157446 157448 157450 157468 157471 157473 157482 157482 157484 157484 157493 157494 157497 157499 157501 157503 157519 157560 157569 157569 157572 157573 157577 157577 157579 157579 157589 157591 157593 157613 157615 157618 157621 157622 157632 157633 157652 157653 157656 157657 157659 157661 157663 157671 157673 157673 157679 157680 157683 157684 157696 157697 157699 157719 157726 157728 157732 157733 157736 157737 157739 157740 157751 157756 157758 157763 157765 157768 157772 157773 157783 157784 157787 157788 157800 157805 157808 157810 157812 157821 157827 157827 157829 157829 157832 157832 157834 157834 157836 157841 157845 157846 157849 157853 157861 157867 157869 157869 157871 157871 157880 157885 157887 157889 157894 157901 157903 157907 157910 157910 157914 157918 157920 157920 157924 157924 157929 157929 157934 157934 157938 157938 157940 157940 157943 157951 157954 157956 157958 157958 157962 157962 157964 157965 157968 157968 157970 157970 157972 157973 157976 157978 157981 157983 157985 157987 157990 157992 157994 157996 158002 158006 158009 158012 158015 158015 158017 158018 158021 158022 158024 158027 158030 158037 158040 158041 158043 158043 158045 158050 158053 158057 158059 158059 158061 158062 158066 158090 158092 158092 158095 158097 158099 158099 158101 158110 158113 158117 158119 158119 158121 158125 158127 158130 158134 158134 158137 158143 158145 158146 158148 158149 158151 158154 158156 158156 158158 158161 158163 158167 158173 158173 158175 158178 158180 158183 158186 158187 158189 158190 158192 158193 158196 158198 158200 158201 158203 158204 158206 158207 158209 158209 158211 158224 158226 158234 158236 158237 158239 158244 158246 158248 158252 158252 158255 158258 158260 158263 158266 158266 158268 158271 158276 158276 158279 158287 158297 158297 158300 158316 158321 158322 158324 158333 158340 158347 158349 158350 158353 158365 158372 158373 158375 158375 158377 158382 158384 158386 158390 158392 158397 158408 158410 158411 158414 158414 158418 158418 158420 158421 158423 158423 158425 158425 158427 158430 158434 158438 158442 158445 158447 158449 158451 158452 158454 158460 158464 158473 158483 158503 158517 158517 158519 158537 158539 158539 158557 158557 158562 158562 158569 158569 158571 158571 158573 158611 158616 158617 158638 158638 158647 158671 158673 158678 158680 158694 158696 158708 158712 158712 158742 158745 158749 158750 158759 158759 158762 158789 158791 158812 158814 158832 158834 158844 158851 158856 158892 158892 158895 158896 158913 158958 158960 158978 158981 158981 158983 159008 159019 159027 159056 159058 159069 159069 159071 159071 159073 159106 159108 159131 159144 159152 159187 159189 159191 159195 159197 159201 159203 159203 159217 159227 159229 159229 159231 159236 159238 159268 159270 159290 159302 159309 159329 159332 159336 159336 159338 159338 159357 159362 159366 159437 159452 159466 159494 159494 159498 159506 159513 159513 159521 159522 159524 159524 159529 159564 159566 159596 159598 159598 159601 159601 159605 159611 159631 159632 159634 159634 159636 159636 159639 159639 159660 159686 159688 159705 159712 159722 159748 159751 159757 159757 159764 159771 159773 159773 159776 159797 159799 159821 159823 159823 159825 159825 159828 159832 159856 159856 159867 159878 159880 159903 159905 159905 159907 159909 159911 159913 159920 159925 159944 159945 159950 159980 159982 159984 159993 159996 160011 160011 160013 160035 160040 160043 160054 160079 160083 160083 160086 160098 160105 160106 160110 160116 160120 160120 160122 160126 160129 160129 160131 160131 160134 160139 160143 160154 160156 160158 160163 160172 160177 160179 160186 160191 160193 160201 160205 160205 160208 160213 160216 160216 160220 160232 160236 160237 160241 160242 160251 160257 160262 160265 160267 160267 160269 160270 160272 160275 160277 160280 160282 160282 160284 160288 160296 160304 160314 160337 160341 160341 160343 160344 160347 160348 160350 160357 160359 160368 160371 160375 160389 160392 160397 160400 160402 160425 160427 160433 160438 160440 160447 160447 160456 160473 160475 160481 160495 160496 160499 160499 160513 160513 160515 160541 160543 160548 160550 160557 160564 160565 160571 160571 160573 160573 160575 160575 160593 160644 160648 160648 160660 160660 160663 160664 160670 160670 160673 160678 160680 160725 160732 160733 160740 160740 160742 160742 160744 160746 160748 160748 160760 160770 160772 160799 160803 160803 160813 160815 160817 160817 160819 160822 160832 160832 160836 160858 160860 160884 160888 160888 160897 160899 160904 160904 160910 160920 160922 160927 160929 160939 160956 160959 160968 160972 160974 160991 160993 160994 161003 161004 161009 161028 161030 161032 161038 161040 161048 161048 161053 161064 161066 161068 161070 161079 161082 161082 161085 161085 161091 161106 161108 161109 161115 161128 161134 161146 161148 161152 161154 161154 161156 161160 161162 161167 161169 161182 161188 161188 161191 161197 161199 161199 161203 161214 161216 161220 161222 161228 161230 161234 161236 161247 161249 161251 161254 161261 161265 161270 161272 161275 161279 161280 161282 161286 161288 161291 161293 161299 161305 161306 161308 161328 161331 161331 161333 161335 161341 161342 161344 161362 161368 161368 161371 161381 161383 161391 161397 161397 161399 161399 161401 161401 161406 161406 161408 161426 161429 161429 161435 161438 161441 161441 161444 161466 161468 161469 161475 161475 161487 161516 161522 161523 161528 161544 161546 161547 161549 161549 161553 161553 161557 161557 161565 161575 161577 161577 161579 161586 161591 161592 161597 161597 161602 161613 161615 161627 161634 161635 161642 161647 161649 161666 161676 161680 161682 161687 161689 161689 161691 161695 161698 161698 161702 161715 161718 161725 161730 161731 161736 161738 161740 161746 161748 161755 161758 161759 161761 161761 161763 161763 161766 161770 161775 161775 161777 161780 161785 161785 161788 161789 161791 161791 161794 161796 161798 161799 161801 161801 161803 161803 161806 161811 161816 161827 161832 161835 161837 161838 161840 161840 161845 161845 161851 161856 161861 161862 161864 161864 161867 161875 161877 161878 161880 161880 161883 161883 161885 161885 161888 161903 161911 161915 161917 161919 161922 161926 161933 161935 161938 161940 161942 161942 161946 161946 161948 161950 161954 161955 161957 161960 161963 161963 161965 161967 161969 161973 161975 161988 161992 161993 161997 162012 162017 162019 162021 162021 162024 162033 162036 162046 162051 162057 162059 162072 162075 162083 162086 162087 162089 162092 162094 162095 162097 162098 162102 162103 162106 162114 162116 162116 162120 162120 162122 162122 162124 162125 162129 162129 162131 162131 162133 162141 162145 162150 162152 162155 162157 162161 162163 162165 162167 162178 162182 162183 162191 162191 162194 162194 162199 162199 162201 162223 162234 162235 162238 162238 162241 162242 162244 162246 162248 162273 162279 162280 162282 162283 162288 162315 162329 162334 162336 162336 162339 162340 162342 162368 162370 162375 162384 162385 162390 162390 162392 162392 162394 162415 162417 162439 162452 162452 162454 162487 162489 162490 162495 162495 162507 162507 162511 162512 162514 162544 162546 162546 162552 162552 162554 162554 162557 162560 162562 162579 162581 162583 162588 162589 162591 162596 162599 162614 162623 162630 162632 162646 162648 162661 162663 162671 162676 162676 162679 162688 162691 162698 162702 162708 162712 162715 162717 162719 162722 162723 162725 162725 162728 162729 162731 162739 162741 162744 162746 162749 162752 162754 162758 162758 162761 162768 162771 162773 162776 162780 162784 162786 162789 162791 162793 162795 162797 162801 162803 162803 162807 162817 162819 162823 162825 162829 162832 162835 162837 162837 162840 162841 162848 162849 162851 162851 162853 162853 162855 162864 162866 162866 162868 162877 162879 162890 162893 162916 162920 162936 162939 162940 162942 162965 162967 162968 162970 162975 162977 162978 162980 162986 162988 162999 163006 163015 163017 163026 163028 163028 163030 163030 163033 163042 163045 163055 163058 163059 163061 163068 163073 163079 163084 163088 163092 163098 163101 163105 163107 163110 163114 163117 163122 163123 163125 163130 163140 163141 163143 163153 163164 163165 163168 163168 163171 163186 163197 163197 163199 163199 163202 163202 163205 163214 163225 163237 163242 163242 163249 163259 163268 163268 163271 163271 163273 163287 163294 163305 163314 163314 163317 163317 163323 163339 163345 163345 163348 163354 163358 163358 163365 163368 163371 163371 163375 163375 163377 163379 163383 163385 163389 163392 163398 163401 163406 163406 163416 163419 163421 163422 163424 163424 163427 163427 163431 163431 163436 163437 163439 163439 163442 163444 163446 163449 163453 163453 163460 163460 163462 163464 163470 163472 163474 163476 163478 163478 163485 163496 163506 163507 163510 163523 163534 163534 163537 163549 163559 163559 163563 163564 163567 163574 163576 163581 163583 163584 163593 163593 163598 163617 163621 163622 163624 163638 163649 163650 163652 163654 163657 163670 163677 163691 163693 163693 163695 163695 163699 163700 163702 163714 163720 163720 163723 163723 163725 163733 163737 163749 163752 163753 163755 163761 163764 163766 163768 163771 163776 163782 163785 163785 163789 163789 163794 163808 163811 163812 163814 163814 163822 163823 163825 163840 163846 163846 163859 163886 163894 163895 163904 163925 163929 163929 163932 163932 163934 163934 163936 163936 163938 163939 163955 163955 163957 163976 163983 163983 163985 163985 163987 163987 163995 164024 164031 164031 164050 164072 164078 164078 164095 164096 164099 164099 164101 164123 164135 164141 164165 164166 164168 164168 164170 164172 164174 164202 164209 164210 164212 164214 164224 164241 164250 164252 164262 164264 164266 164277 164289 164296 164298 164299 164303 164303 164308 164308 164310 164314 164317 164318 164324 164331 164333 164340 164347 164349 164355 164357 164360 164360 164363 164363 164367 164369 164371 164373 164376 164386 164393 164398 164404 164405 164408 164412 164416 164416 164418 164419 164424 164429 164436 164437 164439 164439 164443 164443 164450 164454 164462 164465 164473 164474 164479 164481 164486 164486 164490 164490 164493 164494 164498 164504 164507 164507 164509 164509 164512 164514 164519 164519 164521 164522 164527 164527 164529 164529 164531 164544 164550 164551 164556 164556 164558 164572 164582 164594 164601 164601 164604 164604 164609 164619 164621 164623 164630 164630 164637 164637 164639 164664 164672 164675 164677 164692 164694 164695 164703 164704 164707 164707 164711 164724 164726 164729 164731 164731 164735 164737 164740 164741 164743 164749 164752 164752 164757 164758 164760 164761 164764 164764 164769 164770 164772 164783 164785 164793 164798 164798 164801 164801 164805 164811 164814 164815 164817 164822 164824 164825 164829 164836 164838 164838 164840 164844 164847 164854 164856 164858 164861 164862 164865 164866 164875 164877 164879 164881 164884 164885 164888 164888 164891 164898 164904 164905 164911 164914 164917 164918 164921 164921 164924 164924 164926 164926 164928 164935 164937 164939 164941 164941 164943 164948 164952 164952 164955 164955 164958 164958 164960 164973 164981 164981 164983 164983 164988 164993 164995 165007 165018 165019 165021 165021 165024 165024 165026 165040 165042 165043 165052 165061 165063 165067 165069 165070 165074 165074 165078 165081 165083 165083 165085 165085 165092 165097 165099 165115 165117 165118 165120 165120 165123 165123 165125 165125 165131 165131 165142 165143 165145 165151 165153 165156 165158 165170 165197 165197 165199 165201 165203 165204 165206 165206 165210 165226 165240 165240 165244 165245 165249 165249 165251 165251 165254 165264 165267 165267 165273 165273 165277 165281 165283 165285 165290 165297 165299 165308 165310 165316 165323 165324 165328 165328 165331 165333 165335 165337 165342 165343 165345 165347 165349 165361 165370 165373 165377 165381 165383 165386 165388 165389 165393 165393 165395 165395 165401 165411 165418 165422 165424 165424 165426 165426 165429 165429 165431 165433 165436 165436 165439 165446 165454 165461 165463 165466 165468 165468 165470 165472 165475 165476 165478 165481 165483 165483 165485 165490 165493 165502 165506 165506 165513 165515 165517 165517 165519 165519 165521 165531 165536 165536 165538 165538 165541 165541 165544 165544 165548 165558 165563 165565 165567 165567 165569 165569 165571 165572 165574 165590 165593 165596 165598 165601 165603 165607 165611 165617 165619 165624 165627 165627 165631 165635 165637 165638 165640 165640 165643 165660 165667 165672 165674 165674 165678 165680 165682 165697 165699 165699 165703 165703 165705 165713 165715 165717 165719 165720 165723 165723 165725 165731 165733 165736 165738 165745 165747 165752 165760 165765 165767 165767 165769 165769 165772 165775 165777 165788 165790 165790 165792 165793 165798 165803 165806 165809 165811 165811 165813 165829 165832 165832 165837 165841 165844 165852 165854 165856 165858 165860 165862 165862 165864 165864 165867 165868 165870 165872 165874 165874 165876 165890 165894 165896 165898 165912 165922 165922 165924 165927 165934 165934 165942 165945 165950 165950 165953 165953 165957 165957 165963 165969 165971 165976 165981 165981 165984 165984 165986 165987 165993 166008 166016 166017 166019 166034 166041 166043 166048 166061 166063 166066 166069 166070 166073 166074 166077 166087 166091 166091 166094 166094 166096 166097 166099 166109 166112 166113 166115 166115 166118 166122 166125 166131 166134 166140 166142 166146 166149 166149 166151 166154 166156 166163 166165 166170 166173 166173 166177 166179 166181 166182 166184 166185 166188 166189 166196 166196 166199 166199 166201 166202 166206 166206 166208 166208 166210 166212 166218 166226 166242 166242 166245 166250 166258 166259 166261 166261 166265 166265 166267 166267 166274 166274 166276 166278 166294 166294 166297 166297 166300 166301 166303 166303 166307 166307 166316 166324 166327 166328 166334 166335 166350 166351 166355 166355 166357 166357 166361 166361 166363 166363 166373 166390 166398 166398 166444 166444 166446 166462 166505 166505 166508 166508 166517 166517 166521 166522 166532 166533 166535 166548 166550 166551 166559 166560 166582 166583 166588 166589 166607 166614 166616 166617 166630 166630 166649 166649 166651 166651 166653 166653 166659 166661 166669 166676 166678 166683 166685 166685 166687 166687 166724 166724 166727 166727 166739 166739 166741 166751 166780 166780 166782 166782 166784 166784 166787 166788 166802 166805 166807 166807 166810 166810 166827 166827 166831 166831 166839 166841 166843 166843 166845 166847 166852 166852 166866 166866 166868 166868 166878 166883 166906 166908 166917 166917 166921 166930 166941 166944 166948 166948 166953 166953 166958 166959 166962 166963 166968 166968 166999 167006 167010 167010 167012 167017 167027 167031 167034 167034 167039 167043 167046 167052 167059 167061 167063 167064 167066 167067 167069 167074 167077 167081 167085 167087 167090 167092 167094 167094 167096 167096 167098 167100 167102 167102 167104 167109 167113 167116 167119 167121 167126 167139 167141 167141 167152 167152 167154 167159 167161 167170 167181 167193 167197 167197 167199 167200 167205 167205 167208 167217 167219 167219 167224 167224 167231 167233 167236 167238 167240 167245 167247 167251 167255 167255 167260 167260 167266 167266 167268 167280 167282 167282 167285 167285 167287 167287 167289 167289 167296 167307 167318 167318 167322 167322 167324 167330 167340 167348 167350 167351 167358 167358 167361 167367 167378 167381 167385 167385 167396 167396 167398 167398 167402 167403 167408 167411 167415 167416 167419 167419 167439 167448 167450 167454 167467 167475 167489 167500 167502 167502 167507 167507 167509 167509 167512 167523 167527 167527 167541 167558 167583 167599 167605 167605 167615 167638 167640 167640 167654 167654 167656 167656 167658 167658 167663 167679 167686 167686 167688 167688 167690 167705 167718 167718 167722 167729 167741 167748 167757 167761 167766 167769 167773 167773 167775 167777 167781 167784 167786 167788 167790 167790 167793 167798 167800 167801 167804 167805 167807 167811 167813 167819 167821 167821 167823 167823 167825 167837 167840 167851 167854 167855 167858 167875 167878 167878 167880 167881 167883 167898 167902 167902 167904 167926 167929 167929 167933 167933 167935 167953 167956 167957 167959 167969 167972 167985 167988 168000 168002 168002 168005 168016 168018 168024 168027 168036 168039 168041 168043 168044 168048 168048 168050 168050 168053 168053 168055 168055 168057 168060 168066 168073 168082 168088 168097 168106 168108 168109 168115 168115 168117 168117 168119 168131 168140 168140 168144 168158 168160 168161 168180 168186 168188 168193 168196 168196 168201 168201 168214 168231 168235 168235 168237 168238 168247 168248 168250 168263 168265 168266 168270 168272 168274 168275 168285 168300 168305 168306 168310 168311 168316 168329 168337 168344 168346 168347 168351 168351 168356 168358 168363 168363 168365 168370 168373 168376 168378 168378 168381 168381 168383 168386 168388 168388 168391 168396 168398 168398 168401 168405 168407 168407 168411 168416 168419 168419 168422 168427 168429 168433 168437 168438 168440 168442 168444 168444 168446 168447 168451 168458 168460 168463 168465 168466 168470 168470 168473 168477 168479 168479 168481 168486 168488 168488 168491 168495 168497 168502 168504 168505 168507 168510 168512 168516 168519 168525 168529 168529 168532 168532 168534 168534 168537 168538 168541 168543 168545 168556 168568 168581 168584 168585 168587 168587 168592 168607 168613 168614 168617 168624 168626 168627 168631 168633 168636 168636 168639 168660 168667 168667 168669 168690 168693 168694 168696 168698 168700 168704 168707 168724 168730 168731 168733 168733 168736 168738 168742 168755 168758 168758 168761 168763 168766 168775 168777 168779 168782 168783 168785 168785 168787 168799 168804 168811 168814 168815 168817 168821 168823 168825 168830 168834 168836 168837 168839 168847 168849 168853 168855 168861 168865 168865 168868 168883 168885 168895 168897 168897 168899 168899 168901 168907 168910 168922 168926 168934 168936 168946 168948 168955 168961 168965 168967 168967 168969 168973 168975 168975 168979 168982 168984 168988 168990 169000 169003 169006 169008 169010 169012 169015 169017 169020 169022 169027 169029 169029 169031 169037 169040 169066 169068 169068 169070 169070 169072 169086 169088 169092 169094 169100 169103 169119 169122 169122 169124 169124 169126 169127 169130 169131 169133 169158 169169 169169 169171 169174 169176 169176 169181 169201 169208 169208 169210 169214 169216 169228 169235 169236 169241 169257 169263 169264 169267 169278 169280 169280 169282 169282 169285 169286 169288 169304 169309 169316 169318 169318 169321 169321 169323 169327 169329 169334 169336 169336 169338 169338 169340 169340 169342 169345 169348 169348 169350 169351 169354 169360 169363 169363 169369 169373 169377 169385 169388 169388 169390 169390 169392 169392 169394 169406 169409 169409 169412 169419 169427 169435 169437 169440 169442 169443 169448 169464 169473 169473 169475 169475 169477 169491 169493 169495 169497 169498 169500 169505 169508 169511 169517 169523 169525 169535 169537 169542 169544 169544 169546 169546 169550 169550 169553 169556 169558 169559 169561 169566 169569 169569 169572 169572 169585 169586 169588 169588 169590 169591 169594 169594 169596 169597 169600 169615 169618 169619 169621 169630 169635 169636 169640 169659 169663 169665 169669 169670 169672 169683 169691 169691 169693 169711 169715 169715 169721 169744 169746 169751 169754 169754 169759 169759 169762 169762 169772 169773 169775 169794 169801 169801 169815 169819 169821 169833 169835 169836 169838 169838 169840 169840 169844 169845 169848 169849 169852 169873 169881 169882 169886 169902 169906 169906 169909 169909 169911 169911 169914 169914 169916 169933 169939 169945 169947 169947 169955 169960 169962 169962 169965 169969 169972 169972 169974 169976 170000 170001 170005 170007 170009 170012 170018 170022 170026 170028 170032 170032 170034 170034 170039 170039 170041 170041 170043 170044 170046 170048 170052 170053 170056 170056 170058 170058 170060 170062 170064 170069 170072 170072 170074 170074 170077 170077 170081 170081 170084 170085 170087 170090 170094 170094 170096 170099 170101 170101 170103 170111 170118 170118 170120 170121 170124 170145 170151 170151 170157 170181 170183 170184 170186 170186 170188 170190 170192 170192 170194 170194 170197 170212 170221 170241 170249 170249 170256 170256 170258 170259 170262 170285 170291 170291 170295 170295 170299 170299 170301 170309 170311 170324 170326 170328 170332 170332 170334 170334 170338 170338 170340 170340 170347 170356 170362 170362 170368 170385 170388 170388 170393 170393 170395 170396 170398 170408 170419 170419 170422 170432 170434 170443 170446 170448 170452 170454 170456 170459 170464 170469 170513 170514 170517 170519 170523 170532 170534 170535 170540 170552 170554 170554 170557 170563 170566 170566 170569 170575 170579 170579 170581 170581 170583 170595 170598 170598 170605 170614 170616 170617 170621 170622 170624 170630 170633 170642 170644 170645 170647 170652 170656 170667 170669 170670 170674 170675 170679 170681 170683 170684 170686 170691 170697 170698 170702 170703 170709 170709 170711 170711 170714 170714 170718 170718 170720 170720 170725 170731 170733 170737 170739 170740 170743 170743 170745 170746 170751 170753 170755 170756 170761 170763 170767 170786 170800 170813 170819 170819 170823 170835 170840 170840 170842 170842 170845 170859 170871 170872 170874 170889 170902 170915 170918 170918 170926 170938 170941 170942 170947 170961 170971 170976 170980 170980 170982 170985 170989 170989 170992 170995 171000 171000 171002 171003 171007 171007 171009 171011 171013 171015 171017 171031 171033 171033 171036 171048 171050 171055 171057 171063 171065 171065 171068 171068 171070 171073 171075 171077 171079 171092 171094 171101 171103 171113 171115 171117 171119 171125 171127 171130 171133 171141 171144 171144 171146 171153 171156 171156 171160 171166 171169 171171 171173 171180 171187 171187 171190 171190 171193 171193 171195 171202 171205 171209 171211 171222 171224 171225 171229 171229 171231 171242 171245 171250 171253 171258 171264 171264 171267 171267 171270 171275 171277 171278 171280 171285 171288 171289 171291 171300 171304 171306 171309 171311 171313 171316 171318 171320 171322 171323 171327 171330 171332 171333 171335 171336 171338 171345 171348 171351 171355 171355 171360 171377 171382 171385 171392 171406 171409 171409 171414 171414 171418 171418 171422 171422 171424 171424 171426 171441 171446 171446 171453 171453 171455 171455 171458 171459 171467 171482 171484 171484 171500 171500 171502 171502 171508 171509 171511 171536 171551 171552 171554 171554 171557 171557 171559 171560 171577 171577 171580 171580 171582 171602 171618 171618 171633 171654 171673 171676 171691 171691 171693 171710 171721 171723 171725 171725 171734 171734 171736 171752 171762 171762 171764 171766 171778 171790 171792 171794 171800 171800 171804 171809 171813 171822 171825 171825 171828 171829 171835 171841 171852 171856 171859 171859 171861 171861 171864 171864 171866 171873 171875 171875 171879 171884 171888 171889 171891 171891 171893 171895 171919 171919 171921 171929 171931 171943 171948 171948 171952 171980 171984 171991 171995 172014 172017 172018 172023 172024 172028 172028 172032 172033 172039 172045 172047 172047 172050 172059 172061 172077 172088 172088 172090 172090 172092 172093 172095 172096 172104 172138 172141 172142 172144 172144 172146 172146 172151 172153 172155 172177 172179 172181 172186 172187 172189 172191 172193 172193 172195 172195 172197 172197 172202 172202 172205 172205 172212 172248 172250 172253 172256 172256 172260 172260 172262 172263 172265 172266 172271 172271 172278 172278 172281 172295 172297 172307 172311 172312 172315 172316 172318 172318 172320 172320 172329 172331 172333 172345 172347 172366 172374 172374 172378 172378 172380 172380 172383 172383 172385 172385 172398 172429 172433 172433 172436 172436 172438 172439 172442 172442 172445 172445 172449 172449 172456 172459 172461 172479 172481 172482 172484 172484 172486 172486 172489 172490 172497 172504 172506 172506 172508 172509 172512 172513 172524 172538 172540 172540 172543 172543 172545 172545 172547 172551 172553 172557 172560 172560 172562 172563 172568 172575 172578 172578 172580 172587 172590 172593 172596 172597 172599 172604 172607 172608 172630 172639 172641 172641 172643 172644 172646 172649 172653 172659 172661 172664 172666 172666 172668 172668 172671 172676 172678 172681 172683 172683 172685 172685 172687 172689 172691 172697 172699 172700 172709 172712 172714 172717 172719 172719 172721 172721 172723 172732 172739 172745 172747 172747 172749 172753 172756 172762 172764 172765 172769 172771 172773 172773 172775 172775 172778 172780 172782 172784 172786 172787 172791 172792 172794 172798 172801 172802 172805 172814 172816 172818 172820 172824 172826 172827 172829 172829 172832 172832 172834 172837 172840 172840 172844 172851 172856 172856 172859 172871 172873 172873 172875 172885 172888 172888 172890 172912 172914 172918 172920 172932 172934 172935 172946 172951 172954 172958 172960 172961 172963 172968 172970 172976 172978 172978 172980 172982 172985 172987 172989 172990 172993 172995 172998 173005 173009 173009 173011 173014 173016 173022 173025 173025 173028 173032 173036 173044 173046 173056 173058 173060 173063 173065 173067 173071 173073 173081 173083 173089 173092 173096 173098 173099 173106 173108 173113 173113 173119 173124 173128 173134 173138 173150 173155 173155 173157 173172 173175 173175 173182 173189 173192 173192 173195 173196 173199 173206 173208 173219 173223 173223 173225 173232 173236 173237 173240 173243 173246 173249 173251 173252 173254 173254 173257 173260 173262 173272 173274 173279 173281 173282 173284 173285 173287 173289 173292 173305 173307 173314 173316 173318 173320 173320 173322 173323 173325 173329 173332 173336 173339 173341 173346 173356 173358 173361 173363 173363 173365 173368 173370 173380 173382 173382 173384 173391 173393 173396 173399 173407 173409 173409 173412 173412 173415 173423 173425 173425 173429 173435 173437 173443 173445 173448 173451 173464 173466 173467 173473 173482 173486 173488 173491 173491 173493 173495 173499 173502 173505 173506 173509 173511 173513 173517 173519 173522 173524 173525 173528 173549 173551 173551 173554 173554 173557 173569 173572 173573 173578 173579 173581 173592 173595 173596 173599 173602 173604 173610 173612 173614 173616 173616 173618 173618 173620 173620 173622 173635 173638 173651 173654 173663 173667 173671 173673 173674 173676 173676 173678 173678 173680 173680 173682 173689 173691 173693 173695 173700 173702 173702 173704 173705 173707 173710 173713 173715 173717 173721 173724 173728 173733 173736 173739 173745 173747 173747 173749 173764 173768 173768 173770 173771 173773 173782 194560 194566 194568 194571 194573 194575 194577 194590 194592 194595 194597 194611 194613 194623 194625 194649 194651 194656 194658 194659 194661 194664 194666 194669 194671 194680 194682 194690 194692 194707 194710 194717 194719 194721 194723 194743 194745 194750 194752 194755 194757 194758 194760 194761 194763 194764 194767 194768 194770 194780 194782 194794 194796 194802 194804 194805 194807 194808 194810 194810 194812 194821 194823 194828 194830 194832 194834 194834 194836 194843 194845 194845 194848 194857 194859 194859 194862 194862 194864 194865 194867 194874 194876 194878 194880 194884 194886 194889 194891 194897 194899 194899 194901 194911 194913 194913 194915 194924 194926 194931 194933 194936 194938 194939 194941 194942 194944 194949 194953 194961 194963 194963 194965 194969 194971 194982 194984 194987 194989 194989 194991 194993 194995 195003 195005 195005 195007 195015 195017 195017 195019 195021 195023 195027 195029 195033 195035 195046 195048 195050 195052 195052 195054 195056 195058 195063 195065 195080 195082 195090 195092 195101 917504 917631)) (make-character-set :mib-enum 5 :name "ISO_8859-2:1987" :aliases '("csISOLatin2" "l2" "latin2" #13="ISO-8859-2" "ISO_8859-2" "iso-ir-101") :mime-encoding '#13# :source '"ECMA registry" :comments '("Alias: ISO-8859-2 (preferred MIME name)") :references '("[RFC1345,KXS2]") :ranges #(0 160 164 164 167 168 173 173 176 176 180 180 184 184 193 194 196 196 199 199 201 201 203 203 205 206 211 212 214 215 218 218 220 221 223 223 225 226 228 228 231 231 233 233 235 235 237 238 243 244 246 247 250 250 252 253 258 263 268 273 280 283 313 314 317 318 321 324 327 328 336 337 340 341 344 347 350 357 366 369 377 382 711 711 728 729 731 731 733 733)) (make-character-set :mib-enum 6 :name "ISO_8859-3:1988" :aliases '("csISOLatin3" "l3" "latin3" #14="ISO-8859-3" "ISO_8859-3" "iso-ir-109") :mime-encoding '#14# :source '"ECMA registry" :comments '("Alias: ISO-8859-3 (preferred MIME name)") :references '("[RFC1345,KXS2]") :ranges #(0 160 163 164 167 168 173 173 176 176 178 181 183 184 189 189 192 194 196 196 199 207 209 212 214 215 217 220 223 226 228 228 231 239 241 244 246 247 249 252 264 267 284 289 292 295 304 305 308 309 348 351 364 365 379 380 728 729)) (make-character-set :mib-enum 2013 :name "IBM862" :aliases '("csPC862LatinHebrew" "862" "cp862") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges #(0 127 160 163 165 165 170 172 176 178 183 183 186 189 191 191 209 209 223 223 225 225 237 237 241 241 243 243 247 247 250 250 402 402 915 915 920 920 931 931 934 934 937 937 945 945 948 949 956 956 960 960 963 964 966 966 1488 1514 8319 8319 8359 8359 8729 8730 8734 8734 8745 8745 8776 8776 8801 8801 8804 8805 8976 8976 8992 8993 9472 9472 9474 9474 9484 9484 9488 9488 9492 9492 9496 9496 9500 9500 9508 9508 9516 9516 9524 9524 9532 9532 9552 9580 9600 9600 9604 9604 9608 9608 9612 9612 9616 9619 9632 9632)) (make-character-set :mib-enum 109 :name "ISO-8859-13" :aliases 'nil :mime-encoding 'nil :source '"ISO See (http://www.iana.org/assignments/charset-reg/ISO-8859-13)[Tumasonis]" :comments 'nil :references 'nil :ranges #(0 160 162 164 166 167 169 169 171 174 176 179 181 183 185 185 187 190 196 198 201 201 211 211 213 216 220 220 223 223 228 230 233 233 243 243 245 248 252 252 256 257 260 263 268 269 274 275 278 281 290 291 298 299 302 303 310 311 315 316 321 326 332 333 342 343 346 347 352 353 362 363 370 371 377 382 8217 8217 8220 8222)) (make-character-set :mib-enum 110 :name "ISO-8859-14" :aliases '("l8" "iso-celtic" "latin8" "ISO_8859-14" "ISO_8859-14:1998" "iso-ir-199") :mime-encoding 'nil :source '"ISO See (http://www.iana.org/assignments/charset-reg/ISO-8859-14) [Simonsen]" :comments 'nil :references 'nil :ranges #(0 160 163 163 167 167 169 169 173 174 182 182 192 207 209 214 216 221 223 239 241 246 248 253 255 255 266 267 288 289 372 376 7682 7683 7690 7691 7710 7711 7744 7745 7766 7767 7776 7777 7786 7787 7808 7813 7922 7923)) (make-character-set :mib-enum 2258 :name "windows-1258" :aliases 'nil :mime-encoding 'nil :source '"Microsoft (http://www.iana.org/assignments/charset-reg/windows-1258) [Lazhintseva]" :comments 'nil :references 'nil :ranges #(0 127 160 207 209 221 223 239 241 253 255 255 258 259 262 263 272 273 296 297 313 314 323 324 338 341 346 347 360 361 376 378 402 402 416 417 431 432 471 472 475 476 500 501 504 511 710 710 732 732 768 769 771 771 777 777 803 803 832 833 901 901 7684 7685 7688 7689 7692 7693 7716 7717 7726 7731 7734 7735 7742 7743 7746 7747 7750 7751 7756 7759 7764 7765 7770 7771 7778 7779 7788 7789 7800 7801 7804 7811 7816 7817 7826 7827 7840 7929 8173 8174 8211 8212 8216 8218 8220 8222 8224 8226 8230 8230 8240 8240 8249 8250 8363 8364 8482 8482 917504 917631)) (make-character-set :mib-enum 111 :name "ISO-8859-15" :aliases '("Latin-9" "ISO_8859-15") :mime-encoding 'nil :source '"ISO Please see: <http://www.iana.org/assignments/charset-reg/ISO-8859-15>" :comments 'nil :references 'nil :ranges #(0 163 165 165 167 167 169 179 181 183 185 187 191 255 338 339 352 353 376 376 381 382 8364 8364)) (make-character-set :mib-enum 112 :name "ISO-8859-16" :aliases '("l10" "latin10" "ISO_8859-16" "ISO_8859-16:2001" "iso-ir-226") :mime-encoding 'nil :source '"ISO" :comments 'nil :references 'nil :ranges #(0 160 167 167 169 169 171 171 173 173 176 177 182 183 187 187 192 194 196 196 198 207 210 212 214 214 217 220 223 226 228 228 230 239 242 244 246 246 249 252 255 255 258 263 268 269 272 273 280 281 321 324 336 339 346 347 352 353 368 369 376 382 536 539 8221 8222 8364 8364)) (make-character-set :mib-enum 2025 :name #15="GB2312" :aliases '("csGB2312") :mime-encoding '#15# :source '"Chinese for People's Republic of China (PRC) mixed one byte, two byte set: 20-7E = one byte ASCII A1-FE = two byte PRC Kanji See GB 2312-80 PCL Symbol Set Id: 18C" :comments 'nil :references 'nil :ranges #(0 127 164 164 167 168 176 177 215 215 224 225 232 234 236 237 242 243 247 247 249 250 252 252 257 257 275 275 283 283 299 299 333 333 363 363 462 462 464 464 466 466 468 468 470 470 472 472 474 474 476 476 711 711 713 713 913 929 931 937 945 961 963 969 1025 1025 1040 1103 1105 1105 8213 8214 8216 8217 8220 8221 8230 8230 8240 8240 8242 8243 8251 8251 8451 8451 8470 8470 8544 8555 8592 8595 8712 8712 8719 8719 8721 8721 8730 8730 8733 8734 8736 8736 8741 8741 8743 8747 8750 8750 8756 8759 8765 8765 8776 8776 8780 8780 8800 8801 8804 8805 8814 8815 8857 8857 8869 8869 8978 8978 9312 9321 9332 9371 9472 9547 9632 9633 9650 9651 9670 9671 9675 9675 9678 9679 9733 9734 9792 9792 9794 9794 12288 12291 12293 12293 12296 12305 12307 12311 12353 12435 12449 12534 12539 12539 12549 12585 12832 12841 19968 19969 19971 19971 19975 19982 19984 19985 19987 19990 19992 19998 20002 20002 20004 20005 20007 20008 20010 20013 20016 20016 20018 20018 20020 20020 20022 20022 20024 20027 20029 20031 20035 20035 20037 20037 20039 20041 20043 20048 20050 20052 20054 20054 20056 20057 20060 20065 20070 20070 20073 20073 20080 20081 20083 20083 20094 20094 20102 20102 20104 20105 20107 20111 20113 20117 20120 20120 20122 20123 20127 20130 20132 20137 20139 20142 20146 20147 20149 20149 20154 20155 20159 20167 20169 20171 20173 20174 20177 20177 20179 20185 20189 20191 20193 20193 20195 20197 20200 20200 20202 20204 20208 20208 20210 20211 20213 20215 20219 20219 20221 20221 20223 20223 20225 20225 20233 20234 20237 20241 20247 20251 20254 20256 20258 20258 20260 20263 20266 20267 20271 20272 20274 20274 20276 20276 20278 20278 20280 20280 20282 20282 20284 20285 20291 20291 20294 20294 20301 20305 20307 20307 20309 20309 20311 20320 20323 20325 20327 20327 20329 20329 20332 20332 20335 20336 20339 20340 20342 20342 20347 20348 20350 20351 20355 20356 20360 20361 20363 20363 20365 20365 20367 20367 20369 20369 20372 20372 20375 20375 20379 20379 20381 20381 20384 20384 20387 20387 20389 20394 20396 20396 20398 20399 20405 20405 20415 20415 20419 20421 20426 20426 20430 20433 20439 20440 20442 20442 20444 20447 20449 20449 20451 20451 20454 20454 20456 20458 20461 20463 20465 20465 20467 20467 20472 20472 20474 20474 20478 20478 20492 20493 20495 20495 20498 20498 20500 20500 20504 20506 20508 20508 20511 20511 20513 20513 20517 20518 20520 20522 20524 20526 20538 20538 20540 20540 20542 20542 20547 20547 20551 20552 20556 20556 20558 20559 20565 20565 20570 20570 20572 20572 20581 20581 20588 20588 20598 20599 20603 20603 20606 20608 20613 20613 20616 20616 20621 20621 20643 20643 20645 20645 20647 20649 20652 20652 20658 20658 20666 20667 20687 20687 20694 20694 20698 20698 20710 20711 20716 20718 20723 20723 20725 20725 20731 20731 20742 20743 20747 20747 20754 20754 20769 20769 20799 20801 20803 20806 20808 20809 20811 20811 20813 20813 20817 20817 20820 20822 20826 20826 20828 20828 20834 20834 20837 20837 20840 20840 20843 20846 20848 20849 20851 20857 20859 20861 20864 20866 20869 20869 20872 20873 20876 20877 20882 20882 20885 20887 20889 20889 20891 20892 20896 20896 20898 20898 20900 20901 20907 20908 20911 20915 20917 20919 20923 20925 20928 20928 20932 20932 20934 20935 20937 20937 20939 20940 20943 20943 20945 20945 20955 20955 20957 20957 20960 20961 20964 20964 20971 20971 20973 20973 20975 20976 20979 20979 20981 20982 20984 20989 20991 20995 20998 21000 21002 21002 21005 21006 21009 21010 21014 21019 21021 21021 21024 21024 21028 21028 21032 21033 21035 21035 21037 21038 21040 21040 21043 21043 21046 21051 21053 21053 21055 21059 21066 21066 21068 21069 21072 21073 21076 21076 21078 21078 21084 21084 21086 21086 21089 21089 21093 21093 21095 21095 21097 21098 21103 21103 21106 21106 21117 21117 21119 21119 21121 21122 21128 21128 21136 21136 21139 21139 21147 21147 21149 21155 21160 21165 21169 21171 21182 21183 21187 21187 21191 21191 21193 21193 21195 21195 21200 21200 21202 21202 21206 21206 21208 21208 21215 21215 21220 21220 21232 21232 21241 21242 21246 21248 21253 21254 21256 21256 21261 21261 21263 21264 21269 21271 21273 21274 21277 21277 21280 21281 21283 21283 21286 21286 21290 21290 21294 21294 21305 21307 21310 21311 21313 21313 21315 21315 21317 21317 21319 21322 21326 21327 21329 21331 21333 21335 21338 21338 21340 21340 21342 21348 21350 21351 21353 21353 21355 21355 21358 21361 21363 21365 21367 21368 21370 21370 21375 21375 21378 21378 21380 21382 21385 21385 21387 21389 21397 21397 21400 21400 21402 21402 21405 21405 21407 21407 21410 21411 21413 21414 21416 21417 21422 21422 21430 21430 21435 21435 21439 21439 21441 21442 21448 21453 21457 21457 21460 21460 21462 21465 21467 21467 21471 21472 21475 21478 21480 21491 21493 21497 21499 21501 21505 21505 21507 21508 21510 21510 21512 21514 21516 21523 21525 21527 21531 21531 21533 21537 21539 21539 21542 21545 21547 21551 21553 21554 21556 21557 21560 21561 21563 21564 21566 21566 21568 21568 21571 21571 21574 21574 21576 21576 21578 21579 21584 21584 21586 21593 21595 21596 21602 21602 21604 21604 21606 21606 21608 21608 21617 21619 21621 21624 21627 21629 21632 21632 21634 21634 21636 21636 21638 21638 21643 21644 21646 21648 21650 21650 21652 21654 21657 21659 21661 21661 21667 21668 21670 21677 21679 21679 21681 21681 21683 21684 21688 21688 21691 21691 21693 21693 21695 21698 21700 21700 21702 21705 21708 21717 21719 21719 21721 21722 21724 21727 21733 21738 21741 21742 21746 21747 21754 21754 21756 21757 21759 21759 21761 21761 21766 21767 21769 21769 21775 21777 21780 21780 21787 21787 21792 21792 21794 21796 21799 21799 21802 21802 21804 21804 21806 21809 21811 21811 21815 21815 21820 21820 21822 21823 21825 21825 21827 21828 21830 21830 21833 21834 21840 21840 21845 21846 21852 21852 21857 21857 21860 21863 21866 21866 21868 21870 21877 21880 21883 21884 21886 21886 21888 21892 21895 21899 21903 21903 21905 21905 21908 21908 21912 21913 21916 21917 21919 21919 21927 21927 21937 21937 21939 21939 21941 21941 21943 21943 21945 21945 21947 21947 21949 21950 21956 21957 21961 21961 21964 21965 21969 21972 21974 21974 21980 21981 21983 21983 21985 21985 21987 21990 21992 21992 21994 21996 21999 21999 22002 22003 22005 22005 22007 22007 22013 22014 22016 22017 22024 22025 22028 22028 22030 22031 22040 22040 22043 22043 22046 22047 22051 22052 22055 22055 22060 22061 22065 22066 22068 22068 22070 22070 22073 22073 22075 22075 22079 22079 22092 22094 22100 22100 22103 22105 22108 22108 22114 22114 22116 22116 22120 22124 22129 22129 22134 22134 22139 22140 22149 22150 22158 22159 22163 22163 22179 22179 22191 22191 22199 22199 22204 22204 22218 22218 22228 22228 22231 22231 22234 22235 22237 22242 22244 22244 22251 22251 22253 22253 22256 22257 22260 22261 22265 22266 22269 22271 22275 22276 22278 22278 22280 22282 22300 22300 22303 22303 22307 22307 22312 22314 22316 22320 22323 22323 22329 22331 22334 22334 22336 22336 22338 22338 22343 22343 22346 22346 22348 22353 22359 22359 22362 22369 22372 22372 22374 22374 22376 22379 22381 22381 22383 22383 22387 22387 22390 22391 22395 22396 22402 22406 22411 22412 22418 22419 22427 22427 22432 22436 22438 22439 22441 22441 22443 22443 22445 22446 22450 22450 22452 22452 22456 22456 22466 22467 22475 22475 22478 22479 22482 22482 22484 22485 22488 22490 22493 22493 22495 22496 22500 22500 22509 22509 22511 22511 22516 22516 22520 22522 22525 22525 22528 22528 22530 22530 22534 22535 22539 22539 22541 22541 22545 22545 22549 22549 22553 22553 22558 22558 22560 22561 22564 22564 22570 22570 22576 22576 22581 22581 22596 22596 22604 22605 22609 22609 22612 22612 22616 22616 22622 22622 22629 22629 22635 22636 22654 22654 22656 22657 22659 22659 22661 22661 22665 22665 22674 22675 22681 22682 22686 22687 22696 22697 22716 22716 22721 22721 22725 22725 22737 22737 22741 22741 22756 22756 22763 22764 22766 22766 22768 22768 22771 22771 22774 22774 22777 22777 22786 22786 22788 22788 22791 22791 22797 22797 22799 22799 22804 22806 22809 22810 22812 22812 22815 22815 22820 22821 22823 22823 22825 22827 22829 22831 22833 22833 22836 22836 22839 22842 22844 22844 22849 22850 22852 22852 22855 22857 22859 22859 22862 22863 22865 22865 22868 22872 22874 22874 22880 22880 22882 22882 22885 22885 22899 22900 22902 22902 22904 22905 22909 22909 22913 22916 22918 22920 22922 22922 22925 22925 22930 22931 22934 22935 22937 22937 22942 22942 22947 22949 22952 22955 22958 22959 22962 22962 22969 22969 22971 22971 22974 22974 22982 22982 22986 22987 22992 22996 22999 23000 23002 23002 23004 23005 23011 23011 23013 23013 23016 23016 23020 23020 23033 23033 23035 23035 23039 23039 23041 23041 23043 23049 23052 23052 23057 23057 23059 23059 23064 23064 23068 23068 23071 23072 23075 23075 23077 23077 23081 23081 23089 23090 23092 23092 23094 23094 23100 23100 23104 23104 23110 23110 23113 23114 23125 23125 23130 23130 23138 23138 23143 23143 23146 23146 23156 23159 23162 23162 23167 23167 23186 23186 23194 23195 23210 23210 23218 23219 23221 23221 23224 23224 23230 23230 23233 23234 23241 23241 23244 23244 23250 23250 23252 23252 23254 23254 23256 23256 23260 23260 23264 23265 23267 23267 23270 23270 23273 23273 23275 23275 23281 23281 23305 23305 23318 23319 23346 23346 23348 23348 23351 23351 23360 23360 23376 23377 23379 23381 23383 23389 23391 23391 23394 23398 23401 23402 23404 23404 23408 23409 23411 23411 23413 23413 23418 23418 23421 23421 23424 23425 23427 23429 23431 23433 23435 23436 23439 23439 23443 23443 23445 23445 23447 23454 23456 23462 23466 23467 23472 23472 23475 23478 23480 23481 23485 23487 23490 23490 23492 23495 23500 23500 23504 23504 23506 23507 23517 23519 23521 23521 23524 23525 23528 23528 23534 23534 23536 23536 23544 23548 23551 23551 23553 23553 23556 23556 23558 23558 23561 23562 23567 23567 23569 23569 23572 23574 23576 23576 23578 23578 23580 23581 23586 23586 23588 23589 23591 23591 23596 23596 23601 23601 23604 23604 23608 23618 23621 23621 23624 23627 23630 23633 23637 23637 23641 23641 23646 23646 23648 23649 23651 23651 23653 23654 23662 23663 23665 23665 23673 23674 23679 23679 23681 23682 23688 23688 23692 23693 23696 23697 23700 23700 23702 23708 23714 23715 23721 23721 23723 23725 23729 23729 23731 23731 23733 23733 23735 23736 23741 23741 23743 23743 23745 23745 23748 23748 23755 23755 23762 23762 23769 23769 23777 23777 23780 23782 23784 23784 23786 23786 23789 23789 23792 23792 23803 23803 23810 23811 23814 23815 23822 23822 23828 23828 23830 23830 23835 23835 23838 23838 23844 23844 23846 23847 23849 23849 23853 23854 23860 23860 23869 23870 23879 23879 23882 23884 23896 23896 23899 23899 23901 23901 23913 23913 23915 23916 23919 23919 23924 23924 23938 23938 23961 23961 23965 23965 23991 23991 24005 24005 24013 24013 24027 24027 24029 24030 24033 24034 24037 24041 24043 24043 24046 24047 24049 24052 24055 24055 24061 24062 24065 24067 24069 24070 24072 24072 24076 24076 24079 24081 24084 24086 24088 24093 24102 24103 24109 24110 24113 24113 24119 24120 24123 24125 24130 24130 24132 24133 24140 24140 24148 24149 24155 24155 24158 24158 24161 24162 24178 24180 24182 24182 24184 24184 24186 24189 24191 24192 24196 24196 24198 24199 24202 24203 24207 24209 24211 24215 24217 24218 24220 24220 24222 24224 24229 24231 24237 24237 24243 24243 24245 24249 24254 24254 24265 24266 24273 24275 24278 24278 24283 24283 24296 24296 24298 24298 24308 24308 24310 24311 24314 24314 24318 24324 24328 24328 24330 24331 24335 24335 24337 24337 24339 24339 24341 24341 24343 24344 24347 24347 24351 24352 24357 24359 24361 24362 24365 24365 24367 24367 24369 24369 24377 24378 24380 24380 24384 24384 24400 24400 24402 24403 24405 24408 24413 24413 24417 24418 24420 24420 24422 24422 24425 24426 24428 24429 24432 24433 24435 24435 24439 24439 24441 24441 24443 24444 24448 24450 24452 24453 24455 24460 24464 24464 24466 24466 24469 24469 24471 24473 24476 24476 24481 24481 24488 24488 24490 24490 24493 24494 24501 24501 24503 24503 24508 24509 24515 24518 24521 24521 24524 24525 24527 24530 24534 24537 24541 24541 24544 24545 24548 24548 24551 24551 24554 24555 24557 24558 24561 24561 24565 24565 24568 24568 24571 24571 24573 24582 24586 24586 24589 24591 24594 24594 24596 24598 24601 24601 24603 24605 24608 24609 24613 24619 24623 24623 24629 24629 24635 24636 24639 24639 24641 24643 24651 24651 24653 24653 24656 24656 24658 24658 24661 24661 24665 24666 24669 24669 24674 24676 24679 24685 24687 24688 24691 24691 24694 24694 24696 24701 24703 24703 24707 24708 24713 24713 24716 24717 24722 24722 24724 24724 24726 24726 24730 24731 24733 24733 24735 24736 24739 24739 24742 24742 24744 24744 24747 24749 24751 24751 24753 24754 24756 24756 24760 24760 24763 24764 24773 24774 24778 24779 24785 24785 24789 24789 24792 24792 24794 24794 24796 24797 24799 24800 24806 24809 24811 24816 24819 24820 24822 24822 24825 24826 24832 24833 24838 24838 24840 24841 24845 24847 24853 24853 24858 24858 24863 24864 24867 24868 24870 24871 24875 24875 24895 24895 24904 24904 24906 24906 24908 24908 24910 24910 24913 24913 24917 24917 24925 24925 24930 24930 24935 24936 24944 24944 24949 24949 24951 24951 24971 24971 24974 24974 24980 24980 24989 24989 24999 25001 25004 25004 25015 25015 25022 25022 25026 25026 25032 25032 25034 25035 25041 25042 25044 25044 25062 25062 25077 25077 25087 25087 25094 25094 25096 25096 25098 25106 25109 25112 25114 25115 25119 25119 25121 25122 25124 25125 25130 25130 25132 25132 25134 25134 25139 25140 25143 25143 25149 25153 25155 25155 25159 25161 25163 25166 25169 25172 25176 25176 25179 25179 25187 25187 25190 25191 25193 25200 25203 25203 25206 25206 25209 25209 25212 25212 25214 25216 25220 25220 25225 25226 25233 25235 25237 25240 25242 25243 25247 25250 25252 25253 25256 25256 25259 25260 25265 25265 25269 25269 25273 25273 25275 25277 25279 25279 25282 25282 25284 25290 25292 25294 25296 25296 25298 25300 25302 25308 25311 25311 25314 25315 25317 25321 25324 25327 25329 25329 25331 25332 25334 25335 25340 25343 25345 25346 25351 25353 25358 25358 25361 25361 25366 25366 25370 25371 25373 25381 25384 25384 25386 25387 25391 25391 25394 25394 25401 25402 25405 25405 25410 25411 25413 25414 25417 25417 25419 25424 25429 25429 25438 25439 25441 25443 25447 25447 25449 25449 25453 25454 25457 25457 25462 25463 25466 25467 25472 25472 25474 25474 25479 25482 25484 25484 25486 25488 25490 25490 25494 25494 25496 25496 25504 25504 25506 25507 25509 25509 25511 25514 25516 25518 25520 25520 25523 25524 25527 25528 25530 25530 25532 25532 25534 25534 25540 25540 25542 25542 25545 25545 25549 25552 25554 25554 25558 25558 25566 25566 25568 25569 25571 25571 25577 25578 25581 25581 25586 25586 25588 25588 25590 25590 25592 25592 25597 25597 25599 25602 25605 25605 25611 25612 25615 25616 25619 25620 25627 25628 25630 25630 25632 25633 25638 25638 25642 25642 25644 25645 25652 25652 25658 25658 25661 25661 25663 25663 25665 25665 25668 25672 25674 25674 25682 25682 25684 25684 25688 25688 25694 25694 25703 25703 25705 25705 25709 25709 25720 25722 25730 25730 25732 25733 25735 25735 25745 25746 25749 25750 25753 25753 25758 25758 25764 25764 25769 25769 25772 25774 25776 25776 25781 25781 25783 25784 25786 25786 25788 25788 25792 25792 25794 25794 25797 25797 25805 25806 25808 25808 25810 25810 25815 25816 25822 25822 25826 25826 25828 25828 25830 25830 25856 25856 25865 25865 25874 25874 25880 25880 25893 25893 25899 25899 25902 25903 25908 25910 25912 25913 25915 25915 25918 25919 25925 25925 25928 25929 25932 25932 25935 25935 25937 25937 25941 25942 25945 25945 25947 25947 25949 25950 25954 25955 25958 25958 25963 25964 25968 25968 25970 25970 25972 25972 25975 25975 25991 25991 25995 25996 26000 26001 26003 26003 26007 26007 26009 26009 26011 26012 26015 26015 26017 26017 26020 26021 26023 26023 26025 26025 26027 26027 26029 26029 26031 26032 26041 26041 26044 26045 26049 26049 26051 26054 26059 26060 26062 26063 26066 26066 26070 26071 26080 26080 26082 26082 26085 26089 26092 26097 26102 26103 26106 26106 26112 26112 26114 26115 26118 26118 26122 26122 26124 26124 26126 26127 26131 26133 26137 26137 26141 26141 26143 26144 26149 26149 26151 26152 26157 26157 26159 26159 26161 26161 26164 26166 26172 26172 26174 26174 26177 26177 26179 26179 26187 26188 26191 26191 26194 26199 26202 26202 26207 26207 26209 26209 26212 26212 26214 26214 26216 26216 26222 26224 26228 26228 26230 26231 26234 26234 26238 26238 26242 26242 26244 26244 26247 26247 26252 26252 26257 26257 26262 26263 26269 26269 26279 26280 26286 26286 26292 26292 26297 26297 26302 26302 26329 26329 26331 26333 26342 26342 26345 26345 26352 26352 26354 26356 26359 26359 26361 26361 26364 26364 26366 26368 26376 26379 26381 26381 26384 26384 26388 26389 26391 26391 26395 26395 26397 26397 26399 26399 26406 26406 26408 26408 26410 26413 26415 26415 26417 26417 26420 26421 26426 26426 26429 26429 26432 26432 26434 26435 26438 26438 26440 26441 26444 26444 26446 26449 26451 26451 26454 26454 26460 26460 26462 26465 26469 26469 26472 26474 26477 26477 26479 26480 26482 26483 26485 26485 26487 26487 26492 26492 26494 26495 26497 26497 26500 26500 26503 26503 26505 26505 26507 26507 26512 26512 26517 26517 26519 26520 26522 26522 26524 26526 26530 26531 26533 26533 26535 26536 26538 26539 26541 26541 26543 26544 26547 26547 26549 26552 26561 26561 26563 26564 26575 26580 26584 26586 26588 26590 26592 26592 26594 26594 26597 26597 26601 26601 26604 26604 26607 26609 26611 26612 26621 26621 26623 26624 26629 26629 26631 26636 26638 26639 26641 26641 26643 26643 26646 26647 26653 26653 26657 26657 26665 26666 26674 26675 26679 26681 26684 26686 26688 26694 26696 26698 26700 26700 26702 26702 26704 26705 26707 26709 26720 26729 26731 26731 26740 26740 26742 26743 26753 26753 26755 26755 26757 26758 26767 26767 26771 26771 26775 26775 26786 26786 26790 26792 26797 26797 26799 26800 26803 26803 26805 26805 26816 26816 26818 26818 26825 26825 26827 26827 26829 26829 26834 26834 26837 26837 26840 26840 26842 26842 26848 26848 26851 26851 26862 26862 26864 26865 26869 26869 26873 26874 26876 26876 26881 26881 26885 26885 26891 26891 26893 26894 26896 26896 26898 26898 26911 26912 26916 26916 26925 26925 26928 26928 26932 26932 26937 26937 26941 26941 26943 26943 26946 26946 26964 26964 26967 26967 26970 26970 26973 26974 26976 26976 26979 26979 26982 26982 26987 26987 26990 26990 26993 26993 26999 27001 27004 27004 27008 27008 27010 27010 27012 27012 27014 27017 27021 27021 27028 27029 27032 27032 27035 27036 27047 27048 27051 27051 27053 27053 27057 27057 27060 27060 27063 27063 27067 27067 27073 27073 27082 27082 27084 27084 27086 27086 27088 27088 27092 27092 27099 27099 27103 27104 27117 27117 27122 27122 27133 27133 27135 27135 27146 27146 27159 27160 27167 27167 27169 27169 27176 27176 27178 27178 27183 27183 27185 27185 27189 27189 27197 27198 27204 27204 27207 27207 27216 27216 27224 27225 27227 27227 27233 27233 27237 27237 27249 27249 27257 27257 27260 27260 27264 27264 27268 27268 27278 27278 27280 27281 27287 27287 27296 27296 27305 27305 27307 27308 27424 27428 27431 27431 27442 27442 27447 27447 27449 27450 27454 27454 27459 27459 27462 27463 27465 27465 27468 27468 27481 27481 27490 27495 27498 27498 27513 27513 27515 27516 27521 27524 27526 27527 27529 27531 27533 27533 27538 27539 27542 27542 27546 27547 27553 27553 27562 27562 27571 27573 27575 27575 27583 27583 27585 27586 27589 27589 27595 27595 27597 27597 27599 27599 27602 27607 27609 27609 27611 27611 27617 27617 27626 27627 27631 27631 27635 27635 27637 27637 27641 27641 27645 27645 27653 27655 27661 27661 27663 27665 27667 27670 27672 27675 27679 27679 27681 27682 27684 27684 27686 27690 27694 27696 27698 27698 27700 27701 27704 27704 27709 27709 27712 27714 27718 27719 27721 27722 27728 27728 27732 27733 27735 27735 27739 27745 27748 27748 27752 27754 27760 27760 27762 27762 27764 27764 27766 27766 27769 27769 27773 27774 27777 27779 27781 27782 27784 27785 27788 27788 27791 27792 27795 27796 27801 27801 27803 27803 27807 27807 27809 27809 27811 27815 27817 27819 27821 27822 27825 27827 27832 27833 27835 27839 27844 27845 27849 27850 27852 27852 27856 27856 27859 27863 27867 27867 27870 27870 27872 27875 27877 27877 27880 27880 27882 27883 27886 27889 27891 27891 27893 27896 27898 27902 27905 27905 27908 27908 27911 27911 27915 27916 27918 27918 27922 27922 27927 27927 27929 27931 27934 27934 27941 27941 27943 27943 27946 27947 27950 27950 27953 27955 27957 27957 27961 27961 27963 27966 27969 27969 27971 27971 27973 27976 27978 27979 27981 27983 27985 27988 27993 27994 27996 27996 27998 27998 28000 28000 28003 28003 28006 28006 28009 28010 28014 28015 28020 28020 28023 28024 28028 28028 28034 28034 28037 28037 28040 28041 28044 28044 28046 28046 28049 28049 28051 28053 28059 28059 28061 28065 28067 28068 28070 28075 28078 28079 28082 28082 28085 28085 28088 28088 28095 28096 28100 28103 28107 28108 28113 28113 28118 28118 28120 28121 28125 28126 28128 28129 28132 28132 28134 28134 28139 28140 28142 28142 28145 28145 28147 28147 28151 28151 28153 28153 28155 28156 28165 28165 28170 28170 28172 28174 28176 28177 28180 28180 28182 28183 28186 28186 28189 28189 28192 28193 28195 28197 28201 28201 28203 28203 28205 28205 28207 28207 28210 28210 28212 28212 28216 28216 28218 28218 28227 28228 28237 28238 28243 28244 28246 28246 28248 28248 28251 28251 28255 28255 28267 28267 28270 28270 28286 28287 28291 28291 28293 28294 28297 28297 28303 28304 28312 28312 28316 28316 28319 28319 28322 28322 28325 28325 28327 28327 28330 28330 28335 28335 28337 28338 28340 28340 28342 28343 28346 28347 28349 28349 28353 28354 28359 28359 28363 28363 28367 28367 28369 28369 28371 28373 28375 28375 28378 28378 28382 28386 28388 28390 28392 28393 28404 28404 28409 28409 28418 28418 28422 28422 28425 28425 28431 28431 28435 28437 28448 28448 28452 28452 28457 28459 28461 28461 28463 28463 28465 28465 28467 28467 28470 28470 28478 28478 28486 28487 28491 28491 28493 28493 28504 28504 28508 28508 28510 28510 28514 28514 28518 28518 28525 28526 28530 28530 28532 28532 28536 28536 28538 28538 28540 28540 28548 28548 28552 28553 28556 28558 28572 28572 28577 28577 28583 28583 28595 28595 28598 28598 28601 28601 28608 28608 28610 28610 28617 28617 28625 28626 28638 28638 28640 28641 28654 28655 28689 28689 28698 28699 28707 28707 28725 28725 28729 28729 28748 28748 28751 28751 28766 28766 28779 28781 28783 28784 28789 28790 28792 28792 28796 28796 28798 28800 28805 28805 28809 28810 28814 28814 28818 28818 28820 28822 28825 28825 28828 28829 28843 28847 28849 28849 28851 28851 28855 28857 28859 28861 28864 28867 28872 28872 28874 28874 28888 28889 28891 28891 28895 28895 28900 28900 28902 28905 28907 28909 28911 28911 28919 28919 28921 28921 28925 28925 28937 28938 28944 28944 28947 28947 28949 28950 28952 28954 28966 28966 28975 28977 28982 28982 28997 28997 29002 29002 29004 29004 29006 29006 29020 29020 29022 29022 29028 29028 29030 29032 29038 29038 29042 29043 29048 29048 29050 29050 29053 29053 29060 29060 29066 29066 29071 29071 29076 29076 29080 29081 29087 29088 29096 29096 29100 29100 29107 29107 29109 29109 29113 29113 29123 29123 29134 29134 29140 29141 29152 29152 29157 29157 29159 29159 29166 29166 29177 29177 29190 29190 29213 29213 29224 29224 29226 29226 29228 29228 29232 29233 29237 29241 29243 29243 29245 29245 29247 29247 29255 29256 29260 29261 29266 29266 29270 29270 29273 29273 29275 29275 29277 29277 29279 29279 29281 29282 29286 29287 29289 29289 29294 29295 29298 29298 29301 29301 29305 29306 29310 29313 29316 29316 29322 29323 29325 29325 29327 29327 29330 29330 29343 29343 29356 29357 29359 29360 29364 29364 29366 29369 29377 29380 29384 29384 29389 29390 29392 29392 29394 29394 29399 29399 29401 29401 29406 29406 29408 29409 29416 29417 29420 29428 29431 29432 29434 29436 29441 29441 29443 29443 29450 29450 29454 29454 29459 29459 29461 29463 29467 29470 29473 29474 29477 29477 29481 29484 29486 29486 29489 29489 29492 29492 29495 29497 29502 29503 29517 29517 29520 29520 29522 29522 29527 29527 29536 29536 29548 29549 29551 29551 29566 29566 29572 29572 29575 29575 29577 29577 29579 29579 29582 29582 29585 29585 29590 29590 29595 29595 29599 29599 29602 29602 29609 29609 29611 29611 29614 29616 29618 29619 29623 29623 29626 29627 29632 29632 29634 29634 29640 29642 29645 29645 29647 29649 29657 29657 29662 29662 29664 29664 29669 29669 29671 29671 29673 29673 29677 29677 29682 29682 29699 29699 29701 29702 29705 29706 29711 29712 29722 29723 29730 29730 29733 29734 29736 29736 29738 29738 29740 29740 29742 29742 29744 29744 29747 29750 29756 29756 29761 29761 29781 29781 29783 29783 29785 29788 29790 29791 29805 29805 29808 29808 29814 29815 29822 29822 29824 29825 29827 29827 29831 29831 29835 29835 29838 29838 29840 29840 29852 29852 29854 29854 29863 29865 29882 29882 29906 29906 29916 29916 29918 29918 29920 29920 29922 29924 29926 29926 29934 29935 29940 29940 29942 29943 29951 29951 29956 29956 29965 29965 29967 29967 29969 29969 29971 29971 29976 29978 29980 29980 29983 29983 29989 29989 29992 29993 29995 29997 29999 30003 30005 30005 30007 30008 30010 30011 30014 30014 30016 30016 30021 30021 30024 30024 30027 30028 30030 30031 30036 30036 30041 30044 30053 30054 30058 30058 30066 30066 30068 30068 30072 30073 30079 30079 30083 30083 30086 30086 30091 30091 30095 30095 30097 30098 30100 30100 30102 30103 30105 30106 30109 30109 30111 30113 30115 30117 30123 30124 30126 30133 30136 30137 30140 30142 30146 30149 30151 30154 30157 30157 30162 30162 30164 30166 30168 30168 30171 30171 30174 30174 30178 30180 30182 30184 30186 30187 30192 30193 30196 30196 30201 30201 30204 30204 30207 30209 30211 30211 30213 30213 30218 30218 30220 30220 30224 30224 30229 30229 30231 30233 30235 30235 30239 30240 30242 30242 30244 30246 30249 30251 30253 30253 30256 30256 30259 30261 30264 30264 30268 30268 30270 30272 30275 30275 30284 30285 30292 30292 30294 30294 30300 30300 30302 30302 30307 30307 30315 30315 30319 30319 30328 30328 30331 30331 30333 30334 30338 30338 30340 30340 30342 30344 30347 30347 30350 30350 30353 30353 30355 30355 30358 30358 30361 30361 30372 30372 30382 30382 30385 30386 30388 30388 30399 30399 30402 30402 30405 30406 30408 30408 30410 30410 30413 30418 30420 30420 30422 30424 30427 30427 30431 30431 30437 30437 30446 30447 30449 30450 30452 30452 30456 30457 30460 30460 30462 30462 30465 30465 30468 30468 30471 30473 30475 30475 30477 30477 30489 30490 30495 30496 30498 30498 30502 30502 30504 30505 30509 30509 30511 30511 30517 30520 30522 30522 30524 30524 30528 30529 30531 30531 30535 30535 30544 30545 30554 30555 30561 30563 30565 30566 30568 30568 30571 30572 30585 30585 30589 30592 30596 30597 30604 30606 30609 30610 30623 30624 30626 30626 30629 30629 30631 30631 30633 30634 30636 30636 30640 30640 30643 30643 30645 30645 30651 30651 30653 30653 30655 30655 30669 30669 30679 30679 30683 30684 30690 30691 30693 30693 30695 30695 30697 30697 30699 30702 30707 30707 30710 30710 30712 30712 30717 30722 30729 30729 30732 30733 30737 30738 30740 30740 30742 30744 30746 30746 30748 30749 30751 30751 30755 30755 30757 30759 30761 30761 30764 30765 30768 30768 30772 30772 30775 30780 30782 30782 30784 30784 30789 30789 30791 30791 30796 30796 30798 30798 30800 30800 30802 30802 30805 30807 30813 30813 30826 30830 30839 30839 30844 30844 30855 30855 30857 30857 30860 30862 30865 30865 30867 30867 30871 30872 30874 30876 30879 30879 30881 30881 30883 30883 30885 30885 30887 30887 30896 30900 30905 30905 30910 30910 30913 30913 30917 30917 30921 30923 30928 30928 30932 30933 30937 30937 30952 30952 30956 30956 30962 30962 30964 30964 30967 30967 30970 30970 30977 30977 30981 30981 30995 30995 31006 31006 31012 31012 31028 31028 31034 31036 31038 31038 31040 31041 31046 31046 31048 31049 31059 31059 31062 31063 31066 31072 31074 31074 31077 31077 31079 31080 31085 31085 31087 31087 31095 31096 31098 31098 31104 31105 31108 31109 31114 31114 31119 31119 31130 31130 31143 31143 31155 31155 31161 31163 31165 31166 31168 31169 31171 31171 31174 31174 31177 31177 31179 31179 31181 31181 31185 31186 31189 31189 31192 31192 31199 31199 31203 31204 31206 31207 31209 31209 31211 31211 31213 31213 31215 31216 31224 31224 31227 31227 31229 31229 31232 31232 31234 31235 31238 31238 31243 31243 31245 31246 31252 31252 31255 31255 31258 31258 31262 31262 31264 31264 31267 31267 31283 31283 31287 31287 31289 31289 31291 31293 31295 31295 31302 31302 31313 31313 31319 31319 31344 31344 31348 31348 31350 31354 31359 31361 31363 31364 31366 31366 31368 31368 31373 31373 31377 31378 31381 31384 31388 31389 31391 31392 31397 31398 31400 31400 31404 31405 31411 31411 31423 31423 31435 31435 31446 31446 31449 31449 31454 31456 31459 31459 31461 31462 31469 31469 31471 31471 31481 31482 31485 31485 31487 31487 31491 31492 31494 31494 31496 31496 31498 31499 31503 31503 31505 31505 31508 31509 31513 31513 31515 31515 31518 31518 31520 31520 31524 31526 31528 31528 31530 31532 31534 31534 31537 31537 31539 31539 31544 31544 31546 31546 31548 31548 31550 31550 31557 31557 31559 31559 31561 31561 31563 31564 31567 31570 31572 31572 31574 31574 31576 31576 31578 31579 31581 31581 31584 31584 31586 31586 31598 31598 31601 31602 31605 31605 31607 31607 31609 31609 31611 31611 31614 31614 31616 31616 31621 31621 31629 31629 31632 31632 31636 31637 31639 31639 31644 31645 31649 31650 31654 31661 31665 31665 31668 31668 31672 31672 31681 31681 31686 31687 31692 31692 31697 31697 31699 31699 31705 31706 31709 31709 31713 31713 31717 31718 31722 31722 31726 31726 31729 31729 31735 31735 31740 31740 31742 31742 31751 31751 31755 31756 31759 31759 31766 31766 31775 31775 31782 31783 31786 31786 31800 31800 31807 31809 31821 31821 31859 31860 31867 31869 31881 31881 31889 31890 31893 31893 31895 31896 31900 31903 31906 31906 31908 31909 31914 31914 31918 31918 31921 31923 31929 31929 31932 31934 31937 31937 31941 31941 31943 31944 31946 31946 31948 31949 31957 31959 31961 31961 31964 31964 31967 31968 31976 31976 31983 31983 31992 31992 31995 31995 32010 32010 32032 32032 32034 32034 32039 32039 32043 32043 32047 32047 32110 32110 32119 32119 32166 32166 32174 32174 32315 32315 32321 32321 32327 32327 32386 32386 32411 32411 32415 32429 32431 32435 32437 32442 32445 32469 32471 32483 32485 32491 32493 32504 32506 32521 32523 32527 32529 32541 32543 32566 32568 32568 32570 32570 32578 32578 32580 32581 32592 32593 32596 32597 32599 32600 32602 32602 32607 32607 32609 32610 32616 32618 32622 32622 32625 32626 32628 32628 32633 32633 32638 32638 32641 32641 32650 32650 32652 32652 32654 32654 32660 32660 32666 32666 32669 32671 32673 32673 32676 32676 32679 32679 32687 32688 32690 32690 32696 32697 32700 32701 32703 32703 32705 32705 32709 32709 32714 32714 32716 32716 32718 32718 32724 32725 32728 32728 32735 32737 32741 32742 32745 32745 32750 32750 32752 32753 32755 32755 32763 32764 32768 32769 32771 32774 32779 32781 32784 32784 32786 32786 32788 32793 32796 32796 32800 32800 32802 32802 32805 32810 32817 32817 32819 32819 32821 32824 32827 32827 32829 32829 32831 32831 32834 32835 32838 32838 32842 32845 32850 32850 32852 32852 32856 32856 32858 32858 32873 32874 32881 32881 32895 32896 32899 32900 32902 32903 32905 32905 32907 32908 32915 32915 32918 32918 32920 32920 32922 32925 32927 32930 32932 32933 32937 32939 32941 32943 32945 32946 32948 32948 32951 32951 32954 32954 32956 32964 32966 32966 32972 32974 32982 32983 32985 32990 32993 32993 32996 32997 32999 33005 33007 33012 33014 33014 33016 33016 33018 33018 33020 33021 33026 33026 33030 33030 33033 33034 33037 33044 33046 33046 33048 33048 33050 33050 33054 33054 33068 33068 33071 33071 33073 33074 33078 33078 33080 33080 33086 33086 33094 33094 33096 33096 33098 33100 33104 33105 33107 33109 33113 33114 33120 33120 33125 33125 33127 33127 33129 33129 33133 33134 33136 33137 33140 33140 33145 33152 33154 33154 33160 33160 33162 33162 33167 33167 33169 33169 33176 33176 33179 33181 33187 33187 33190 33190 33192 33192 33194 33194 33203 33203 33210 33211 33216 33219 33222 33222 33226 33226 33228 33228 33251 33251 33255 33255 33258 33258 33260 33261 33267 33268 33275 33276 33278 33278 33280 33282 33284 33286 33292 33293 33296 33296 33298 33298 33300 33300 33307 33308 33310 33311 33313 33315 33320 33320 33322 33325 33327 33329 33331 33337 33339 33339 33342 33342 33348 33348 33351 33351 33353 33353 33355 33355 33359 33359 33368 33368 33370 33370 33375 33375 33384 33384 33390 33392 33394 33396 33401 33402 33405 33407 33410 33410 33412 33412 33416 33416 33418 33419 33421 33423 33425 33426 33431 33433 33436 33437 33439 33439 33441 33441 33444 33446 33448 33457 33459 33460 33463 33465 33469 33470 33473 33473 33476 33476 33479 33480 33482 33487 33489 33493 33495 33496 33499 33500 33502 33505 33507 33510 33515 33515 33519 33519 33521 33521 33524 33524 33527 33527 33529 33529 33531 33531 33537 33545 33548 33548 33550 33551 33553 33553 33556 33557 33559 33559 33562 33564 33575 33576 33579 33581 33583 33583 33585 33585 33587 33590 33592 33594 33596 33596 33600 33600 33603 33603 33606 33607 33609 33609 33615 33618 33620 33620 33626 33628 33630 33633 33635 33647 33655 33656 33659 33661 33669 33670 33673 33673 33678 33678 33682 33683 33688 33688 33691 33692 33694 33694 33696 33696 33704 33707 33712 33716 33718 33722 33724 33725 33728 33729 33733 33733 33735 33735 33738 33738 33740 33740 33743 33743 33748 33748 33750 33750 33752 33752 33756 33757 33759 33761 33765 33765 33769 33770 33776 33778 33784 33785 33789 33789 33793 33793 33795 33796 33798 33798 33803 33807 33809 33809 33816 33816 33820 33821 33828 33832 33841 33841 33848 33848 33852 33853 33862 33862 33873 33873 33879 33879 33881 33884 33889 33889 33891 33891 33897 33897 33899 33901 33905 33905 33907 33907 33909 33910 33912 33912 33914 33914 33922 33922 33927 33929 33931 33932 33934 33934 33943 33943 33945 33945 33948 33948 33953 33953 33967 33967 33970 33970 33972 33972 33976 33978 33981 33981 33983 33983 33985 33985 33988 33988 33993 33994 33997 33997 34000 34001 34003 34003 34006 34006 34013 34013 34015 34016 34019 34019 34021 34022 34028 34028 34032 34032 34044 34044 34047 34047 34060 34060 34065 34065 34067 34067 34071 34071 34074 34074 34079 34079 34081 34081 34091 34092 34103 34109 34115 34115 34120 34122 34134 34134 34137 34137 34142 34142 34148 34148 34152 34152 34162 34162 34164 34164 34169 34171 34174 34174 34180 34181 34183 34183 34191 34191 34203 34204 34212 34212 34216 34216 34218 34218 34222 34224 34231 34231 34233 34233 34241 34241 34249 34249 34255 34256 34259 34259 34261 34261 34268 34268 34276 34276 34281 34281 34299 34299 34303 34303 34309 34309 34321 34321 34326 34326 34343 34343 34345 34345 34360 34360 34364 34364 34381 34385 34388 34388 34394 34394 34398 34398 34402 34402 34411 34412 34414 34414 34417 34417 34425 34434 34442 34445 34451 34451 34453 34453 34460 34461 34467 34468 34471 34474 34476 34476 34479 34481 34484 34486 34490 34490 34496 34496 34500 34500 34502 34503 34505 34507 34510 34513 34516 34516 34520 34521 34523 34523 34526 34527 34532 34532 34537 34537 34541 34542 34544 34548 34552 34553 34558 34558 34560 34560 34562 34563 34567 34570 34573 34573 34578 34579 34581 34581 34583 34584 34586 34586 34588 34588 34590 34590 34593 34595 34597 34597 34601 34601 34606 34606 34609 34609 34612 34612 34615 34615 34619 34619 34622 34623 34631 34633 34636 34636 34638 34638 34643 34643 34647 34647 34649 34649 34656 34656 34659 34661 34670 34670 34672 34672 34676 34676 34678 34678 34683 34686 34690 34691 34693 34693 34696 34696 34699 34699 34701 34701 34707 34707 34711 34711 34719 34719 34728 34728 34731 34733 34735 34735 34739 34739 34741 34741 34746 34746 34749 34749 34752 34752 34758 34758 34762 34763 34769 34771 34779 34779 34784 34784 34789 34789 34794 34794 34798 34798 34809 34809 34814 34814 34819 34819 34826 34826 34835 34835 34837 34838 34843 34843 34849 34850 34866 34866 34873 34873 34876 34876 34880 34880 34884 34885 34892 34893 34900 34900 34903 34903 34905 34905 34913 34917 34920 34921 34923 34924 34926 34926 34928 34928 34930 34930 34935 34935 34941 34943 34945 34946 34948 34949 34952 34952 34955 34955 34957 34957 34962 34962 34966 34966 34972 34972 34978 34978 34980 34980 34987 34987 34989 34989 34993 34993 34999 34999 35004 35004 35009 35010 35013 35014 35017 35017 35022 35022 35026 35026 35028 35029 35032 35033 35039 35039 35042 35045 35048 35048 35056 35057 35059 35060 35064 35065 35068 35068 35070 35070 35074 35074 35082 35082 35088 35088 35090 35091 35097 35099 35105 35105 35109 35109 35114 35115 35120 35120 35124 35124 35126 35126 35137 35137 35140 35140 35166 35167 35174 35174 35195 35195 35199 35199 35201 35201 35203 35203 35206 35206 35265 35266 35268 35276 35278 35282 35286 35286 35290 35290 35292 35292 35294 35294 35299 35299 35301 35302 35307 35307 35311 35311 35315 35315 35328 35328 35335 35335 35390 35390 35400 35400 35449 35449 35465 35466 35475 35475 35591 35591 35622 35622 35686 35686 35692 35692 35744 35755 35757 35760 35762 35770 35772 35782 35784 35791 35793 35817 35819 35848 35850 35869 35871 35895 35905 35905 35910 35911 35913 35913 35916 35916 35925 35925 35930 35930 35937 35938 35946 35947 35955 35955 35960 35962 35970 35970 35973 35973 35977 35978 35980 35980 35988 35988 35992 35992 36125 36127 36129 36176 36179 36182 36184 36190 36192 36196 36198 36199 36203 36203 36205 36205 36208 36208 36211 36215 36225 36225 36228 36229 36234 36235 36241 36241 36244 36244 36255 36255 36259 36259 36273 36273 36275 36277 36280 36280 36282 36282 36284 36284 36286 36287 36291 36292 36294 36294 36299 36300 36302 36303 36305 36305 36310 36311 36314 36315 36317 36319 36323 36324 36328 36328 36330 36332 36335 36335 36339 36339 36341 36341 36343 36347 36349 36349 36357 36357 36361 36362 36364 36364 36367 36367 36372 36372 36381 36383 36386 36387 36393 36394 36396 36396 36398 36399 36401 36401 36405 36405 36409 36410 36413 36413 36416 36418 36420 36420 36423 36427 36433 36434 36441 36441 36454 36454 36457 36457 36460 36461 36463 36464 36466 36466 36468 36468 36470 36470 36476 36476 36479 36479 36481 36481 36485 36485 36487 36487 36495 36496 36500 36500 36508 36508 36510 36510 36523 36524 36527 36527 36530 36530 36538 36538 36558 36558 36710 36713 36715 36735 36737 36747 36749 36753 36755 36764 36766 36767 36771 36771 36776 36777 36779 36779 36784 36785 36790 36790 36793 36793 36797 36798 36801 36802 36804 36805 36807 36808 36814 36814 36816 36817 36819 36821 36824 36825 36827 36831 36834 36834 36836 36838 36840 36843 36845 36846 36848 36848 36851 36851 36855 36857 36861 36861 36864 36870 36873 36875 36877 36877 36879 36882 36884 36884 36886 36887 36890 36891 36893 36898 36902 36902 36909 36911 36917 36918 36920 36920 36923 36924 36926 36926 36929 36930 36932 36932 36935 36935 36941 36941 36943 36947 36951 36952 36955 36955 36962 36963 36965 36965 36968 36968 36973 36974 36980 36981 36989 36989 36991 36992 36994 36995 37000 37000 37003 37003 37009 37009 37011 37011 37013 37013 37015 37015 37017 37017 37019 37019 37021 37021 37025 37027 37030 37030 37034 37034 37036 37036 37038 37041 37043 37046 37048 37051 37054 37054 37057 37057 37060 37061 37063 37063 37066 37066 37070 37073 37075 37075 37079 37079 37083 37085 37089 37090 37094 37096 37099 37099 37101 37101 37103 37103 37108 37108 37112 37112 37117 37118 37122 37122 37124 37124 37145 37145 37150 37150 37154 37155 37167 37167 37169 37169 37177 37177 37187 37187 37190 37190 37193 37200 37202 37202 37207 37207 37210 37210 37213 37214 37217 37221 37225 37226 37228 37228 37230 37234 37236 37241 37245 37247 37253 37253 37255 37255 37257 37257 37259 37261 37264 37266 37274 37275 37282 37283 37290 37290 37293 37295 37300 37301 37306 37306 37319 37319 37321 37322 37324 37327 37329 37329 37340 37340 37492 37492 37518 37518 37550 37550 37576 37576 37694 37694 37738 37738 37775 37775 37834 37834 37846 37846 37950 37950 37995 37995 38021 38032 38034 38037 38039 38039 38041 38086 38088 38094 38096 38098 38101 38105 38107 38117 38119 38138 38140 38171 38173 38175 38177 38182 38184 38194 38196 38204 38206 38210 38212 38215 38217 38218 38220 38228 38230 38233 38235 38239 38241 38253 38255 38259 38262 38262 38271 38271 38376 38379 38381 38398 38400 38406 38408 38418 38420 38423 38425 38426 38428 38429 38431 38431 38433 38434 38442 38442 38446 38446 38449 38454 38459 38461 38463 38464 38466 38466 38468 38473 38475 38477 38480 38480 38484 38485 38491 38491 38495 38495 38497 38498 38500 38500 38503 38506 38508 38508 38514 38514 38516 38519 38533 38534 38536 38536 38539 38539 38541 38541 38543 38544 38548 38548 38551 38553 38556 38556 38567 38567 38576 38576 38579 38579 38582 38582 38585 38585 38588 38590 38592 38593 38596 38599 38601 38601 38604 38607 38610 38610 38613 38613 38624 38624 38632 38634 38639 38639 38643 38643 38646 38647 38649 38649 38654 38654 38656 38657 38660 38660 38662 38665 38669 38671 38675 38675 38678 38678 38684 38684 38686 38686 38698 38698 38701 38701 38704 38704 38706 38706 38712 38713 38718 38718 38738 38739 38742 38742 38745 38745 38747 38747 38750 38750 38752 38754 38757 38757 38761 38761 38771 38772 38774 38774 38780 38780 38789 38789 38795 38795 38797 38797 38801 38802 38804 38804 38808 38808 38816 38816 38819 38819 38827 38827 38829 38829 38831 38831 38834 38834 38836 38836 38886 38887 38889 38893 38899 38899 38901 38902 39029 39050 39052 39053 39055 39057 39059 39060 39062 39064 39066 39074 39076 39079 39118 39118 39121 39123 39125 39125 39128 39130 39134 39135 39143 39144 39181 39181 39184 39184 39214 39214 39252 39253 39267 39267 39269 39269 39271 39282 39284 39287 39290 39290 39292 39293 39295 39297 39300 39304 39306 39307 39309 39309 39311 39321 39333 39333 39336 39336 39532 39537 39539 39554 39556 39560 39562 39564 39567 39571 39574 39576 39578 39589 39591 39592 39600 39601 39606 39608 39610 39610 39612 39612 39616 39618 39621 39621 39627 39628 39633 39633 39635 39635 39640 39640 39647 39647 39649 39649 39654 39654 39659 39659 39661 39661 39663 39663 39673 39673 39675 39675 39683 39683 39688 39688 39695 39695 39699 39699 39711 39711 39715 39715 39727 39727 39730 39730 39739 39740 39745 39749 39751 39753 39757 39757 39759 39759 39761 39761 39764 39764 40060 40060 40063 40063 40065 40066 40069 40072 40075 40075 40077 40078 40080 40082 40084 40085 40090 40092 40094 40105 40107 40107 40109 40110 40112 40120 40122 40125 40131 40135 40138 40144 40147 40153 40156 40159 40162 40162 40479 40483 40485 40486 40488 40493 40495 40495 40497 40499 40501 40506 40509 40511 40513 40524 40526 40527 40529 40529 40533 40533 40535 40536 40538 40540 40542 40542 40547 40548 40550 40557 40560 40561 40563 40563 40574 40575 40578 40578 40583 40584 40587 40587 40594 40595 40605 40605 40607 40607 40614 40614 40628 40628 40632 40632 40635 40635 40637 40638 40644 40644 40649 40649 40653 40655 40657 40657 40660 40660 40664 40664 40667 40669 40671 40672 40674 40674 40677 40677 40679 40679 40681 40682 40687 40687 40697 40697 40699 40700 40702 40702 40715 40715 40717 40718 40720 40720 40723 40723 40727 40727 40729 40729 40736 40736 40738 40738 40748 40748 40751 40751 40759 40759 40761 40761 40763 40763 40765 40766 40772 40772 40784 40785 40831 40832 40835 40844 40857 40859 40863 40864 65281 65374 65504 65505 65507 65507 65509 65509 917504 917631)) (make-character-set :mib-enum 17 :name #16="Shift_JIS" :aliases '("csShiftJIS" "MS_Kanji") :mime-encoding '#16# :source '"This charset is an extension of csHalfWidthKatakana by adding graphic characters in JIS X 0208. The CCS's are JIS X0201:1997 and JIS X0208:1997. The complete definition is shown in Appendix 1 of JIS X0208:1997. This charset can be used for the top-level media type \"text\"." :comments 'nil :references 'nil :ranges #(0 127 162 163 165 165 167 168 172 172 176 177 180 180 182 182 215 215 247 247 913 929 931 937 945 961 963 969 1025 1025 1040 1103 1105 1105 8208 8208 8212 8214 8216 8217 8220 8221 8224 8225 8229 8230 8240 8240 8242 8243 8251 8251 8254 8254 8451 8451 8470 8470 8481 8481 8491 8491 8544 8553 8560 8569 8592 8595 8658 8658 8660 8660 8704 8704 8706 8707 8711 8712 8715 8715 8721 8722 8730 8730 8733 8736 8741 8741 8743 8748 8750 8750 8756 8757 8765 8765 8786 8786 8800 8801 8806 8807 8810 8811 8834 8835 8838 8839 8869 8869 8895 8895 8978 8978 9312 9331 9472 9475 9484 9484 9487 9488 9491 9492 9495 9496 9499 9501 9504 9504 9507 9509 9512 9512 9515 9516 9519 9520 9523 9524 9527 9528 9531 9532 9535 9535 9538 9538 9547 9547 9632 9633 9650 9651 9660 9661 9670 9671 9675 9675 9678 9679 9711 9711 9733 9734 9792 9792 9794 9794 9834 9834 9837 9837 9839 9839 12288 12291 12293 12309 12316 12317 12319 12319 12353 12435 12443 12446 12449 12534 12539 12542 12849 12850 12857 12857 12964 12968 13059 13059 13069 13069 13076 13076 13080 13080 13090 13091 13094 13095 13099 13099 13110 13110 13115 13115 13129 13130 13133 13133 13137 13137 13143 13143 13179 13182 13198 13199 13212 13214 13217 13217 13252 13252 13261 13261 19968 19969 19971 19971 19975 19979 19981 19982 19984 19985 19988 19993 19998 19998 20001 20001 20006 20006 20008 20008 20010 20010 20013 20013 20017 20018 20022 20022 20024 20025 20027 20028 20031 20031 20034 20035 20037 20037 20043 20043 20045 20047 20053 20057 20061 20063 20066 20066 20081 20081 20083 20083 20094 20094 20096 20096 20098 20098 20101 20102 20104 20108 20110 20110 20113 20114 20116 20117 20120 20121 20123 20124 20126 20130 20132 20134 20136 20136 20139 20142 20144 20144 20147 20147 20150 20150 20154 20154 20160 20162 20164 20164 20166 20167 20170 20171 20173 20175 20180 20185 20189 20191 20193 20193 20195 20197 20205 20206 20208 20208 20210 20210 20214 20215 20219 20220 20224 20225 20227 20227 20233 20234 20237 20241 20250 20250 20252 20253 20271 20272 20276 20276 20278 20278 20280 20282 20284 20285 20291 20291 20294 20295 20301 20305 20307 20307 20309 20311 20313 20318 20329 20329 20335 20336 20339 20339 20341 20342 20347 20348 20351 20351 20355 20355 20358 20358 20360 20360 20362 20363 20365 20365 20367 20367 20369 20370 20372 20372 20374 20374 20376 20376 20378 20379 20381 20381 20384 20385 20395 20395 20397 20399 20405 20406 20415 20415 20418 20420 20425 20426 20429 20430 20432 20433 20436 20436 20439 20440 20442 20443 20445 20445 20447 20447 20449 20449 20451 20453 20462 20463 20467 20467 20469 20470 20472 20472 20474 20474 20478 20479 20485 20486 20489 20489 20491 20491 20493 20493 20495 20495 20497 20498 20500 20500 20502 20502 20505 20506 20510 20511 20513 20518 20520 20525 20534 20534 20537 20537 20544 20544 20546 20547 20550 20553 20559 20560 20565 20566 20570 20570 20572 20572 20581 20581 20588 20588 20592 20592 20594 20594 20596 20598 20600 20600 20605 20605 20608 20608 20613 20613 20621 20621 20625 20625 20628 20628 20632 20634 20652 20653 20658 20661 20663 20663 20670 20670 20674 20674 20677 20677 20681 20682 20685 20685 20687 20687 20689 20689 20693 20694 20696 20696 20698 20698 20702 20702 20707 20707 20709 20709 20711 20711 20717 20718 20724 20725 20729 20729 20731 20731 20736 20738 20740 20740 20745 20745 20754 20754 20756 20758 20760 20760 20762 20762 20767 20767 20769 20769 20778 20778 20786 20786 20791 20791 20794 20796 20799 20801 20803 20814 20816 20816 20818 20818 20820 20820 20826 20826 20828 20828 20834 20834 20836 20837 20840 20846 20849 20849 20853 20856 20860 20860 20864 20864 20866 20866 20869 20870 20873 20874 20876 20877 20879 20883 20885 20887 20889 20889 20893 20893 20896 20896 20898 20898 20900 20902 20904 20908 20912 20919 20925 20926 20932 20934 20937 20937 20939 20941 20950 20950 20955 20957 20960 20961 20966 20967 20969 20970 20972 20973 20976 20977 20981 20982 20984 20986 20989 20990 20992 20992 20995 20996 20998 21000 21002 21003 21006 21006 21009 21009 21012 21013 21015 21015 21021 21021 21028 21029 21031 21031 21033 21034 21038 21038 21040 21040 21043 21043 21046 21051 21059 21060 21063 21063 21066 21069 21071 21071 21076 21076 21078 21078 21083 21083 21086 21086 21091 21093 21097 21098 21103 21109 21117 21117 21119 21119 21123 21123 21127 21129 21133 21133 21137 21138 21140 21140 21147 21148 21151 21152 21155 21155 21158 21158 21161 21165 21167 21167 21169 21169 21172 21173 21177 21177 21180 21180 21182 21182 21184 21185 21187 21187 21189 21189 21191 21191 21193 21193 21197 21197 21202 21202 21205 21205 21207 21209 21211 21211 21213 21216 21218 21220 21222 21223 21234 21235 21237 21237 21240 21242 21246 21250 21253 21256 21261 21261 21263 21264 21269 21271 21273 21274 21277 21277 21280 21281 21283 21284 21290 21290 21295 21295 21297 21297 21299 21299 21304 21307 21311 21313 21315 21315 21317 21322 21325 21325 21329 21332 21335 21336 21338 21338 21340 21340 21342 21342 21344 21344 21350 21350 21353 21353 21358 21365 21367 21368 21371 21371 21375 21375 21378 21378 21380 21380 21395 21395 21398 21398 21400 21400 21402 21402 21407 21408 21413 21414 21416 21417 21421 21422 21424 21424 21426 21427 21430 21430 21435 21435 21442 21443 21448 21454 21460 21460 21462 21463 21465 21465 21467 21467 21469 21469 21471 21471 21473 21477 21480 21491 21494 21496 21498 21498 21505 21505 21507 21508 21512 21521 21531 21531 21533 21533 21535 21536 21542 21542 21545 21545 21547 21550 21558 21558 21560 21561 21563 21566 21568 21568 21570 21570 21574 21574 21576 21578 21582 21582 21585 21585 21599 21599 21608 21608 21610 21610 21616 21617 21619 21619 21621 21623 21627 21629 21632 21632 21636 21636 21638 21638 21642 21644 21646 21648 21650 21650 21660 21660 21666 21666 21668 21669 21672 21673 21675 21676 21679 21679 21682 21683 21688 21688 21692 21694 21696 21698 21700 21700 21703 21705 21720 21720 21729 21730 21733 21734 21736 21737 21741 21742 21746 21746 21754 21754 21757 21757 21759 21759 21764 21764 21766 21767 21775 21776 21780 21780 21782 21782 21806 21807 21809 21809 21811 21811 21816 21817 21822 21822 21824 21824 21828 21830 21836 21836 21839 21839 21843 21843 21846 21847 21852 21853 21859 21859 21883 21884 21886 21886 21888 21888 21891 21892 21894 21895 21897 21899 21912 21914 21916 21919 21927 21932 21934 21934 21936 21936 21942 21942 21956 21957 21959 21959 21972 21972 21978 21978 21980 21980 21983 21983 21987 21988 22007 22007 22009 22009 22013 22014 22022 22022 22025 22025 22036 22036 22038 22040 22043 22043 22057 22057 22063 22063 22065 22066 22068 22068 22070 22070 22072 22072 22082 22082 22092 22092 22094 22094 22096 22096 22107 22107 22116 22116 22120 22120 22122 22124 22132 22132 22136 22136 22138 22138 22144 22144 22150 22151 22154 22154 22159 22159 22164 22164 22176 22176 22178 22178 22181 22181 22190 22190 22196 22196 22198 22198 22204 22204 22208 22211 22216 22216 22222 22222 22225 22225 22227 22227 22231 22232 22234 22235 22238 22238 22240 22240 22243 22243 22254 22254 22256 22256 22258 22259 22265 22266 22269 22269 22271 22272 22275 22276 22280 22281 22283 22283 22285 22285 22287 22287 22290 22291 22294 22294 22296 22296 22300 22300 22303 22303 22310 22312 22317 22317 22320 22320 22327 22328 22331 22331 22336 22336 22338 22338 22343 22343 22346 22346 22350 22353 22361 22361 22369 22369 22372 22374 22377 22378 22399 22399 22402 22402 22408 22409 22411 22411 22419 22419 22432 22432 22434 22436 22442 22442 22444 22444 22448 22448 22451 22451 22464 22464 22467 22467 22470 22472 22475 22475 22478 22478 22482 22484 22486 22486 22492 22492 22495 22496 22499 22499 22516 22516 22519 22519 22521 22522 22524 22524 22528 22528 22530 22530 22533 22534 22538 22539 22549 22549 22553 22553 22557 22557 22561 22561 22564 22564 22570 22570 22575 22577 22580 22581 22586 22586 22589 22589 22592 22593 22602 22603 22609 22610 22612 22612 22615 22618 22622 22622 22626 22626 22633 22633 22635 22635 22640 22640 22642 22642 22645 22645 22649 22649 22654 22654 22659 22659 22661 22661 22675 22675 22679 22679 22684 22684 22686 22687 22696 22696 22699 22699 22702 22702 22706 22707 22712 22715 22718 22718 22721 22721 22725 22725 22727 22727 22730 22730 22732 22732 22737 22737 22739 22739 22741 22741 22743 22745 22748 22748 22750 22751 22756 22757 22763 22764 22766 22770 22775 22775 22777 22781 22786 22786 22793 22795 22799 22800 22805 22806 22808 22812 22818 22818 22821 22821 22823 22823 22825 22830 22833 22834 22839 22840 22846 22846 22852 22852 22855 22857 22862 22865 22867 22869 22871 22872 22874 22875 22877 22877 22880 22880 22882 22883 22885 22885 22887 22890 22892 22892 22894 22894 22899 22900 22904 22904 22909 22909 22913 22916 22922 22922 22925 22925 22931 22931 22934 22934 22937 22937 22939 22939 22941 22941 22947 22949 22952 22952 22956 22956 22962 22962 22969 22971 22974 22974 22982 22982 22985 22985 22987 22987 22992 22993 22995 22996 23001 23002 23004 23004 23013 23014 23016 23016 23018 23019 23030 23030 23035 23035 23039 23039 23041 23041 23043 23043 23049 23049 23057 23057 23064 23064 23066 23066 23068 23068 23071 23072 23077 23077 23081 23081 23087 23087 23093 23094 23100 23100 23104 23105 23110 23110 23113 23113 23130 23130 23138 23138 23142 23142 23146 23146 23148 23148 23167 23167 23186 23186 23194 23195 23228 23230 23233 23234 23241 23241 23243 23244 23248 23248 23254 23255 23265 23265 23267 23267 23270 23270 23273 23273 23290 23291 23305 23305 23307 23308 23318 23318 23330 23330 23338 23338 23340 23340 23344 23344 23346 23346 23350 23350 23358 23358 23360 23360 23363 23363 23365 23365 23376 23377 23380 23384 23386 23389 23391 23391 23395 23398 23401 23401 23403 23403 23408 23409 23411 23411 23413 23413 23416 23416 23418 23418 23424 23424 23427 23427 23429 23429 23431 23433 23435 23437 23439 23439 23445 23445 23447 23453 23455 23455 23458 23462 23470 23470 23472 23472 23475 23478 23480 23481 23487 23488 23490 23495 23497 23497 23500 23500 23504 23504 23506 23508 23512 23512 23515 23515 23517 23519 23521 23522 23524 23529 23531 23532 23534 23534 23536 23536 23539 23539 23541 23542 23544 23544 23546 23546 23550 23551 23553 23554 23556 23563 23565 23567 23569 23569 23571 23571 23574 23574 23578 23578 23582 23582 23584 23584 23586 23586 23588 23588 23592 23592 23597 23597 23601 23601 23608 23617 23621 23622 23624 23624 23626 23627 23629 23633 23635 23635 23637 23637 23646 23646 23648 23649 23652 23653 23660 23660 23662 23663 23665 23665 23670 23670 23673 23673 23692 23692 23696 23697 23700 23700 23713 23713 23718 23718 23720 23721 23723 23724 23729 23729 23731 23731 23734 23736 23738 23740 23742 23742 23749 23749 23751 23751 23769 23769 23776 23777 23784 23786 23789 23789 23791 23792 23797 23798 23802 23803 23805 23805 23815 23815 23819 23819 23822 23822 23825 23825 23828 23835 23839 23839 23842 23842 23847 23847 23849 23849 23874 23874 23883 23884 23886 23886 23888 23888 23890 23891 23900 23900 23913 23913 23916 23917 23919 23919 23923 23923 23926 23926 23938 23938 23940 23940 23943 23943 23947 23948 23952 23952 23965 23965 23970 23970 23980 23980 23982 23982 23991 23994 23996 23997 24009 24009 24012 24013 24016 24016 24018 24019 24022 24022 24027 24027 24029 24030 24033 24033 24035 24035 24037 24040 24043 24043 24046 24046 24049 24053 24055 24055 24059 24059 24061 24062 24066 24067 24070 24070 24075 24076 24081 24081 24086 24086 24089 24091 24093 24093 24101 24101 24107 24107 24109 24109 24111 24112 24115 24115 24118 24120 24125 24125 24128 24128 24131 24133 24135 24135 24140 24140 24142 24142 24148 24149 24151 24151 24159 24159 24161 24164 24178 24182 24184 24191 24193 24193 24195 24196 24199 24199 24202 24202 24207 24207 24213 24215 24218 24218 24220 24220 24224 24224 24230 24231 24235 24235 24237 24237 24245 24248 24257 24259 24264 24266 24271 24272 24275 24275 24278 24278 24282 24283 24285 24285 24287 24291 24296 24297 24300 24300 24304 24305 24307 24308 24310 24312 24314 24316 24318 24319 24321 24321 24323 24324 24329 24333 24335 24337 24339 24344 24347 24347 24351 24351 24353 24353 24357 24359 24361 24361 24365 24365 24367 24367 24369 24369 24372 24373 24375 24376 24380 24380 24382 24382 24385 24385 24389 24389 24392 24392 24394 24394 24396 24396 24398 24398 24401 24401 24403 24403 24406 24407 24409 24409 24412 24413 24417 24418 24422 24423 24425 24429 24432 24433 24435 24435 24439 24439 24441 24441 24444 24444 24447 24453 24455 24456 24458 24460 24464 24467 24471 24473 24478 24478 24480 24481 24488 24490 24493 24494 24499 24500 24503 24503 24505 24505 24508 24509 24515 24515 24517 24517 24524 24525 24534 24537 24540 24542 24544 24544 24548 24548 24555 24555 24560 24561 24565 24565 24568 24568 24571 24571 24573 24573 24575 24575 24590 24592 24594 24594 24597 24598 24601 24601 24603 24605 24608 24609 24613 24619 24623 24623 24625 24625 24634 24634 24641 24643 24646 24646 24650 24651 24653 24653 24656 24656 24658 24658 24661 24661 24665 24666 24669 24669 24671 24672 24674 24677 24680 24685 24687 24688 24693 24693 24695 24695 24705 24705 24707 24709 24713 24717 24722 24722 24724 24724 24726 24727 24730 24731 24735 24736 24739 24739 24742 24743 24745 24746 24754 24758 24760 24760 24764 24765 24773 24775 24785 24785 24787 24787 24789 24789 24792 24792 24794 24794 24796 24796 24798 24801 24803 24803 24807 24808 24816 24820 24822 24823 24825 24827 24832 24833 24835 24835 24838 24838 24840 24841 24845 24847 24849 24849 24853 24853 24858 24859 24863 24865 24871 24872 24876 24876 24880 24880 24884 24884 24887 24887 24892 24895 24898 24898 24900 24900 24903 24904 24906 24910 24915 24915 24917 24917 24920 24922 24925 24925 24927 24927 24930 24931 24933 24933 24935 24936 24939 24939 24942 24945 24947 24951 24958 24958 24962 24962 24967 24967 24970 24970 24974 24974 24976 24977 24980 24980 24982 24982 24984 24986 24996 24996 24999 24999 25001 25001 25003 25004 25006 25006 25010 25010 25014 25014 25018 25018 25022 25022 25027 25027 25030 25037 25040 25040 25059 25059 25062 25062 25074 25074 25076 25076 25078 25080 25082 25082 25084 25088 25096 25098 25100 25102 25104 25108 25110 25110 25114 25115 25117 25119 25121 25121 25126 25126 25130 25130 25134 25136 25138 25140 25144 25144 25147 25147 25151 25153 25159 25161 25163 25163 25165 25166 25171 25171 25173 25173 25176 25176 25179 25179 25182 25182 25184 25184 25187 25187 25192 25192 25198 25198 25201 25201 25206 25206 25209 25209 25212 25212 25214 25216 25218 25220 25225 25226 25233 25240 25243 25244 25246 25246 25254 25254 25259 25260 25265 25265 25269 25269 25273 25273 25275 25277 25282 25282 25285 25290 25292 25293 25295 25300 25303 25305 25307 25309 25312 25313 25324 25327 25329 25329 25331 25331 25333 25335 25342 25343 25345 25346 25351 25353 25356 25356 25361 25361 25369 25369 25375 25375 25383 25384 25387 25387 25391 25391 25402 25402 25405 25407 25417 25417 25420 25421 25423 25424 25429 25429 25431 25431 25436 25436 25447 25449 25451 25451 25454 25454 25458 25458 25462 25463 25466 25467 25472 25472 25475 25475 25480 25481 25484 25484 25486 25487 25490 25490 25494 25494 25496 25496 25499 25499 25503 25507 25509 25509 25511 25516 25522 25522 25524 25525 25531 25531 25534 25534 25536 25536 25539 25540 25542 25542 25545 25545 25551 25552 25554 25554 25558 25558 25562 25563 25569 25569 25571 25571 25577 25577 25582 25582 25588 25590 25594 25594 25606 25606 25613 25613 25615 25615 25619 25619 25622 25623 25628 25628 25638 25638 25640 25640 25644 25645 25652 25652 25654 25654 25658 25658 25662 25662 25666 25666 25678 25678 25688 25688 25696 25696 25703 25703 25705 25705 25711 25711 25718 25718 25720 25720 25722 25722 25731 25731 25736 25736 25746 25747 25749 25749 25754 25754 25757 25758 25764 25765 25769 25769 25771 25771 25773 25774 25776 25776 25778 25778 25785 25785 25787 25788 25793 25794 25797 25797 25799 25799 25805 25806 25810 25810 25812 25812 25816 25816 25818 25818 25824 25827 25830 25831 25836 25836 25839 25839 25841 25842 25844 25844 25846 25846 25850 25850 25853 25854 25856 25856 25861 25861 25880 25880 25884 25885 25891 25892 25898 25900 25903 25903 25908 25913 25915 25915 25918 25919 25925 25925 25928 25928 25933 25935 25937 25937 25941 25945 25949 25950 25954 25955 25958 25958 25964 25964 25968 25968 25970 25970 25972 25973 25975 25976 25986 25987 25991 25993 25996 25996 25998 25998 26000 26001 26007 26007 26009 26009 26011 26012 26015 26015 26017 26017 26020 26021 26023 26023 26027 26029 26031 26032 26039 26039 26041 26041 26044 26045 26049 26049 26051 26054 26059 26060 26063 26063 26066 26066 26071 26071 26073 26073 26075 26075 26080 26082 26085 26089 26092 26093 26097 26097 26106 26107 26112 26112 26114 26115 26118 26119 26121 26122 26124 26124 26126 26127 26131 26133 26140 26140 26142 26144 26148 26149 26151 26152 26157 26159 26161 26161 26164 26166 26171 26172 26175 26175 26177 26180 26185 26185 26187 26187 26191 26191 26194 26194 26199 26199 26201 26201 26205 26207 26210 26210 26212 26217 26222 26224 26227 26228 26230 26230 26234 26234 26241 26241 26243 26244 26247 26249 26254 26254 26257 26257 26262 26265 26269 26269 26272 26272 26274 26274 26278 26278 26283 26283 26286 26286 26290 26290 26292 26292 26296 26297 26300 26300 26302 26303 26305 26305 26308 26308 26311 26311 26313 26313 26326 26326 26329 26330 26332 26333 26336 26336 26342 26342 26345 26345 26352 26352 26354 26357 26359 26368 26371 26371 26376 26377 26379 26379 26381 26383 26388 26391 26395 26395 26397 26399 26406 26408 26410 26414 26417 26417 26420 26420 26422 26424 26426 26426 26429 26429 26431 26431 26433 26433 26438 26438 26441 26441 26446 26449 26451 26451 26454 26454 26457 26457 26460 26460 26462 26470 26474 26474 26477 26477 26479 26483 26485 26485 26487 26487 26492 26492 26494 26495 26501 26501 26503 26503 26505 26505 26507 26508 26512 26512 26517 26517 26519 26519 26522 26522 26524 26525 26528 26530 26534 26534 26537 26537 26543 26543 26547 26548 26550 26553 26555 26555 26560 26561 26564 26564 26566 26566 26570 26570 26574 26577 26579 26580 26584 26584 26586 26586 26589 26590 26594 26594 26596 26596 26599 26599 26601 26601 26604 26604 26606 26607 26609 26609 26611 26613 26619 26619 26622 26623 26625 26628 26643 26643 26646 26647 26654 26654 26657 26658 26665 26667 26674 26674 26676 26676 26680 26681 26684 26685 26688 26692 26694 26694 26696 26696 26701 26702 26704 26708 26713 26713 26716 26717 26719 26719 26723 26723 26727 26727 26740 26740 26742 26743 26750 26751 26753 26753 26755 26755 26757 26757 26765 26765 26767 26767 26771 26772 26775 26775 26779 26779 26781 26781 26783 26784 26786 26786 26790 26792 26797 26797 26799 26801 26803 26803 26805 26806 26809 26810 26812 26812 26820 26820 26822 26822 26824 26827 26829 26829 26831 26831 26834 26834 26836 26837 26839 26840 26842 26842 26847 26849 26851 26851 26855 26855 26862 26863 26866 26866 26873 26874 26880 26881 26884 26885 26888 26888 26891 26895 26898 26898 26905 26908 26913 26915 26917 26918 26920 26920 26922 26922 26928 26928 26932 26932 26934 26934 26937 26937 26941 26941 26943 26943 26954 26954 26963 26965 26969 26970 26972 26974 26976 26978 26984 26984 26986 26987 26989 26991 26995 26997 26999 27001 27004 27006 27009 27010 27018 27018 27022 27022 27025 27025 27028 27029 27032 27032 27035 27036 27040 27040 27047 27047 27054 27054 27057 27058 27060 27060 27067 27067 27070 27071 27073 27073 27075 27075 27079 27079 27082 27086 27088 27088 27091 27091 27096 27097 27101 27102 27106 27106 27111 27112 27115 27115 27117 27117 27122 27122 27129 27129 27131 27131 27133 27133 27135 27135 27138 27138 27141 27141 27146 27148 27154 27156 27159 27159 27161 27161 27163 27163 27166 27167 27169 27171 27177 27179 27182 27182 27184 27184 27189 27190 27192 27194 27197 27197 27204 27204 27206 27208 27211 27211 27224 27225 27231 27231 27233 27234 27238 27238 27243 27243 27250 27251 27256 27256 27262 27264 27268 27268 27277 27278 27280 27280 27287 27287 27292 27292 27296 27296 27298 27299 27306 27306 27308 27308 27310 27310 27315 27315 27320 27320 27323 27323 27329 27331 27345 27345 27347 27347 27354 27355 27358 27359 27362 27362 27364 27364 27368 27368 27370 27370 27386 27387 27396 27397 27402 27402 27410 27410 27414 27414 27421 27421 27423 27425 27427 27427 27431 27431 27442 27442 27447 27450 27453 27454 27459 27459 27463 27463 27465 27465 27468 27468 27470 27470 27472 27472 27475 27476 27481 27481 27483 27483 27487 27487 27489 27492 27494 27494 27497 27498 27503 27503 27507 27508 27512 27513 27515 27515 27519 27520 27523 27524 27526 27526 27529 27531 27533 27533 27541 27542 27544 27544 27550 27550 27556 27556 27562 27563 27567 27567 27569 27573 27575 27575 27578 27580 27583 27584 27589 27590 27595 27595 27597 27598 27602 27604 27606 27606 27608 27608 27611 27611 27615 27615 27627 27628 27631 27631 27635 27635 27656 27656 27663 27663 27665 27665 27667 27668 27671 27671 27675 27675 27683 27684 27700 27700 27703 27704 27710 27714 27726 27726 27728 27728 27733 27733 27735 27735 27738 27738 27740 27744 27746 27746 27752 27752 27754 27754 27759 27760 27762 27763 27770 27770 27773 27774 27777 27779 27782 27782 27784 27784 27788 27789 27792 27792 27794 27795 27798 27798 27801 27803 27809 27810 27819 27819 27822 27822 27825 27825 27827 27827 27832 27839 27841 27841 27844 27845 27849 27850 27852 27852 27859 27859 27861 27861 27863 27863 27865 27867 27869 27869 27873 27875 27877 27877 27880 27880 27882 27882 27887 27889 27891 27891 27908 27908 27915 27916 27922 27922 27927 27927 27929 27929 27931 27931 27934 27935 27941 27941 27945 27947 27954 27955 27957 27958 27960 27960 27963 27963 27965 27966 27969 27969 27972 27973 27993 27994 27996 27996 28003 28004 28006 28006 28009 28010 28012 28012 28014 28015 28020 28020 28023 28025 28037 28037 28039 28040 28044 28044 28046 28046 28051 28051 28053 28054 28057 28057 28059 28060 28076 28076 28079 28079 28082 28082 28085 28085 28088 28088 28092 28092 28096 28096 28101 28103 28107 28108 28111 28111 28113 28114 28117 28117 28120 28121 28126 28126 28129 28129 28132 28132 28134 28134 28136 28136 28138 28140 28142 28142 28145 28147 28149 28149 28151 28156 28165 28165 28167 28171 28179 28179 28181 28181 28185 28187 28189 28189 28191 28193 28195 28199 28201 28201 28203 28207 28216 28218 28220 28220 28222 28222 28227 28227 28234 28234 28237 28238 28246 28246 28248 28248 28251 28252 28255 28255 28263 28263 28267 28267 28270 28271 28274 28274 28278 28278 28286 28288 28290 28290 28300 28300 28303 28304 28310 28310 28312 28312 28316 28317 28319 28319 28322 28322 28325 28325 28330 28330 28335 28335 28338 28338 28342 28343 28346 28346 28349 28349 28351 28351 28354 28354 28356 28357 28361 28361 28363 28364 28369 28369 28371 28373 28381 28382 28396 28396 28399 28399 28402 28402 28404 28404 28407 28408 28414 28415 28417 28418 28422 28422 28425 28425 28431 28431 28433 28433 28435 28437 28448 28448 28450 28451 28459 28460 28465 28466 28472 28472 28478 28479 28481 28481 28485 28485 28500 28500 28504 28504 28507 28508 28511 28511 28516 28516 28518 28518 28525 28528 28532 28532 28536 28536 28538 28538 28540 28540 28544 28546 28548 28548 28550 28550 28552 28552 28558 28558 28561 28561 28567 28567 28577 28577 28579 28580 28586 28586 28593 28593 28595 28595 28597 28597 28601 28601 28608 28611 28614 28614 28628 28629 28632 28632 28635 28635 28639 28641 28644 28644 28651 28652 28654 28655 28657 28657 28659 28659 28661 28662 28666 28666 28670 28670 28673 28673 28677 28677 28679 28679 28681 28681 28683 28683 28687 28687 28689 28689 28693 28693 28696 28696 28698 28699 28701 28703 28710 28712 28716 28716 28720 28720 28722 28722 28734 28734 28748 28748 28753 28753 28760 28760 28771 28771 28779 28779 28783 28784 28792 28792 28796 28797 28805 28805 28809 28810 28814 28814 28818 28818 28825 28825 28843 28847 28851 28851 28856 28859 28872 28872 28875 28875 28879 28879 28889 28889 28893 28893 28895 28895 28913 28913 28921 28921 28925 28925 28932 28932 28937 28937 28943 28943 28948 28948 28953 28954 28956 28956 28961 28961 28966 28966 28982 28982 28988 28988 28998 28999 29001 29001 29004 29004 29006 29006 29013 29014 29017 29017 29020 29020 29026 29026 29028 29031 29033 29033 29036 29036 29038 29038 29053 29053 29060 29060 29064 29064 29066 29066 29071 29071 29076 29077 29081 29081 29087 29087 29096 29096 29100 29100 29105 29105 29113 29113 29118 29118 29121 29121 29123 29123 29128 29129 29134 29134 29136 29136 29138 29138 29140 29141 29143 29143 29151 29152 29157 29159 29164 29166 29173 29173 29177 29177 29179 29180 29182 29183 29190 29190 29197 29197 29200 29200 29211 29211 29224 29224 29226 29226 29228 29229 29232 29232 29234 29234 29237 29238 29242 29248 29254 29256 29259 29260 29266 29266 29272 29273 29275 29275 29277 29277 29279 29279 29281 29282 29287 29287 29289 29289 29298 29298 29300 29300 29305 29305 29309 29310 29312 29314 29319 29319 29330 29330 29334 29334 29344 29344 29346 29346 29351 29351 29356 29356 29359 29359 29361 29362 29366 29366 29369 29369 29374 29374 29378 29380 29382 29382 29390 29390 29392 29392 29394 29394 29399 29399 29401 29401 29403 29403 29408 29410 29417 29417 29420 29421 29431 29433 29436 29437 29450 29450 29462 29463 29467 29469 29471 29471 29476 29477 29481 29483 29486 29487 29492 29492 29494 29495 29502 29503 29508 29509 29518 29519 29527 29527 29539 29539 29544 29544 29546 29546 29552 29552 29554 29554 29557 29557 29559 29560 29562 29563 29572 29572 29575 29575 29577 29577 29579 29579 29590 29590 29609 29609 29618 29619 29627 29627 29629 29629 29632 29632 29634 29634 29640 29642 29645 29646 29650 29650 29654 29654 29662 29662 29664 29664 29667 29667 29669 29669 29674 29674 29677 29678 29681 29681 29685 29685 29688 29688 29694 29694 29699 29699 29701 29703 29705 29705 29730 29730 29733 29734 29737 29738 29742 29742 29746 29750 29754 29754 29759 29759 29761 29761 29781 29781 29785 29788 29790 29792 29794 29796 29801 29802 29807 29808 29811 29811 29814 29814 29822 29822 29827 29827 29833 29833 29835 29835 29854 29855 29858 29858 29863 29863 29872 29872 29885 29885 29898 29898 29903 29903 29908 29908 29916 29916 29920 29920 29922 29923 29926 29927 29929 29929 29934 29934 29936 29938 29942 29944 29953 29953 29955 29957 29964 29966 29969 29969 29971 29971 29973 29973 29976 29976 29978 29978 29980 29980 29982 29983 29987 29987 29989 29990 29992 29992 29995 29996 29999 30003 30007 30008 30010 30012 30020 30020 30022 30022 30025 30029 30031 30031 30033 30033 30036 30036 30041 30045 30048 30048 30050 30050 30052 30055 30057 30059 30061 30061 30063 30064 30067 30068 30070 30072 30079 30079 30082 30082 30086 30087 30089 30091 30094 30095 30097 30097 30100 30100 30106 30106 30109 30109 30115 30115 30117 30117 30123 30123 30129 30131 30133 30133 30136 30137 30140 30142 30146 30147 30149 30149 30151 30151 30154 30154 30157 30157 30162 30162 30164 30165 30168 30169 30171 30171 30174 30174 30178 30179 30185 30185 30192 30192 30194 30196 30202 30202 30204 30204 30206 30207 30209 30209 30217 30217 30219 30219 30221 30221 30239 30242 30244 30244 30247 30247 30256 30256 30260 30260 30267 30267 30274 30274 30278 30280 30284 30284 30290 30290 30294 30294 30296 30296 30300 30300 30305 30306 30311 30314 30316 30316 30320 30320 30322 30322 30326 30326 30328 30328 30330 30334 30336 30336 30338 30340 30342 30344 30347 30347 30350 30350 30352 30352 30355 30355 30358 30358 30361 30364 30366 30366 30374 30374 30382 30382 30384 30384 30388 30388 30391 30394 30399 30399 30402 30403 30406 30406 30408 30408 30410 30410 30413 30413 30418 30418 30422 30423 30427 30428 30430 30431 30433 30433 30435 30437 30439 30439 30442 30442 30446 30446 30450 30450 30452 30452 30456 30456 30459 30459 30462 30462 30465 30465 30468 30468 30471 30473 30475 30476 30491 30491 30494 30496 30500 30502 30505 30505 30519 30520 30522 30522 30524 30524 30528 30528 30534 30535 30554 30555 30561 30561 30563 30563 30565 30566 30568 30568 30571 30571 30585 30585 30590 30591 30603 30603 30606 30606 30609 30609 30622 30622 30624 30624 30629 30629 30636 30637 30640 30640 30643 30643 30646 30646 30649 30649 30651 30653 30655 30655 30663 30663 30669 30669 30679 30679 30682 30684 30690 30691 30693 30693 30695 30695 30697 30697 30701 30703 30707 30707 30716 30716 30722 30722 30732 30732 30738 30738 30740 30741 30752 30753 30757 30759 30770 30770 30772 30772 30778 30778 30783 30783 30789 30789 30798 30798 30813 30813 30820 30820 30827 30828 30831 30831 30834 30834 30836 30836 30842 30842 30844 30844 30849 30849 30854 30855 30860 30862 30865 30865 30867 30867 30869 30869 30871 30871 30874 30874 30883 30883 30887 30887 30889 30890 30895 30895 30901 30901 30906 30906 30908 30908 30910 30910 30913 30913 30917 30918 30922 30923 30928 30929 30932 30932 30938 30938 30951 30952 30956 30956 30959 30959 30964 30964 30973 30973 30977 30977 30983 30983 30990 30990 30993 30994 31001 31001 31014 31014 31018 31020 31024 31024 31034 31034 31036 31036 31038 31038 31040 31041 31047 31049 31056 31056 31059 31059 31061 31063 31066 31066 31069 31072 31074 31074 31077 31077 31080 31080 31085 31085 31095 31095 31098 31098 31103 31105 31108 31109 31114 31114 31117 31119 31124 31124 31131 31131 31133 31133 31142 31143 31146 31146 31150 31150 31152 31152 31155 31155 31161 31162 31165 31169 31177 31177 31179 31179 31185 31186 31189 31189 31192 31192 31199 31199 31201 31201 31203 31204 31206 31207 31209 31209 31212 31212 31216 31216 31227 31227 31232 31232 31240 31240 31243 31243 31245 31246 31252 31252 31255 31258 31260 31260 31263 31264 31278 31278 31281 31282 31287 31287 31291 31296 31298 31299 31302 31302 31305 31305 31309 31312 31319 31319 31329 31331 31337 31337 31339 31339 31344 31344 31348 31348 31350 31350 31353 31354 31357 31357 31359 31359 31361 31361 31363 31364 31368 31368 31378 31379 31381 31384 31391 31391 31401 31402 31406 31408 31414 31414 31418 31418 31423 31423 31427 31429 31431 31432 31434 31435 31437 31437 31439 31439 31441 31443 31445 31445 31449 31450 31452 31453 31455 31459 31461 31463 31466 31467 31469 31469 31471 31472 31478 31478 31480 31482 31487 31487 31490 31490 31492 31492 31494 31494 31496 31496 31498 31499 31503 31503 31505 31505 31512 31513 31515 31515 31518 31518 31520 31520 31525 31526 31528 31528 31532 31532 31539 31539 31541 31542 31545 31545 31557 31558 31560 31561 31563 31565 31567 31570 31572 31572 31574 31574 31581 31581 31589 31589 31591 31591 31596 31596 31598 31598 31600 31601 31604 31605 31610 31610 31622 31623 31627 31627 31629 31629 31631 31631 31634 31634 31636 31637 31639 31642 31644 31647 31649 31649 31658 31658 31661 31661 31665 31665 31668 31668 31672 31672 31680 31681 31684 31684 31686 31687 31689 31689 31691 31692 31695 31695 31709 31709 31712 31712 31716 31718 31721 31721 31725 31725 31731 31731 31734 31735 31744 31744 31751 31751 31757 31757 31761 31764 31767 31767 31775 31775 31777 31777 31779 31779 31783 31783 31786 31787 31799 31800 31805 31808 31811 31811 31820 31821 31823 31824 31828 31828 31830 31830 31832 31832 31839 31840 31844 31845 31852 31852 31859 31859 31861 31861 31870 31870 31873 31875 31881 31881 31883 31883 31885 31885 31888 31888 31890 31890 31893 31893 31895 31896 31899 31899 31903 31903 31905 31906 31908 31909 31911 31912 31915 31915 31917 31918 31921 31923 31929 31929 31933 31934 31936 31936 31938 31938 31941 31941 31946 31946 31950 31950 31954 31954 31958 31958 31960 31960 31964 31964 31966 31968 31970 31970 31975 31975 31983 31983 31986 31986 31988 31988 31990 31990 31992 31992 31994 31995 31998 31998 32000 32000 32002 32002 32004 32006 32010 32011 32013 32013 32016 32016 32020 32021 32023 32028 32032 32034 32043 32044 32046 32048 32050 32051 32053 32053 32057 32058 32063 32063 32066 32070 32072 32072 32075 32076 32078 32080 32086 32086 32091 32092 32094 32094 32097 32099 32102 32102 32104 32104 32110 32110 32113 32115 32117 32118 32121 32121 32125 32125 32137 32137 32143 32143 32147 32147 32153 32156 32159 32160 32162 32163 32171 32178 32180 32181 32183 32184 32186 32187 32189 32191 32199 32199 32202 32203 32207 32207 32209 32210 32213 32214 32216 32216 32218 32218 32220 32222 32224 32225 32228 32228 32232 32233 32236 32236 32239 32239 32242 32242 32244 32244 32251 32251 32257 32257 32260 32261 32265 32267 32274 32274 32283 32283 32286 32287 32289 32291 32294 32294 32299 32299 32302 32302 32305 32306 32309 32309 32311 32311 32313 32315 32317 32318 32321 32321 32323 32323 32326 32326 32330 32331 32333 32333 32338 32338 32340 32342 32345 32346 32349 32350 32358 32359 32361 32362 32365 32365 32368 32368 32377 32377 32379 32381 32383 32383 32386 32387 32392 32394 32396 32396 32398 32400 32402 32404 32406 32406 32411 32412 32566 32566 32568 32568 32570 32570 32581 32581 32583 32583 32588 32590 32592 32593 32596 32597 32600 32600 32607 32608 32615 32619 32622 32622 32624 32624 32626 32626 32629 32629 32631 32633 32642 32643 32645 32648 32650 32650 32652 32652 32654 32654 32660 32660 32666 32666 32669 32670 32673 32673 32675 32676 32680 32681 32686 32687 32690 32690 32694 32694 32696 32697 32701 32701 32705 32705 32709 32710 32714 32714 32716 32716 32722 32722 32724 32725 32736 32737 32742 32742 32745 32745 32747 32747 32752 32752 32755 32755 32761 32761 32763 32764 32768 32769 32771 32774 32779 32780 32784 32784 32786 32786 32789 32789 32791 32793 32796 32796 32801 32801 32808 32808 32819 32819 32822 32822 32827 32827 32829 32829 32831 32831 32838 32838 32842 32842 32850 32850 32854 32854 32856 32856 32858 32858 32862 32863 32865 32866 32872 32872 32879 32880 32882 32884 32886 32887 32889 32889 32893 32895 32900 32903 32905 32905 32907 32908 32915 32915 32918 32918 32920 32920 32922 32923 32925 32925 32929 32930 32933 32933 32937 32938 32940 32941 32943 32943 32945 32946 32948 32948 32954 32954 32963 32964 32966 32966 32972 32972 32974 32974 32982 32982 32985 32987 32989 32990 32993 32993 32996 32997 33007 33007 33009 33009 33012 33012 33016 33016 33020 33021 33026 33026 33029 33034 33050 33051 33059 33059 33065 33065 33071 33071 33073 33073 33075 33075 33081 33081 33086 33086 33094 33094 33099 33099 33102 33102 33104 33105 33107 33109 33119 33119 33125 33126 33131 33131 33134 33134 33136 33137 33140 33140 33144 33146 33151 33152 33154 33155 33160 33160 33162 33162 33167 33167 33171 33171 33173 33173 33178 33178 33180 33181 33184 33184 33187 33188 33192 33193 33200 33200 33203 33203 33205 33205 33208 33208 33210 33210 33213 33216 33218 33218 33222 33222 33224 33225 33229 33229 33233 33233 33235 33235 33240 33242 33247 33248 33251 33251 33253 33253 33255 33256 33258 33258 33261 33261 33267 33268 33274 33276 33278 33278 33281 33282 33285 33285 33287 33290 33292 33294 33296 33296 33298 33298 33302 33304 33307 33308 33310 33311 33321 33324 33326 33326 33331 33331 33333 33337 33344 33344 33351 33351 33368 33370 33373 33373 33375 33375 33378 33378 33380 33380 33382 33382 33384 33384 33386 33387 33390 33391 33393 33394 33398 33400 33406 33406 33419 33419 33421 33421 33426 33426 33433 33433 33437 33437 33439 33439 33445 33446 33451 33453 33455 33455 33457 33457 33459 33459 33464 33465 33467 33467 33469 33469 33477 33477 33489 33492 33495 33495 33497 33497 33499 33500 33502 33503 33505 33505 33507 33507 33509 33511 33515 33515 33521 33521 33523 33524 33529 33531 33537 33542 33545 33545 33550 33550 33558 33560 33564 33564 33571 33571 33576 33576 33579 33579 33583 33583 33585 33586 33588 33590 33592 33593 33600 33600 33605 33605 33609 33610 33615 33616 33618 33618 33624 33624 33634 33634 33651 33651 33653 33653 33655 33655 33659 33660 33663 33663 33669 33669 33671 33671 33673 33674 33678 33678 33683 33683 33686 33686 33690 33690 33694 33696 33698 33698 33704 33704 33706 33707 33713 33713 33717 33717 33725 33725 33729 33729 33733 33733 33735 33735 33738 33738 33740 33740 33742 33742 33747 33747 33750 33750 33752 33752 33756 33756 33759 33760 33769 33769 33771 33771 33775 33778 33780 33780 33782 33783 33787 33787 33789 33789 33795 33796 33799 33799 33803 33806 33811 33811 33824 33824 33826 33826 33833 33834 33836 33836 33841 33841 33845 33845 33848 33848 33852 33853 33862 33862 33864 33865 33870 33870 33879 33879 33883 33883 33889 33891 33894 33894 33897 33897 33899 33903 33905 33905 33909 33909 33911 33911 33913 33914 33922 33922 33924 33924 33931 33931 33936 33936 33940 33940 33945 33945 33948 33948 33951 33951 33953 33953 33965 33965 33970 33970 33972 33972 33976 33977 33979 33980 33983 33983 33985 33985 33988 33988 33990 33990 33993 33995 33997 33997 34000 34001 34006 34006 34009 34010 34012 34012 34028 34028 34030 34030 34036 34036 34044 34044 34047 34048 34054 34054 34065 34065 34067 34069 34071 34072 34074 34074 34079 34079 34081 34081 34086 34086 34092 34093 34101 34101 34109 34109 34112 34113 34115 34115 34120 34123 34126 34126 34131 34131 34133 34133 34135 34138 34147 34147 34152 34155 34157 34157 34167 34167 34174 34174 34176 34176 34180 34180 34183 34184 34186 34186 34192 34193 34196 34196 34199 34199 34201 34201 34203 34204 34212 34212 34214 34214 34216 34220 34222 34224 34233 34234 34241 34241 34249 34249 34253 34253 34255 34256 34261 34261 34268 34269 34276 34277 34281 34282 34295 34295 34297 34299 34302 34302 34306 34306 34310 34311 34314 34315 34323 34323 34326 34327 34330 34330 34338 34338 34349 34349 34351 34352 34367 34367 34381 34382 34384 34384 34388 34389 34394 34394 34396 34396 34398 34399 34407 34407 34411 34411 34417 34417 34425 34425 34427 34427 34442 34444 34451 34451 34453 34453 34467 34468 34473 34475 34479 34480 34486 34486 34500 34500 34502 34503 34505 34505 34507 34507 34509 34510 34516 34516 34521 34521 34523 34523 34526 34527 34532 34532 34537 34537 34540 34543 34552 34553 34555 34555 34558 34558 34560 34560 34562 34563 34566 34566 34568 34570 34573 34573 34577 34578 34584 34584 34586 34586 34588 34588 34597 34597 34601 34601 34612 34612 34615 34615 34619 34619 34623 34623 34633 34633 34635 34636 34638 34638 34643 34643 34645 34645 34647 34647 34649 34649 34655 34656 34659 34659 34662 34662 34664 34664 34666 34666 34670 34670 34676 34676 34678 34678 34680 34680 34687 34687 34690 34690 34701 34701 34719 34719 34722 34722 34731 34731 34735 34735 34739 34739 34746 34747 34749 34749 34752 34752 34756 34756 34758 34759 34763 34763 34768 34768 34770 34770 34784 34784 34799 34799 34802 34802 34806 34807 34809 34809 34811 34811 34814 34814 34821 34821 34823 34823 34829 34831 34833 34833 34837 34838 34849 34851 34855 34855 34865 34865 34870 34870 34873 34873 34875 34875 34880 34880 34882 34882 34884 34884 34886 34886 34892 34893 34898 34899 34903 34903 34905 34905 34907 34907 34909 34910 34913 34915 34920 34920 34923 34923 34928 34928 34930 34930 34933 34933 34935 34935 34941 34943 34945 34946 34952 34952 34955 34955 34957 34957 34962 34962 34966 34967 34969 34969 34974 34974 34978 34978 34980 34980 34987 34987 34990 34990 34992 34993 34996 34997 34999 34999 35007 35007 35009 35013 35023 35023 35028 35029 35032 35033 35036 35037 35039 35039 35041 35041 35048 35048 35058 35061 35064 35065 35068 35070 35074 35074 35076 35076 35079 35079 35082 35082 35084 35084 35088 35088 35090 35091 35100 35102 35109 35109 35114 35115 35126 35126 35128 35128 35131 35131 35137 35137 35139 35140 35148 35149 35158 35158 35166 35168 35172 35172 35174 35174 35178 35178 35181 35181 35183 35183 35186 35186 35188 35188 35191 35191 35198 35199 35201 35201 35203 35203 35206 35208 35210 35211 35215 35215 35219 35219 35222 35224 35226 35226 35233 35233 35238 35239 35241 35242 35244 35244 35247 35247 35250 35251 35258 35258 35261 35261 35263 35264 35282 35282 35290 35290 35292 35293 35299 35299 35302 35303 35316 35316 35320 35320 35328 35328 35330 35331 35336 35336 35338 35338 35340 35340 35342 35342 35344 35344 35346 35347 35350 35352 35355 35355 35357 35357 35359 35359 35363 35363 35365 35365 35370 35370 35373 35373 35377 35377 35379 35380 35382 35383 35386 35388 35393 35393 35398 35398 35400 35400 35408 35410 35412 35413 35419 35419 35422 35422 35424 35424 35426 35427 35430 35430 35433 35433 35435 35438 35440 35443 35449 35449 35452 35452 35458 35458 35460 35461 35463 35463 35465 35465 35468 35469 35473 35473 35475 35475 35477 35477 35480 35480 35482 35482 35486 35486 35488 35489 35491 35496 35500 35501 35504 35504 35506 35506 35513 35513 35516 35516 35518 35519 35522 35522 35524 35524 35527 35527 35531 35533 35535 35535 35538 35538 35542 35542 35546 35548 35550 35554 35556 35556 35558 35559 35563 35563 35565 35566 35569 35569 35571 35571 35574 35576 35578 35578 35582 35582 35584 35586 35588 35588 35591 35591 35596 35596 35598 35598 35600 35600 35604 35604 35606 35607 35609 35611 35613 35613 35616 35617 35622 35622 35624 35624 35627 35628 35635 35635 35641 35641 35646 35646 35649 35649 35657 35657 35660 35660 35662 35663 35667 35667 35670 35670 35672 35672 35674 35676 35679 35679 35686 35686 35691 35692 35695 35698 35700 35700 35703 35703 35709 35709 35711 35712 35715 35715 35722 35722 35724 35724 35726 35726 35728 35728 35730 35731 35734 35734 35737 35738 35895 35895 35898 35898 35903 35903 35905 35905 35910 35910 35912 35912 35914 35914 35916 35916 35918 35918 35920 35920 35925 35925 35930 35930 35937 35938 35946 35948 35960 35962 35964 35964 35970 35970 35973 35973 35977 35978 35980 35982 35988 35988 35992 35992 35997 35998 36000 36002 36007 36016 36018 36020 36022 36024 36027 36029 36031 36036 36039 36040 36042 36042 36045 36046 36049 36049 36051 36051 36058 36060 36062 36062 36064 36064 36066 36068 36070 36070 36074 36074 36077 36077 36080 36080 36084 36084 36090 36093 36100 36101 36103 36104 36106 36107 36109 36109 36111 36112 36114 36116 36118 36118 36196 36196 36198 36199 36203 36203 36205 36205 36208 36209 36211 36212 36214 36215 36225 36225 36229 36229 36234 36234 36249 36249 36259 36259 36264 36264 36275 36275 36282 36282 36286 36286 36290 36290 36299 36300 36303 36303 36310 36310 36314 36315 36317 36317 36319 36319 36321 36321 36323 36323 36328 36328 36330 36331 36335 36335 36339 36339 36341 36341 36348 36348 36351 36351 36360 36362 36367 36368 36381 36383 36394 36394 36400 36400 36404 36405 36418 36418 36420 36420 36423 36426 36428 36428 36432 36432 36437 36437 36441 36441 36447 36448 36451 36452 36466 36466 36468 36468 36470 36470 36476 36476 36481 36481 36484 36485 36487 36487 36490 36491 36493 36493 36497 36497 36499 36500 36505 36505 36513 36513 36522 36524 36527 36529 36542 36542 36549 36550 36552 36552 36554 36557 36559 36559 36562 36562 36571 36571 36575 36575 36578 36579 36587 36587 36600 36600 36603 36606 36611 36611 36613 36613 36617 36618 36620 36620 36626 36629 36633 36633 36635 36637 36639 36639 36646 36646 36649 36650 36655 36655 36659 36659 36664 36665 36667 36667 36670 36671 36674 36674 36676 36678 36681 36681 36684 36686 36695 36695 36700 36700 36703 36703 36705 36708 36763 36764 36766 36767 36771 36771 36775 36776 36781 36786 36791 36791 36794 36796 36799 36799 36802 36802 36804 36805 36814 36814 36817 36817 36820 36820 36826 36826 36834 36834 36837 36838 36841 36843 36845 36845 36847 36848 36852 36852 36855 36858 36861 36861 36864 36865 36867 36867 36869 36870 36875 36875 36877 36881 36883 36887 36889 36890 36893 36899 36903 36903 36910 36910 36913 36914 36917 36918 36920 36921 36924 36924 36926 36926 36929 36930 36933 36933 36935 36935 36937 36939 36941 36950 36952 36953 36956 36956 36958 36958 36960 36961 36963 36963 36965 36965 36967 36969 36973 36975 36978 36978 36981 36984 36986 36986 36988 36989 36991 36996 36999 36999 37001 37002 37007 37007 37009 37009 37027 37027 37030 37030 37032 37032 37034 37034 37039 37039 37041 37041 37045 37045 37048 37048 37057 37057 37066 37066 37070 37070 37083 37083 37086 37086 37089 37090 37092 37092 37096 37096 37101 37101 37109 37109 37111 37111 37117 37117 37122 37122 37138 37138 37141 37141 37145 37145 37159 37159 37165 37165 37168 37168 37170 37170 37193 37198 37202 37202 37204 37204 37206 37206 37208 37208 37218 37219 37221 37221 37225 37226 37228 37228 37234 37235 37237 37237 37239 37240 37250 37250 37255 37255 37257 37257 37259 37259 37261 37261 37264 37264 37266 37266 37271 37271 37276 37276 37282 37282 37284 37284 37290 37291 37295 37295 37300 37301 37304 37304 37306 37306 37312 37313 37318 37321 37323 37329 37334 37336 37338 37343 37345 37345 37347 37351 37357 37358 37365 37366 37372 37372 37375 37375 37382 37382 37386 37386 37389 37390 37392 37393 37396 37397 37406 37406 37417 37417 37420 37420 37428 37428 37431 37431 37433 37434 37436 37436 37439 37440 37444 37445 37448 37449 37451 37451 37454 37454 37456 37457 37463 37463 37465 37467 37470 37470 37474 37474 37476 37476 37478 37479 37489 37489 37495 37496 37502 37502 37504 37504 37507 37507 37509 37509 37512 37512 37521 37521 37523 37523 37525 37526 37528 37528 37530 37532 37543 37543 37549 37549 37559 37559 37561 37561 37583 37584 37586 37587 37589 37589 37591 37591 37593 37593 37600 37600 37604 37604 37607 37607 37609 37610 37613 37613 37618 37619 37624 37628 37631 37631 37634 37634 37638 37638 37647 37648 37656 37658 37661 37662 37664 37667 37669 37670 37672 37672 37675 37676 37678 37679 37682 37682 37685 37685 37690 37691 37700 37700 37704 37704 37707 37707 37709 37709 37716 37716 37718 37719 37723 37724 37728 37728 37740 37740 37742 37742 37744 37744 37749 37749 37756 37756 37758 37758 37772 37772 37780 37780 37782 37783 37786 37786 37796 37796 37799 37799 37804 37806 37808 37808 37817 37817 37827 37827 37830 37830 37832 37832 37840 37841 37846 37848 37853 37854 37857 37857 37860 37861 37864 37864 37880 37880 37891 37891 37895 37895 37904 37904 37907 37908 37912 37914 37921 37921 37931 37931 37937 37937 37941 37942 37944 37944 37946 37946 37953 37953 37956 37957 37960 37960 37969 37971 37978 37979 37982 37982 37984 37984 37986 37986 37994 37994 38000 38000 38005 38005 38007 38007 38012 38015 38017 38017 38263 38263 38272 38272 38274 38275 38279 38279 38281 38283 38287 38287 38289 38292 38294 38294 38296 38297 38304 38304 38306 38309 38311 38312 38317 38317 38322 38322 38329 38329 38331 38332 38334 38334 38339 38339 38343 38343 38346 38346 38348 38349 38356 38358 38360 38360 38364 38364 38369 38370 38373 38373 38428 38428 38433 38433 38440 38440 38442 38442 38446 38447 38450 38450 38459 38459 38463 38464 38466 38466 38468 38468 38475 38477 38479 38480 38491 38495 38498 38502 38506 38506 38508 38508 38512 38512 38514 38515 38517 38520 38522 38522 38525 38525 38533 38534 38536 38536 38538 38539 38541 38543 38548 38549 38551 38553 38555 38557 38560 38560 38563 38563 38567 38568 38570 38570 38575 38578 38580 38580 38582 38585 38587 38588 38592 38593 38596 38599 38601 38601 38603 38606 38609 38609 38613 38614 38617 38617 38619 38620 38626 38627 38632 38632 38634 38635 38640 38640 38642 38642 38646 38647 38649 38649 38651 38651 38656 38656 38660 38660 38662 38664 38666 38666 38669 38671 38673 38673 38675 38675 38678 38678 38681 38681 38684 38684 38686 38686 38692 38692 38695 38695 38698 38698 38704 38704 38706 38707 38712 38713 38715 38715 38717 38718 38722 38724 38726 38726 38728 38729 38733 38733 38735 38735 38737 38738 38741 38742 38745 38745 38748 38748 38750 38750 38752 38754 38756 38756 38758 38758 38760 38761 38763 38763 38765 38765 38769 38769 38772 38772 38777 38778 38780 38780 38785 38785 38788 38790 38795 38795 38797 38797 38799 38800 38808 38808 38812 38812 38816 38816 38819 38819 38822 38822 38824 38824 38827 38827 38829 38829 38835 38836 38851 38851 38854 38854 38856 38856 38859 38859 38867 38867 38876 38876 38893 38894 38898 38899 38901 38902 38907 38907 38911 38911 38913 38915 38917 38918 38920 38920 38924 38924 38927 38931 38935 38936 38938 38938 38945 38945 38948 38948 38956 38957 38964 38964 38967 38968 38971 38973 38982 38982 38987 38991 38996 38997 38999 39000 39003 39003 39006 39006 39013 39013 39015 39015 39019 39019 39023 39025 39027 39028 39080 39080 39082 39082 39087 39087 39089 39089 39094 39094 39107 39108 39110 39110 39131 39132 39135 39135 39138 39138 39145 39145 39147 39147 39149 39151 39154 39154 39156 39156 39164 39166 39171 39171 39173 39173 39177 39178 39180 39180 39184 39184 39186 39188 39192 39192 39197 39198 39200 39201 39204 39204 39207 39208 39212 39212 39214 39214 39229 39230 39234 39234 39237 39237 39241 39241 39243 39244 39248 39250 39253 39253 39255 39255 39318 39321 39326 39326 39333 39333 39336 39336 39340 39342 39347 39348 39356 39356 39361 39361 39364 39366 39368 39368 39376 39378 39381 39381 39384 39384 39387 39387 39389 39389 39391 39391 39394 39394 39405 39406 39409 39410 39416 39416 39419 39419 39423 39423 39425 39425 39429 39429 39438 39439 39442 39443 39449 39449 39464 39464 39467 39467 39472 39472 39479 39479 39486 39486 39488 39488 39490 39491 39493 39493 39501 39502 39509 39509 39511 39511 39514 39515 39519 39519 39522 39522 39524 39525 39529 39531 39592 39592 39597 39597 39600 39600 39608 39608 39612 39612 39616 39616 39620 39620 39631 39631 39633 39633 39635 39636 39640 39641 39644 39644 39646 39647 39650 39651 39654 39654 39658 39659 39661 39663 39665 39665 39668 39668 39671 39671 39675 39675 39686 39686 39704 39704 39706 39706 39711 39711 39714 39715 39717 39717 39719 39722 39726 39727 39729 39730 39739 39740 39745 39749 39757 39759 39761 39761 39764 39764 39768 39768 39770 39770 39791 39791 39794 39794 39796 39797 39811 39811 39822 39823 39825 39827 39830 39831 39839 39840 39848 39848 39850 39851 39853 39854 39857 39857 39860 39860 39865 39865 39867 39867 39872 39872 39878 39878 39881 39882 39887 39887 39889 39890 39892 39892 39894 39894 39899 39899 39905 39908 39912 39912 39920 39922 39925 39925 39936 39936 39940 39940 39942 39942 39944 39946 39948 39949 39952 39952 39954 39957 39963 39963 39969 39969 39972 39973 39981 39984 39986 39986 39993 39995 39998 39998 40006 40008 40018 40018 40023 40023 40026 40026 40032 40032 40039 40039 40054 40054 40056 40056 40165 40165 40167 40167 40169 40169 40171 40172 40176 40176 40179 40180 40182 40182 40195 40195 40198 40201 40206 40206 40210 40210 40213 40213 40219 40219 40223 40223 40227 40227 40230 40230 40232 40232 40234 40236 40251 40251 40254 40255 40257 40257 40260 40260 40262 40262 40264 40264 40272 40273 40281 40281 40284 40286 40288 40289 40292 40292 40299 40300 40303 40304 40306 40306 40314 40314 40327 40327 40329 40329 40335 40335 40346 40346 40356 40356 40361 40361 40363 40363 40367 40367 40370 40370 40372 40372 40376 40376 40378 40379 40385 40386 40388 40388 40390 40390 40399 40399 40403 40403 40409 40409 40422 40422 40429 40429 40431 40431 40434 40434 40440 40442 40445 40445 40473 40475 40478 40478 40565 40565 40568 40569 40573 40573 40575 40575 40577 40577 40584 40584 40587 40588 40593 40595 40597 40597 40599 40599 40605 40605 40607 40607 40613 40614 40617 40618 40621 40621 40632 40636 40638 40639 40644 40644 40652 40658 40660 40660 40664 40665 40667 40670 40672 40672 40677 40677 40680 40680 40687 40687 40692 40692 40694 40695 40697 40697 40699 40701 40711 40712 40718 40718 40723 40723 40725 40725 40736 40737 40748 40748 40763 40763 40766 40766 40778 40779 40782 40783 40786 40786 40788 40788 40799 40803 40806 40807 40810 40810 40812 40812 40818 40818 40822 40823 40845 40845 40853 40853 40860 40861 40864 40864 57344 59223 63785 63785 63964 63964 64014 64045 65281 65374 65377 65439 65504 65509 917504 917631)) (make-character-set :mib-enum 2252 :name "windows-1252" :aliases 'nil :mime-encoding 'nil :source '"Microsoft (http://www.iana.org/assignments/charset-reg/windows-1252) [Wendt]" :comments 'nil :references 'nil :ranges #(0 127 160 255 338 339 352 353 376 376 381 382 402 402 710 710 732 732 8211 8212 8216 8218 8220 8222 8224 8226 8230 8230 8240 8240 8249 8250 8364 8364 8482 8482)) (make-character-set :mib-enum 2253 :name "windows-1253" :aliases 'nil :mime-encoding 'nil :source '"Microsoft (http://www.iana.org/assignments/charset-reg/windows-1253) [Lazhintseva]" :comments 'nil :references 'nil :ranges #(0 127 160 160 163 169 171 174 176 179 181 183 187 187 189 189 402 402 900 902 904 906 908 908 910 929 931 974 8211 8213 8216 8218 8220 8222 8224 8226 8230 8230 8240 8240 8249 8250 8364 8364 8482 8482)) (make-character-set :mib-enum 2250 :name "windows-1250" :aliases 'nil :mime-encoding 'nil :source '"Microsoft (http://www.iana.org/assignments/charset-reg/windows-1250) [Lazhintseva]" :comments 'nil :references 'nil :ranges #(0 127 160 160 164 164 166 169 171 174 176 177 180 184 187 187 193 194 196 196 199 199 201 201 203 203 205 206 211 212 214 215 218 218 220 221 223 223 225 226 228 228 231 231 233 233 235 235 237 238 243 244 246 247 250 250 252 253 258 263 268 273 280 283 313 314 317 318 321 324 327 328 336 337 340 341 344 347 350 357 366 369 377 382 711 711 728 729 731 731 733 733 8211 8212 8216 8218 8220 8222 8224 8226 8230 8230 8240 8240 8249 8250 8364 8364 8482 8482)) (make-character-set :mib-enum 1012 :name "UTF-7" :aliases 'nil :mime-encoding 'nil :source '"RFC 2152" :comments 'nil :references '("[RFC2152]") :ranges #(0 1114111)) (make-character-set :mib-enum 2251 :name "windows-1251" :aliases 'nil :mime-encoding 'nil :source '"Microsoft (http://www.iana.org/assignments/charset-reg/windows-1251) [Lazhintseva]" :comments 'nil :references 'nil :ranges #(0 127 160 160 164 164 166 167 169 169 171 174 176 177 181 183 187 187 1025 1036 1038 1103 1105 1116 1118 1119 1168 1169 8211 8212 8216 8218 8220 8222 8224 8226 8230 8230 8240 8240 8249 8250 8364 8364 8470 8470 8482 8482)) (make-character-set :mib-enum 15 :name "JIS_X0201" :aliases '("csHalfWidthKatakana" "X0201") :mime-encoding 'nil :source '"JIS X 0201-1976. One byte only, this is equivalent to JIS/Roman (similar to ASCII) plus eight-bit half-width Katakana" :comments 'nil :references '("[RFC1345,KXS2]") :ranges #(0 91 93 125 127 127 165 165 8254 8254 65377 65439)) (make-character-set :mib-enum 2256 :name "windows-1256" :aliases 'nil :mime-encoding 'nil :source '"Microsoft (http://www.iana.org/assignments/charset-reg/windows-1256) [Lazhintseva]" :comments 'nil :references 'nil :ranges #(0 127 160 160 162 169 171 185 187 190 215 215 224 224 226 226 231 235 238 239 244 244 247 247 249 249 251 252 338 339 402 402 710 710 1548 1548 1563 1563 1567 1567 1569 1594 1600 1618 1657 1657 1662 1662 1670 1670 1672 1672 1681 1681 1688 1688 1705 1705 1711 1711 1722 1722 1726 1726 1729 1729 1746 1746 8204 8207 8211 8212 8216 8218 8220 8222 8224 8226 8230 8230 8240 8240 8249 8250 8364 8364 8482 8482)) (make-character-set :mib-enum 2049 :name "IBM861" :aliases '("csIBM861" "cp-is" "861" "cp861") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges #(0 127 160 161 163 163 171 172 176 178 183 183 187 189 191 191 193 193 196 199 201 201 205 205 208 208 211 211 214 214 216 216 218 218 220 226 228 235 237 237 240 240 243 244 246 248 250 254 402 402 915 915 920 920 931 931 934 934 937 937 945 945 948 949 956 956 960 960 963 964 966 966 8319 8319 8359 8359 8729 8730 8734 8734 8745 8745 8776 8776 8801 8801 8804 8805 8976 8976 8992 8993 9472 9472 9474 9474 9484 9484 9488 9488 9492 9492 9496 9496 9500 9500 9508 9508 9516 9516 9524 9524 9532 9532 9552 9580 9600 9600 9604 9604 9608 9608 9612 9612 9616 9619 9632 9632)) (make-character-set :mib-enum 2026 :name #17="Big5" :aliases '("csBig5") :mime-encoding '#17# :source '"Chinese for Taiwan Multi-byte set. PCL Symbol Set Id: 18T" :comments 'nil :references 'nil :ranges #(0 128 167 167 175 177 183 183 215 215 247 247 711 711 713 715 717 717 729 729 913 929 931 937 945 961 963 969 8211 8212 8216 8217 8220 8221 8229 8231 8242 8242 8245 8245 8251 8251 8364 8364 8451 8451 8453 8453 8457 8457 8544 8553 8592 8595 8598 8601 8725 8725 8730 8730 8734 8736 8739 8739 8741 8741 8745 8747 8750 8750 8756 8757 8786 8786 8800 8801 8806 8807 8853 8853 8857 8857 8869 8869 8895 8895 9472 9472 9474 9474 9484 9484 9488 9488 9492 9492 9496 9496 9500 9500 9508 9508 9516 9516 9524 9524 9532 9532 9552 9588 9601 9615 9619 9621 9632 9633 9650 9651 9660 9661 9670 9671 9675 9675 9678 9679 9698 9701 9733 9734 9792 9792 9794 9794 12288 12291 12296 12306 12308 12309 12317 12318 12321 12329 12549 12585 12963 12963 13198 13199 13212 13214 13217 13217 13252 13252 13262 13262 13265 13266 13269 13269 19968 19969 19971 19971 19975 19985 19988 19990 19992 19993 19998 19999 20006 20006 20011 20011 20013 20014 20016 20019 20024 20025 20027 20028 20034 20035 20037 20037 20039 20040 20043 20043 20045 20047 20050 20051 20054 20054 20056 20057 20060 20063 20073 20073 20083 20083 20094 20095 20098 20100 20102 20102 20104 20104 20107 20110 20113 20117 20121 20121 20123 20123 20126 20127 20129 20130 20132 20134 20136 20136 20139 20142 20147 20147 20150 20150 20153 20154 20160 20164 20166 20171 20173 20173 20180 20186 20188 20191 20193 20193 20195 20197 20200 20201 20208 20215 20219 20219 20221 20221 20223 20226 20228 20229 20232 20235 20237 20245 20248 20249 20253 20253 20258 20258 20268 20269 20271 20272 20275 20276 20278 20278 20280 20280 20282 20287 20289 20289 20291 20291 20294 20297 20300 20324 20327 20327 20329 20332 20334 20336 20339 20361 20363 20363 20365 20365 20367 20370 20372 20376 20378 20382 20398 20399 20402 20403 20405 20407 20409 20411 20415 20421 20423 20423 20425 20427 20429 20433 20435 20436 20438 20449 20460 20460 20462 20463 20465 20465 20467 20472 20474 20474 20478 20478 20480 20480 20485 20487 20489 20489 20491 20495 20497 20508 20510 20515 20517 20525 20527 20529 20531 20531 20533 20533 20535 20535 20540 20540 20544 20545 20547 20547 20549 20559 20561 20561 20563 20563 20565 20565 20567 20567 20570 20581 20584 20587 20589 20592 20594 20599 20602 20602 20605 20605 20608 20608 20610 20611 20613 20613 20615 20615 20619 20622 20625 20626 20628 20630 20632 20638 20642 20643 20652 20664 20666 20667 20669 20671 20673 20674 20676 20683 20686 20687 20689 20689 20691 20695 20698 20699 20701 20701 20704 20704 20707 20714 20716 20721 20723 20723 20725 20726 20728 20729 20731 20731 20733 20736 20738 20748 20752 20757 20759 20760 20762 20762 20764 20764 20767 20770 20772 20774 20777 20778 20781 20782 20784 20789 20791 20797 20799 20801 20803 20809 20811 20813 20818 20818 20820 20821 20823 20823 20825 20831 20833 20835 20837 20837 20839 20841 20843 20846 20849 20849 20853 20856 20860 20860 20864 20864 20871 20871 20873 20874 20877 20877 20879 20879 20881 20885 20887 20888 20894 20894 20896 20896 20898 20898 20900 20901 20906 20906 20908 20908 20912 20913 20918 20919 20921 20921 20924 20926 20932 20934 20936 20936 20938 20942 20944 20944 20948 20948 20951 20952 20956 20958 20960 20961 20976 20977 20979 20979 20981 20982 20984 20986 20989 20989 20992 20993 20995 20995 20998 21002 21004 21004 21006 21006 21008 21011 21014 21015 21020 21022 21025 21025 21028 21029 21032 21034 21038 21038 21040 21043 21045 21048 21050 21051 21057 21057 21059 21060 21062 21063 21065 21070 21074 21074 21076 21078 21082 21087 21089 21090 21097 21103 21106 21106 21108 21109 21111 21112 21114 21117 21119 21124 21127 21133 21137 21137 21139 21139 21142 21145 21147 21147 21151 21152 21155 21155 21158 21158 21161 21166 21179 21180 21182 21182 21184 21187 21191 21191 21193 21193 21197 21197 21202 21203 21205 21209 21211 21211 21213 21215 21218 21220 21222 21222 21225 21225 21227 21227 21231 21233 21235 21237 21239 21240 21242 21244 21246 21247 21253 21254 21256 21259 21261 21266 21269 21271 21273 21274 21276 21277 21279 21283 21290 21290 21293 21293 21295 21297 21300 21300 21303 21303 21305 21305 21308 21313 21315 21317 21319 21322 21324 21325 21329 21332 21335 21335 21338 21338 21340 21340 21342 21342 21344 21345 21347 21347 21350 21350 21356 21356 21358 21363 21365 21365 21367 21369 21371 21372 21375 21375 21378 21378 21380 21380 21386 21386 21390 21391 21394 21394 21396 21396 21398 21402 21404 21407 21412 21413 21415 21415 21420 21421 21426 21426 21428 21428 21433 21433 21435 21435 21443 21443 21448 21451 21453 21453 21460 21460 21462 21463 21467 21467 21471 21471 21473 21478 21480 21491 21493 21493 21496 21496 21499 21500 21505 21505 21507 21508 21510 21522 21528 21529 21531 21536 21540 21550 21552 21553 21555 21555 21557 21561 21563 21566 21568 21571 21573 21576 21578 21578 21582 21583 21588 21588 21600 21608 21611 21612 21615 21624 21626 21634 21636 21636 21638 21640 21643 21646 21648 21650 21653 21654 21656 21656 21658 21658 21664 21666 21669 21681 21683 21683 21686 21688 21690 21705 21710 21711 21718 21718 21726 21726 21728 21730 21732 21739 21741 21742 21745 21747 21751 21752 21754 21757 21759 21759 21761 21761 21763 21772 21774 21778 21780 21780 21783 21783 21786 21786 21798 21799 21802 21802 21804 21817 21819 21820 21822 21822 21824 21825 21827 21830 21832 21832 21834 21835 21837 21842 21845 21847 21852 21852 21854 21855 21857 21862 21866 21866 21877 21879 21883 21892 21895 21903 21905 21909 21912 21914 21916 21917 21919 21919 21921 21928 21930 21934 21937 21939 21941 21941 21947 21947 21951 21952 21954 21974 21977 21981 21983 21983 21985 21993 21999 21999 22002 22002 22006 22007 22009 22010 22012 22018 22020 22020 22022 22022 22024 22025 22028 22032 22034 22039 22043 22045 22047 22047 22055 22055 22057 22058 22060 22060 22062 22064 22066 22070 22072 22075 22077 22082 22085 22086 22088 22090 22092 22092 22094 22094 22099 22099 22103 22106 22110 22110 22112 22112 22114 22118 22120 22132 22134 22137 22142 22151 22156 22160 22163 22163 22165 22165 22167 22170 22172 22173 22181 22184 22186 22190 22194 22199 22204 22206 22208 22211 22213 22214 22216 22221 22225 22225 22227 22228 22231 22231 22234 22235 22237 22241 22244 22245 22247 22247 22250 22251 22254 22254 22256 22256 22263 22263 22265 22266 22271 22271 22273 22276 22279 22285 22290 22292 22294 22294 22296 22296 22298 22300 22302 22304 22306 22307 22312 22314 22316 22320 22323 22324 22331 22331 22334 22334 22336 22337 22341 22341 22343 22343 22345 22354 22369 22370 22372 22372 22374 22374 22376 22379 22381 22381 22383 22391 22395 22397 22400 22400 22402 22403 22411 22412 22415 22415 22419 22421 22423 22427 22429 22432 22434 22437 22446 22446 22453 22454 22456 22458 22460 22461 22463 22463 22465 22467 22470 22471 22475 22476 22478 22480 22482 22482 22484 22485 22492 22492 22495 22501 22503 22503 22505 22505 22508 22510 22512 22525 22528 22530 22532 22542 22544 22544 22548 22548 22553 22553 22555 22558 22560 22561 22563 22565 22567 22570 22572 22585 22587 22587 22589 22589 22591 22591 22600 22607 22609 22613 22615 22619 22621 22622 22626 22629 22632 22632 22635 22635 22637 22637 22639 22639 22641 22641 22644 22646 22649 22659 22661 22667 22670 22673 22675 22676 22680 22680 22684 22689 22691 22691 22693 22694 22696 22697 22699 22700 22702 22703 22705 22705 22707 22707 22714 22719 22721 22722 22725 22729 22734 22735 22737 22742 22744 22747 22749 22751 22754 22756 22759 22761 22763 22764 22767 22767 22772 22772 22777 22778 22780 22783 22787 22787 22790 22790 22796 22799 22802 22802 22804 22807 22809 22810 22812 22812 22816 22816 22818 22818 22820 22821 22823 22823 22825 22831 22833 22833 22839 22840 22844 22844 22846 22846 22848 22848 22852 22853 22855 22858 22862 22865 22867 22869 22871 22872 22874 22874 22876 22876 22880 22882 22887 22887 22889 22891 22893 22894 22896 22900 22902 22905 22907 22917 22922 22922 22925 22928 22930 22931 22934 22937 22941 22942 22944 22952 22958 22959 22961 22966 22969 22974 22976 22977 22979 22979 22981 22984 22986 22996 22998 22998 23000 23000 23002 23006 23008 23009 23011 23014 23016 23018 23020 23022 23025 23031 23034 23041 23043 23043 23049 23050 23052 23052 23055 23055 23057 23057 23059 23059 23061 23065 23067 23068 23070 23072 23075 23075 23077 23077 23081 23081 23085 23086 23091 23091 23093 23097 23100 23100 23102 23102 23104 23108 23110 23114 23116 23117 23120 23123 23125 23128 23130 23136 23138 23138 23140 23143 23145 23146 23148 23149 23152 23152 23159 23160 23162 23165 23167 23167 23171 23172 23178 23180 23182 23184 23186 23189 23191 23191 23194 23199 23202 23202 23205 23207 23209 23209 23212 23212 23214 23234 23236 23236 23238 23245 23253 23267 23269 23270 23272 23278 23283 23291 23293 23293 23295 23295 23297 23299 23301 23301 23303 23305 23307 23308 23311 23312 23315 23316 23318 23319 23321 23323 23325 23326 23328 23329 23331 23336 23338 23338 23340 23344 23346 23346 23348 23348 23352 23352 23356 23360 23363 23363 23365 23365 23367 23368 23371 23374 23376 23377 23379 23384 23386 23389 23391 23391 23394 23397 23401 23401 23403 23404 23406 23406 23408 23411 23413 23413 23415 23416 23418 23419 23421 23421 23423 23423 23425 23425 23427 23429 23431 23433 23435 23436 23438 23439 23442 23443 23445 23445 23447 23452 23458 23464 23468 23470 23472 23472 23475 23478 23480 23481 23487 23490 23492 23495 23498 23502 23504 23508 23510 23510 23512 23513 23518 23532 23534 23538 23541 23542 23544 23544 23546 23546 23553 23553 23555 23556 23559 23570 23573 23574 23578 23578 23583 23583 23586 23586 23588 23589 23592 23592 23594 23594 23596 23596 23600 23601 23603 23603 23607 23612 23614 23617 23620 23624 23627 23633 23636 23638 23640 23641 23644 23645 23648 23648 23650 23653 23655 23658 23660 23663 23665 23665 23667 23668 23673 23676 23678 23678 23686 23686 23688 23693 23695 23701 23709 23709 23711 23729 23731 23731 23733 23736 23750 23756 23758 23760 23762 23764 23766 23771 23774 23775 23784 23784 23786 23786 23788 23790 23792 23793 23796 23796 23798 23801 23803 23803 23805 23805 23807 23809 23814 23815 23819 23823 23825 23826 23828 23828 23830 23831 23833 23835 23837 23840 23842 23849 23854 23854 23856 23866 23868 23869 23871 23875 23877 23877 23879 23879 23881 23884 23886 23886 23888 23890 23893 23893 23897 23897 23902 23902 23906 23907 23909 23909 23911 23913 23915 23916 23919 23919 23921 23922 23927 23927 23929 23930 23932 23938 23940 23940 23942 23946 23949 23949 23954 23957 23959 23959 23961 23962 23964 23970 23975 23978 23980 23986 23988 23989 23991 23992 23994 23994 23996 23997 24000 24000 24002 24003 24006 24007 24009 24009 24011 24011 24013 24013 24015 24015 24017 24018 24020 24022 24024 24024 24029 24034 24037 24040 24043 24043 24046 24046 24048 24052 24055 24055 24057 24057 24061 24063 24066 24068 24070 24070 24074 24074 24076 24076 24078 24078 24081 24081 24084 24091 24093 24093 24095 24101 24104 24105 24107 24107 24109 24109 24115 24116 24118 24120 24125 24126 24128 24129 24131 24133 24138 24143 24147 24149 24151 24153 24155 24157 24159 24163 24166 24176 24178 24182 24184 24185 24187 24190 24192 24192 24194 24194 24196 24196 24199 24205 24207 24207 24213 24215 24218 24220 24224 24224 24226 24232 24234 24238 24240 24249 24254 24254 24257 24258 24260 24268 24270 24270 24273 24291 24293 24297 24300 24300 24302 24303 24305 24307 24310 24311 24314 24314 24318 24319 24321 24322 24324 24325 24327 24328 24330 24331 24335 24335 24338 24341 24343 24344 24346 24347 24349 24349 24351 24351 24354 24356 24358 24361 24365 24366 24368 24369 24371 24371 24373 24376 24380 24380 24384 24384 24387 24388 24390 24390 24392 24396 24398 24399 24404 24404 24406 24409 24413 24413 24418 24418 24420 24421 24423 24423 24425 24429 24431 24433 24435 24436 24438 24441 24444 24450 24453 24460 24464 24466 24470 24473 24475 24476 24478 24481 24485 24486 24488 24495 24498 24498 24501 24503 24505 24505 24507 24513 24515 24515 24517 24517 24521 24521 24524 24525 24527 24530 24532 24537 24541 24542 24544 24545 24547 24549 24552 24552 24554 24555 24557 24559 24561 24561 24563 24565 24567 24568 24570 24571 24573 24573 24575 24576 24585 24599 24601 24606 24608 24610 24612 24623 24626 24629 24631 24631 24633 24633 24640 24647 24649 24649 24652 24653 24656 24656 24658 24661 24664 24667 24669 24671 24674 24688 24690 24690 24703 24705 24707 24714 24716 24718 24720 24720 24722 24722 24724 24727 24730 24733 24735 24736 24738 24739 24744 24744 24752 24754 24756 24769 24771 24783 24785 24785 24787 24789 24792 24797 24799 24802 24804 24804 24806 24806 24816 24828 24830 24833 24835 24838 24840 24843 24845 24848 24850 24854 24856 24856 24858 24861 24863 24863 24867 24867 24871 24873 24875 24876 24878 24879 24882 24882 24884 24884 24886 24887 24891 24891 24894 24897 24900 24911 24914 24918 24920 24920 24922 24923 24925 24927 24929 24931 24933 24936 24938 24940 24942 24942 24944 24951 24953 24954 24956 24956 24958 24958 24960 24960 24962 24963 24969 24974 24976 24980 24982 24982 24986 24987 24989 24989 24991 24991 24993 24994 24996 24996 24999 25014 25016 25016 25018 25018 25020 25020 25022 25023 25025 25027 25029 25037 25046 25046 25048 25048 25054 25056 25059 25067 25069 25070 25072 25074 25077 25089 25091 25092 25095 25098 25100 25102 25104 25106 25108 25110 25113 25115 25119 25125 25127 25127 25129 25131 25133 25134 25136 25136 25138 25140 25142 25142 25146 25146 25149 25155 25158 25163 25165 25166 25168 25172 25176 25180 25182 25182 25184 25190 25197 25204 25206 25207 25209 25217 25219 25220 25222 25226 25228 25228 25230 25231 25233 25240 25256 25265 25267 25270 25272 25273 25275 25279 25282 25282 25284 25284 25286 25300 25302 25308 25323 25347 25351 25353 25355 25361 25363 25366 25384 25389 25391 25391 25394 25396 25398 25398 25400 25406 25408 25425 25428 25434 25445 25445 25447 25449 25451 25451 25453 25458 25461 25464 25466 25469 25472 25477 25479 25482 25484 25490 25492 25492 25494 25497 25499 25509 25511 25521 25533 25534 25536 25536 25538 25552 25554 25555 25557 25565 25567 25569 25571 25573 25575 25579 25581 25590 25593 25593 25606 25606 25609 25616 25618 25624 25626 25628 25630 25640 25642 25648 25651 25655 25657 25657 25661 25665 25667 25667 25675 25675 25677 25678 25680 25684 25688 25689 25691 25697 25701 25705 25707 25712 25714 25723 25725 25725 25727 25727 25730 25730 25733 25733 25735 25740 25743 25744 25746 25747 25749 25754 25756 25760 25762 25766 25769 25769 25771 25774 25776 25779 25787 25791 25793 25797 25799 25799 25801 25803 25805 25808 25810 25810 25812 25812 25814 25819 25824 25824 25826 25828 25830 25830 25832 25833 25835 25837 25839 25844 25847 25848 25850 25857 25859 25860 25862 25863 25865 25865 25868 25872 25875 25881 25883 25885 25888 25894 25897 25903 25906 25907 25910 25913 25915 25915 25917 25919 25921 25921 25923 25923 25925 25926 25928 25930 25935 25935 25937 25937 25939 25945 25948 25950 25954 25960 25962 25962 25964 25964 25967 25967 25970 25980 25983 25988 25991 25991 25996 25996 26000 26002 26004 26007 26009 26009 26011 26018 26020 26021 26023 26024 26026 26028 26030 26032 26034 26035 26038 26041 26043 26045 26047 26047 26049 26054 26059 26064 26066 26067 26070 26071 26074 26075 26077 26079 26081 26082 26085 26086 26088 26089 26092 26101 26106 26109 26112 26112 26114 26133 26140 26141 26143 26146 26148 26152 26155 26155 26157 26159 26161 26166 26169 26170 26177 26179 26181 26181 26183 26183 26185 26186 26188 26188 26191 26191 26193 26194 26201 26207 26209 26210 26212 26214 26216 26216 26218 26218 26220 26220 26222 26226 26228 26228 26230 26236 26238 26238 26240 26240 26244 26244 26246 26253 26256 26257 26260 26265 26269 26269 26271 26274 26280 26283 26286 26290 26292 26293 26295 26299 26301 26302 26304 26304 26308 26308 26310 26316 26319 26319 26322 26322 26326 26326 26328 26334 26336 26336 26339 26340 26342 26342 26344 26345 26347 26350 26352 26352 26354 26356 26358 26361 26364 26364 26366 26369 26371 26373 26376 26379 26381 26381 26383 26384 26386 26389 26391 26392 26395 26395 26397 26397 26399 26403 26406 26408 26410 26414 26417 26417 26419 26421 26424 26431 26437 26441 26443 26449 26451 26451 26453 26455 26457 26458 26460 26464 26474 26474 26476 26477 26479 26495 26497 26497 26499 26503 26505 26505 26507 26510 26512 26517 26519 26522 26524 26525 26527 26527 26542 26544 26546 26555 26560 26566 26568 26580 26584 26591 26594 26599 26601 26616 26618 26618 26620 26620 26623 26623 26642 26644 26646 26648 26650 26650 26652 26653 26655 26657 26661 26662 26664 26667 26669 26671 26673 26677 26680 26685 26688 26694 26696 26697 26699 26705 26707 26708 26731 26731 26733 26735 26737 26738 26740 26745 26747 26755 26757 26759 26761 26764 26767 26772 26774 26775 26779 26781 26783 26788 26791 26805 26820 26820 26822 26825 26827 26830 26832 26840 26842 26842 26844 26849 26851 26852 26854 26860 26862 26877 26884 26888 26890 26901 26903 26903 26917 26917 26922 26922 26927 26928 26930 26933 26935 26937 26939 26941 26943 26946 26948 26949 26952 26956 26958 26959 26961 26964 26966 26976 26978 26979 26981 26982 26984 26993 26996 27003 27010 27011 27014 27014 27021 27022 27024 27025 27027 27031 27033 27036 27038 27038 27040 27041 27043 27057 27059 27063 27065 27065 27067 27071 27073 27076 27078 27078 27081 27088 27091 27092 27097 27097 27106 27106 27108 27112 27115 27118 27121 27124 27126 27128 27131 27138 27140 27146 27149 27149 27151 27151 27153 27153 27155 27161 27163 27163 27165 27169 27171 27171 27173 27176 27186 27186 27188 27189 27192 27201 27204 27204 27206 27209 27211 27211 27213 27217 27220 27222 27224 27227 27229 27234 27236 27236 27238 27243 27245 27245 27247 27247 27254 27254 27262 27265 27267 27269 27271 27271 27273 27273 27276 27278 27280 27287 27290 27292 27294 27302 27304 27304 27308 27311 27315 27316 27318 27323 27325 27325 27330 27331 27333 27335 27339 27341 27343 27345 27347 27347 27353 27361 27365 27365 27367 27368 27370 27372 27374 27377 27379 27379 27384 27388 27392 27392 27394 27396 27400 27403 27407 27411 27414 27418 27422 27422 27424 27425 27427 27427 27429 27429 27432 27432 27436 27437 27439 27439 27441 27444 27446 27455 27457 27459 27461 27470 27472 27473 27476 27478 27481 27481 27483 27484 27486 27495 27498 27498 27501 27501 27506 27506 27510 27513 27515 27515 27518 27520 27522 27524 27526 27526 27528 27530 27532 27535 27537 27537 27540 27545 27547 27547 27550 27552 27554 27559 27562 27563 27565 27568 27570 27571 27573 27575 27578 27578 27580 27581 27583 27584 27587 27597 27599 27600 27602 27604 27606 27608 27610 27611 27614 27614 27616 27616 27618 27620 27622 27624 27627 27628 27631 27632 27634 27635 27639 27641 27643 27654 27656 27657 27659 27661 27663 27665 27667 27670 27672 27675 27677 27677 27679 27681 27683 27688 27690 27692 27694 27696 27699 27700 27702 27702 27704 27704 27707 27707 27710 27715 27718 27718 27722 27728 27730 27730 27732 27733 27735 27735 27737 27737 27739 27745 27749 27755 27757 27757 27759 27764 27766 27766 27768 27768 27770 27771 27773 27774 27776 27792 27794 27798 27800 27805 27819 27822 27824 27825 27827 27828 27830 27847 27849 27850 27852 27853 27855 27863 27865 27870 27872 27875 27877 27877 27879 27881 27883 27891 27893 27893 27897 27897 27904 27905 27907 27908 27911 27922 27926 27931 27933 27936 27938 27938 27941 27941 27943 27970 27992 27994 27998 28010 28012 28016 28020 28032 28034 28046 28048 28053 28055 28056 28074 28076 28078 28079 28082 28085 28087 28088 28090 28096 28098 28098 28100 28109 28111 28134 28136 28151 28153 28157 28160 28160 28163 28163 28165 28165 28185 28189 28191 28200 28203 28214 28216 28225 28227 28231 28233 28235 28237 28238 28241 28246 28248 28248 28250 28265 28267 28267 28270 28271 28273 28276 28279 28281 28296 28297 28301 28304 28306 28308 28310 28313 28315 28327 28330 28331 28334 28340 28342 28343 28345 28346 28348 28374 28376 28376 28380 28380 28395 28399 28401 28402 28404 28409 28411 28419 28421 28426 28429 28431 28434 28437 28440 28442 28444 28444 28446 28451 28453 28455 28457 28467 28469 28476 28478 28481 28483 28483 28494 28501 28503 28504 28506 28507 28509 28516 28518 28519 28521 28528 28530 28531 28534 28536 28538 28544 28546 28546 28548 28553 28555 28558 28560 28560 28562 28567 28574 28574 28576 28596 28598 28598 28600 28602 28604 28605 28607 28612 28614 28623 28628 28629 28632 28632 28635 28644 28646 28649 28651 28658 28660 28660 28663 28663 28666 28668 28670 28673 28676 28679 28681 28687 28689 28689 28692 28701 28703 28708 28710 28715 28719 28725 28727 28732 28734 28742 28744 28746 28748 28748 28753 28754 28757 28760 28762 28763 28765 28774 28776 28779 28784 28785 28788 28788 28790 28790 28792 28792 28794 28794 28796 28797 28802 28806 28810 28810 28814 28814 28817 28822 28824 28826 28831 28831 28833 28833 28836 28836 28841 28841 28843 28849 28851 28853 28855 28856 28858 28858 28862 28862 28869 28872 28874 28875 28877 28879 28881 28884 28887 28890 28892 28894 28896 28898 28900 28900 28911 28912 28915 28916 28918 28925 28927 28928 28930 28930 28932 28932 28934 28934 28937 28942 28944 28944 28947 28947 28951 28951 28953 28956 28958 28963 28965 28966 28968 28968 28974 28978 28982 28982 28986 28986 28993 28996 28998 28999 29001 29001 29003 29006 29008 29008 29010 29012 29014 29014 29016 29018 29020 29034 29036 29036 29038 29038 29040 29040 29042 29042 29048 29048 29051 29051 29053 29053 29056 29058 29060 29063 29065 29066 29071 29072 29074 29074 29076 29076 29079 29079 29081 29089 29092 29093 29095 29098 29100 29100 29103 29107 29109 29109 29112 29113 29116 29131 29134 29136 29138 29138 29140 29142 29144 29148 29151 29154 29156 29160 29164 29166 29168 29170 29172 29172 29176 29177 29179 29183 29185 29187 29189 29191 29194 29194 29196 29197 29200 29200 29203 29204 29209 29211 29213 29215 29218 29219 29222 29226 29228 29229 29232 29232 29237 29238 29240 29243 29245 29247 29249 29250 29252 29252 29254 29260 29263 29263 29266 29267 29270 29270 29272 29275 29277 29283 29287 29287 29289 29290 29292 29292 29294 29296 29298 29300 29302 29305 29307 29313 29316 29318 29320 29321 29323 29326 29328 29331 29333 29336 29338 29339 29341 29342 29345 29354 29356 29356 29358 29360 29364 29365 29370 29370 29373 29373 29375 29382 29385 29388 29390 29390 29392 29394 29396 29396 29398 29402 29404 29404 29407 29409 29411 29412 29414 29414 29416 29419 29427 29428 29430 29441 29447 29448 29450 29452 29455 29455 29457 29459 29462 29465 29467 29470 29474 29475 29477 29479 29481 29481 29485 29485 29488 29495 29498 29500 29502 29504 29506 29509 29513 29514 29516 29518 29520 29522 29527 29531 29533 29538 29541 29548 29550 29552 29554 29555 29557 29560 29562 29579 29582 29582 29586 29591 29597 29597 29599 29602 29604 29606 29608 29609 29611 29613 29618 29625 29627 29628 29630 29632 29634 29635 29637 29640 29642 29645 29650 29652 29654 29662 29664 29664 29667 29667 29669 29669 29671 29675 29677 29678 29684 29686 29688 29688 29690 29690 29692 29697 29699 29709 29718 29718 29722 29723 29725 29725 29728 29734 29736 29750 29754 29754 29759 29762 29764 29764 29766 29766 29770 29771 29773 29778 29780 29781 29783 29783 29785 29788 29790 29791 29794 29796 29799 29799 29801 29802 29805 29811 29813 29813 29817 29817 29820 29825 29827 29827 29829 29835 29840 29840 29842 29842 29844 29845 29847 29848 29850 29850 29852 29852 29854 29857 29859 29859 29861 29867 29869 29869 29871 29874 29877 29880 29882 29883 29885 29891 29893 29893 29898 29899 29903 29903 29908 29926 29928 29929 29932 29932 29934 29934 29940 29943 29947 29947 29949 29952 29954 29956 29959 29960 29963 29965 29967 29976 29978 29978 29980 29981 29983 29983 29985 29986 29989 29990 29992 30003 30007 30010 30013 30016 30023 30024 30027 30028 30030 30031 30036 30036 30041 30045 30047 30047 30050 30054 30058 30060 30063 30064 30070 30073 30077 30080 30084 30084 30086 30087 30090 30092 30095 30097 30100 30101 30104 30106 30109 30109 30114 30117 30119 30119 30122 30123 30128 30128 30130 30131 30133 30134 30136 30146 30148 30149 30151 30151 30154 30162 30164 30165 30167 30171 30173 30180 30182 30183 30189 30189 30191 30209 30211 30211 30216 30221 30223 30225 30227 30230 30233 30249 30253 30253 30255 30261 30264 30264 30266 30266 30268 30269 30274 30275 30278 30281 30284 30284 30288 30288 30290 30291 30294 30298 30300 30300 30303 30306 30308 30309 30313 30314 30316 30318 30320 30322 30325 30325 30328 30329 30331 30335 30337 30338 30340 30340 30342 30347 30350 30351 30354 30355 30357 30358 30361 30366 30372 30372 30374 30374 30378 30379 30381 30384 30388 30389 30392 30392 30394 30395 30397 30399 30402 30406 30408 30410 30413 30414 30418 30420 30426 30431 30433 30433 30435 30439 30441 30442 30444 30453 30455 30460 30462 30462 30465 30465 30467 30469 30471 30475 30480 30483 30485 30485 30489 30491 30493 30493 30495 30496 30498 30499 30501 30501 30503 30505 30509 30509 30511 30511 30513 30526 30532 30535 30538 30543 30546 30546 30548 30550 30553 30556 30558 30563 30565 30575 30585 30585 30588 30597 30599 30601 30603 30607 30609 30609 30613 30613 30615 30615 30617 30627 30629 30629 30631 30632 30634 30637 30640 30647 30650 30653 30655 30655 30658 30658 30660 30660 30663 30663 30665 30666 30668 30672 30675 30677 30679 30684 30686 30686 30688 30688 30690 30691 30693 30693 30695 30697 30700 30707 30711 30717 30722 30723 30725 30726 30729 30729 30732 30740 30749 30749 30751 30755 30757 30773 30775 30776 30787 30787 30789 30789 30792 30794 30796 30798 30800 30800 30802 30802 30812 30814 30816 30816 30818 30818 30820 30821 30824 30833 30841 30841 30843 30844 30846 30849 30851 30855 30857 30857 30860 30860 30862 30863 30865 30865 30867 30874 30878 30885 30887 30893 30896 30896 30898 30900 30906 30908 30910 30910 30913 30913 30915 30917 30920 30929 30932 30933 30938 30939 30941 30947 30949 30949 30951 30954 30956 30957 30959 30959 30962 30964 30967 30967 30969 30975 30977 30978 30980 30981 30985 30985 30988 30988 30990 30990 30992 30996 30999 30999 31001 31001 31003 31006 31009 31009 31011 31021 31023 31023 31025 31025 31029 31029 31032 31034 31037 31042 31044 31052 31055 31063 31066 31073 31075 31077 31079 31083 31085 31085 31088 31088 31090 31092 31097 31098 31100 31101 31103 31103 31105 31106 31112 31112 31114 31115 31117 31120 31122 31128 31130 31132 31136 31138 31140 31140 31142 31144 31146 31150 31152 31156 31158 31163 31165 31169 31173 31173 31176 31177 31179 31179 31181 31183 31185 31186 31189 31190 31192 31192 31196 31200 31203 31204 31206 31207 31209 31214 31222 31224 31226 31227 31232 31232 31234 31237 31240 31240 31242 31245 31248 31253 31255 31260 31262 31264 31266 31266 31270 31270 31272 31272 31275 31275 31278 31281 31287 31287 31289 31289 31291 31293 31295 31296 31300 31300 31302 31304 31306 31310 31316 31316 31318 31320 31322 31324 31327 31330 31335 31337 31339 31342 31344 31345 31348 31350 31352 31355 31358 31361 31364 31372 31375 31376 31378 31378 31380 31385 31390 31392 31394 31395 31400 31404 31406 31407 31409 31416 31418 31418 31422 31425 31428 31429 31431 31431 31434 31435 31441 31441 31448 31449 31455 31456 31459 31462 31467 31467 31469 31471 31478 31479 31481 31483 31485 31485 31487 31489 31492 31494 31496 31498 31502 31507 31512 31515 31517 31518 31520 31520 31522 31526 31528 31528 31530 31541 31544 31544 31547 31547 31552 31552 31556 31570 31572 31572 31574 31574 31576 31576 31584 31585 31587 31591 31593 31593 31597 31598 31600 31608 31618 31618 31620 31621 31623 31624 31626 31633 31636 31641 31643 31645 31648 31649 31652 31652 31660 31661 31663 31663 31665 31665 31668 31669 31671 31673 31678 31678 31680 31681 31684 31684 31686 31687 31689 31692 31694 31694 31700 31701 31704 31723 31728 31732 31735 31737 31739 31739 31741 31747 31749 31751 31753 31761 31769 31769 31772 31779 31781 31789 31792 31792 31795 31795 31799 31801 31803 31808 31811 31811 31813 31813 31815 31818 31820 31821 31824 31824 31827 31828 31831 31831 31833 31836 31839 31840 31843 31847 31849 31852 31854 31855 31858 31859 31861 31861 31864 31866 31869 31869 31871 31873 31876 31877 31880 31882 31884 31885 31889 31890 31892 31896 31902 31903 31905 31907 31909 31909 31911 31912 31919 31919 31921 31925 31929 31935 31941 31941 31944 31944 31946 31948 31950 31950 31952 31954 31956 31959 31961 31961 31964 31968 31970 31970 31975 31976 31978 31978 31980 31980 31982 31986 31988 31988 31990 31992 31995 31995 31997 31998 32000 32034 32040 32041 32043 32044 32046 32051 32053 32054 32056 32071 32074 32074 32078 32086 32088 32088 32091 32092 32094 32095 32097 32099 32102 32107 32109 32115 32121 32125 32127 32129 32131 32134 32136 32136 32140 32143 32145 32148 32150 32150 32156 32163 32166 32167 32169 32170 32172 32178 32180 32181 32183 32194 32196 32199 32201 32204 32206 32206 32210 32210 32215 32219 32221 32225 32227 32227 32230 32234 32236 32236 32238 32244 32246 32247 32249 32251 32259 32259 32264 32279 32282 32293 32297 32299 32301 32329 32332 32332 32336 32346 32348 32348 32350 32355 32360 32363 32365 32365 32367 32368 32370 32382 32384 32386 32390 32392 32394 32397 32399 32399 32401 32401 32403 32412 32566 32566 32568 32570 32573 32575 32579 32581 32584 32584 32586 32589 32591 32593 32596 32597 32600 32600 32603 32609 32611 32611 32613 32622 32624 32624 32626 32627 32629 32631 32633 32639 32643 32643 32645 32654 32657 32658 32660 32662 32666 32670 32672 32674 32676 32681 32684 32685 32687 32691 32693 32707 32709 32709 32711 32711 32713 32722 32724 32725 32727 32727 32731 32732 32734 32739 32741 32742 32744 32757 32759 32761 32763 32769 32771 32775 32779 32786 32788 32793 32795 32796 32798 32799 32801 32801 32804 32804 32806 32806 32808 32810 32812 32812 32816 32816 32819 32823 32825 32825 32829 32831 32835 32835 32838 32840 32842 32842 32847 32850 32854 32854 32856 32856 32858 32858 32860 32862 32868 32868 32871 32871 32876 32876 32879 32883 32885 32889 32893 32895 32898 32898 32900 32903 32905 32908 32911 32912 32914 32915 32917 32918 32920 32925 32929 32931 32933 32933 32937 32939 32941 32943 32945 32946 32948 32949 32952 32952 32954 32954 32962 32965 32967 32970 32972 32977 32980 32990 32992 32993 32995 32998 33005 33005 33007 33013 33016 33022 33024 33026 33029 33030 33032 33032 33034 33034 33045 33046 33048 33049 33051 33051 33053 33055 33057 33061 33063 33063 33065 33065 33067 33069 33071 33072 33081 33082 33085 33086 33091 33092 33094 33095 33098 33109 33115 33116 33118 33118 33120 33122 33124 33127 33129 33129 33131 33131 33134 33140 33142 33146 33151 33152 33154 33155 33158 33165 33167 33167 33173 33173 33175 33184 33186 33187 33190 33193 33195 33196 33198 33198 33200 33205 33207 33207 33209 33216 33218 33223 33225 33226 33228 33229 33231 33234 33237 33237 33239 33243 33245 33251 33253 33258 33260 33262 33266 33268 33271 33276 33278 33282 33284 33285 33287 33293 33296 33298 33300 33302 33307 33314 33317 33317 33320 33320 33322 33324 33327 33327 33330 33338 33340 33341 33343 33344 33346 33346 33348 33349 33351 33351 33353 33353 33355 33355 33358 33363 33365 33372 33374 33375 33377 33377 33379 33380 33382 33382 33384 33385 33387 33391 33393 33394 33396 33397 33399 33400 33404 33408 33411 33413 33418 33419 33421 33428 33432 33435 33437 33445 33447 33449 33451 33457 33459 33470 33472 33472 33474 33475 33489 33495 33497 33497 33499 33500 33502 33505 33507 33512 33514 33517 33519 33526 33529 33531 33534 33534 33536 33545 33548 33549 33558 33559 33561 33561 33563 33564 33566 33566 33568 33568 33570 33570 33572 33581 33583 33583 33585 33596 33599 33605 33607 33620 33622 33622 33651 33656 33658 33663 33665 33665 33667 33667 33670 33680 33682 33691 33693 33694 33696 33696 33698 33707 33710 33712 33725 33725 33727 33740 33742 33743 33745 33745 33748 33753 33755 33765 33767 33772 33774 33782 33784 33791 33793 33793 33795 33796 33798 33799 33801 33811 33819 33819 33827 33827 33833 33833 33835 33837 33839 33853 33855 33856 33858 33863 33865 33865 33867 33870 33872 33874 33876 33876 33878 33879 33881 33883 33885 33889 33891 33891 33893 33897 33899 33904 33907 33914 33917 33918 33922 33922 33926 33926 33933 33937 33940 33940 33943 33954 33956 33956 33959 33964 33966 33970 33972 33972 33974 33974 33976 33980 33983 33986 33988 33991 33993 34004 34006 34007 34011 34011 34023 34028 34030 34036 34038 34039 34041 34048 34050 34050 34054 34063 34065 34074 34076 34081 34083 34097 34107 34107 34109 34110 34112 34113 34115 34122 34125 34126 34129 34129 34131 34137 34139 34139 34141 34142 34144 34158 34161 34161 34165 34172 34174 34174 34176 34193 34196 34198 34200 34212 34214 34218 34223 34225 34227 34234 34237 34240 34242 34249 34251 34251 34253 34258 34261 34261 34263 34266 34268 34271 34273 34278 34280 34285 34287 34290 34294 34299 34301 34305 34308 34311 34313 34316 34321 34321 34327 34332 34334 34343 34345 34346 34348 34350 34353 34358 34360 34364 34366 34368 34371 34371 34374 34376 34379 34382 34384 34384 34386 34390 34393 34393 34395 34396 34398 34399 34401 34405 34407 34411 34413 34417 34419 34420 34423 34423 34425 34428 34437 34439 34442 34446 34448 34449 34451 34458 34460 34462 34465 34469 34471 34474 34479 34481 34483 34505 34507 34508 34512 34513 34515 34516 34518 34527 34530 34532 34534 34534 34536 34541 34549 34555 34558 34558 34560 34574 34577 34579 34584 34588 34590 34590 34592 34602 34604 34606 34608 34613 34615 34616 34618 34620 34622 34627 34630 34630 34636 34671 34675 34683 34689 34693 34695 34697 34701 34701 34703 34708 34710 34712 34714 34719 34722 34724 34730 34736 34738 34752 34754 34758 34760 34764 34769 34772 34775 34777 34779 34792 34794 34797 34799 34799 34802 34804 34806 34807 34809 34812 34814 34819 34821 34822 34824 34829 34832 34833 34835 34839 34841 34841 34843 34845 34847 34854 34856 34860 34862 34867 34869 34873 34875 34881 34883 34884 34888 34888 34890 34894 34898 34899 34901 34903 34905 34907 34909 34909 34913 34915 34919 34923 34925 34925 34927 34930 34932 34935 34937 34937 34940 34947 34952 34953 34955 34958 34961 34963 34965 34971 34974 34975 34977 34978 34980 34980 34983 34984 34986 34988 34993 34994 34998 35002 35004 35006 35008 35010 35017 35024 35026 35026 35028 35039 35041 35041 35047 35048 35051 35052 35054 35060 35062 35070 35073 35074 35077 35079 35081 35084 35086 35086 35088 35098 35102 35103 35105 35107 35109 35111 35113 35123 35125 35128 35131 35134 35137 35138 35140 35140 35142 35142 35145 35145 35147 35148 35151 35155 35158 35172 35174 35174 35177 35183 35185 35188 35190 35190 35193 35196 35198 35199 35201 35203 35205 35206 35208 35208 35211 35211 35215 35215 35219 35219 35221 35224 35227 35231 35233 35236 35238 35238 35242 35242 35244 35247 35250 35250 35254 35255 35257 35258 35261 35264 35282 35286 35289 35293 35295 35302 35304 35305 35307 35309 35312 35316 35318 35320 35322 35324 35326 35328 35330 35332 35335 35336 35338 35338 35340 35340 35342 35347 35349 35352 35355 35355 35357 35359 35362 35363 35365 35365 35367 35367 35370 35370 35372 35373 35376 35377 35380 35380 35382 35382 35385 35388 35390 35393 35396 35398 35400 35400 35402 35402 35404 35410 35412 35417 35419 35419 35422 35422 35424 35427 35430 35430 35432 35433 35435 35438 35440 35447 35449 35452 35455 35455 35457 35463 35467 35469 35471 35471 35473 35475 35477 35478 35480 35482 35486 35486 35488 35489 35491 35496 35498 35499 35504 35504 35506 35506 35510 35510 35512 35520 35522 35529 35531 35531 35533 35533 35535 35535 35537 35545 35547 35554 35556 35556 35558 35560 35563 35563 35565 35576 35578 35580 35582 35586 35588 35592 35594 35595 35597 35614 35616 35616 35618 35624 35626 35628 35630 35633 35635 35635 35637 35639 35641 35646 35648 35650 35653 35659 35662 35674 35676 35677 35679 35680 35683 35683 35685 35688 35690 35693 35695 35696 35700 35700 35703 35707 35709 35712 35714 35714 35716 35718 35720 35720 35722 35724 35726 35726 35730 35734 35736 35738 35740 35740 35742 35743 35895 35895 35897 35897 35899 35903 35905 35907 35909 35920 35924 35927 35930 35930 35932 35933 35935 35935 35937 35938 35940 35942 35944 35949 35951 35955 35957 35963 35965 35965 35968 35970 35972 35974 35977 35978 35980 35981 35983 35989 35991 35994 35996 35998 36000 36005 36007 36012 36015 36016 36018 36037 36039 36040 36042 36042 36044 36044 36047 36047 36049 36051 36053 36053 36055 36055 36057 36058 36060 36072 36074 36074 36076 36078 36080 36081 36083 36085 36088 36094 36096 36096 36098 36098 36100 36106 36109 36109 36111 36112 36115 36119 36121 36121 36123 36123 36196 36196 36198 36201 36203 36208 36210 36212 36214 36217 36219 36219 36221 36221 36224 36225 36228 36229 36233 36234 36236 36246 36249 36249 36251 36252 36255 36257 36259 36259 36261 36261 36263 36264 36266 36271 36274 36279 36281 36282 36284 36284 36286 36287 36289 36290 36293 36296 36299 36305 36307 36307 36309 36317 36319 36324 36326 36332 36334 36340 36346 36346 36348 36352 36354 36359 36361 36362 36365 36365 36367 36391 36393 36393 36395 36395 36398 36398 36400 36401 36403 36406 36408 36409 36412 36418 36420 36421 36423 36430 36432 36432 36435 36439 36441 36455 36457 36458 36460 36461 36463 36463 36466 36468 36470 36470 36472 36472 36474 36476 36481 36482 36484 36494 36496 36504 36506 36506 36509 36513 36515 36518 36520 36524 36530 36530 36538 36538 36541 36541 36544 36544 36546 36546 36553 36557 36559 36559 36561 36564 36567 36568 36571 36577 36581 36585 36587 36588 36590 36591 36593 36593 36596 36604 36606 36611 36613 36619 36621 36622 36624 36632 36634 36640 36643 36646 36649 36650 36652 36652 36654 36655 36658 36665 36667 36667 36670 36672 36674 36681 36683 36683 36685 36699 36701 36708 36763 36764 36767 36767 36771 36771 36774 36774 36776 36776 36781 36786 36788 36788 36799 36799 36802 36802 36804 36806 36809 36809 36811 36811 36813 36814 36817 36823 36832 36838 36840 36840 36842 36843 36845 36846 36848 36848 36852 36856 36858 36870 36875 36877 36879 36881 36884 36887 36889 36900 36909 36911 36913 36914 36916 36918 36920 36920 36924 36927 36929 36930 36932 36932 36935 36935 36937 36939 36941 36949 36952 36953 36955 36958 36960 36960 36962 36963 36967 36969 36971 36971 36973 36976 36978 37000 37002 37003 37005 37005 37007 37009 37012 37013 37015 37017 37019 37019 37022 37027 37029 37031 37034 37034 37039 37046 37048 37048 37053 37055 37057 37057 37059 37059 37061 37061 37063 37064 37066 37067 37070 37070 37076 37085 37087 37093 37096 37101 37103 37109 37113 37129 37131 37131 37133 37138 37140 37140 37142 37156 37158 37174 37176 37179 37182 37185 37187 37200 37202 37203 37205 37208 37210 37210 37215 37221 37224 37226 37228 37228 37230 37231 37234 37237 37239 37242 37248 37255 37257 37259 37261 37261 37263 37267 37273 37283 37285 37285 37287 37288 37290 37301 37303 37303 37305 37306 37308 37310 37312 37315 37317 37319 37321 37321 37323 37329 37331 37333 37335 37338 37340 37341 37346 37348 37350 37358 37361 37361 37363 37365 37367 37369 37373 37373 37375 37383 37385 37386 37388 37389 37391 37394 37396 37399 37401 37402 37404 37404 37406 37406 37411 37415 37421 37422 37424 37428 37430 37434 37437 37440 37445 37446 37448 37460 37462 37463 37466 37467 37470 37470 37472 37473 37475 37479 37484 37485 37487 37488 37490 37490 37494 37494 37496 37504 37506 37507 37509 37512 37514 37518 37521 37521 37523 37533 37536 37548 37554 37559 37561 37561 37563 37564 37568 37587 37589 37589 37591 37593 37597 37601 37604 37604 37606 37610 37614 37617 37623 37628 37630 37634 37636 37636 37638 37638 37640 37641 37643 37648 37650 37654 37656 37659 37661 37675 37677 37679 37683 37686 37688 37689 37692 37692 37702 37703 37705 37714 37716 37724 37726 37726 37728 37729 37731 37733 37735 37735 37738 37738 37740 37741 37744 37745 37749 37751 37753 37756 37758 37758 37760 37760 37762 37763 37768 37770 37772 37775 37777 37778 37780 37787 37789 37791 37793 37802 37804 37804 37806 37813 37815 37815 37824 37824 37826 37828 37831 37832 37834 37834 37836 37842 37844 37850 37852 37855 37857 37860 37862 37864 37868 37868 37870 37870 37877 37888 37891 37891 37894 37895 37897 37910 37912 37913 37920 37920 37928 37932 37934 37934 37936 37939 37941 37949 37951 37952 37956 37964 37967 37970 37973 37973 37975 37975 37981 37982 37984 37984 37986 37988 37992 37995 37997 38008 38012 38019 38263 38263 38266 38269 38272 38272 38274 38275 38278 38278 38280 38281 38283 38292 38296 38296 38299 38300 38302 38303 38305 38305 38307 38309 38312 38313 38315 38318 38320 38321 38325 38327 38329 38336 38339 38339 38341 38349 38352 38358 38362 38364 38366 38373 38428 38428 38430 38430 38432 38436 38440 38440 38442 38442 38444 38450 38457 38461 38463 38464 38466 38468 38474 38481 38483 38484 38488 38488 38491 38495 38497 38500 38506 38509 38511 38520 38524 38526 38528 38528 38531 38539 38541 38542 38545 38549 38551 38553 38555 38556 38558 38558 38561 38562 38564 38564 38567 38570 38572 38572 38574 38574 38576 38577 38579 38580 38584 38585 38587 38588 38591 38606 38610 38623 38625 38627 38629 38629 38632 38634 38639 38642 38645 38651 38653 38653 38655 38656 38658 38658 38660 38665 38667 38667 38669 38675 38678 38678 38680 38681 38684 38688 38690 38700 38702 38704 38706 38706 38709 38709 38712 38714 38717 38719 38722 38724 38726 38729 38731 38731 38738 38738 38742 38742 38744 38744 38746 38748 38750 38750 38752 38754 38758 38758 38760 38762 38764 38764 38766 38766 38768 38768 38770 38772 38774 38776 38778 38789 38792 38792 38794 38795 38797 38799 38804 38804 38807 38810 38812 38814 38816 38822 38824 38824 38826 38830 38835 38835 38838 38839 38841 38841 38843 38843 38847 38847 38849 38849 38851 38855 38857 38857 38859 38864 38867 38873 38876 38879 38881 38881 38883 38883 38885 38885 38893 38893 38896 38897 38899 38899 38902 38902 38904 38907 38909 38920 38922 38922 38924 38931 38934 38936 38939 38942 38944 38945 38948 38948 38950 38953 38955 38955 38957 38957 38959 38960 38962 38962 38965 38965 38967 38969 38971 38971 38977 38977 38979 38982 38984 38986 38988 38995 38999 39001 39003 39008 39010 39013 39015 39015 39017 39019 39023 39028 39080 39081 39084 39087 39089 39091 39094 39094 39096 39096 39098 39106 39108 39108 39110 39110 39113 39113 39115 39116 39131 39131 39135 39135 39138 39139 39141 39141 39143 39143 39145 39147 39149 39149 39151 39151 39154 39154 39156 39156 39158 39158 39161 39162 39164 39166 39168 39168 39170 39171 39173 39173 39175 39178 39180 39180 39184 39192 39194 39195 39198 39199 39201 39201 39204 39205 39207 39219 39221 39221 39226 39226 39228 39231 39233 39233 39235 39235 39237 39237 39239 39241 39243 39244 39246 39246 39248 39257 39259 39260 39262 39263 39265 39265 39318 39321 39324 39326 39329 39329 39331 39331 39333 39336 39339 39349 39353 39355 39357 39357 39361 39363 39367 39367 39369 39369 39371 39385 39387 39389 39391 39391 39394 39397 39399 39399 39401 39402 39404 39406 39408 39409 39412 39412 39414 39423 39425 39431 39433 39435 39437 39439 39441 39441 39444 39446 39449 39454 39456 39456 39458 39461 39463 39463 39465 39470 39472 39474 39476 39482 39485 39494 39496 39498 39500 39504 39506 39511 39513 39515 39518 39520 39522 39522 39524 39531 39592 39592 39595 39595 39597 39597 39599 39601 39603 39604 39607 39609 39611 39612 39614 39618 39622 39623 39626 39626 39629 39629 39631 39638 39640 39640 39644 39644 39647 39647 39649 39649 39651 39651 39654 39655 39659 39663 39665 39667 39670 39671 39673 39678 39681 39681 39683 39686 39688 39688 39690 39694 39696 39698 39701 39706 39710 39712 39714 39717 39719 39721 39723 39723 39726 39727 39729 39731 39733 39733 39735 39735 39738 39740 39742 39743 39745 39750 39752 39752 39754 39759 39761 39762 39764 39766 39768 39771 39775 39777 39780 39780 39782 39784 39788 39788 39791 39793 39796 39799 39802 39806 39808 39808 39810 39810 39813 39816 39824 39827 39829 39829 39834 39835 39838 39838 39840 39842 39844 39846 39848 39848 39850 39851 39853 39855 39861 39862 39864 39865 39869 39869 39871 39873 39875 39876 39878 39882 39891 39895 39897 39900 39902 39902 39904 39906 39908 39912 39914 39916 39920 39920 39927 39928 39933 39933 39941 39945 39947 39947 39949 39950 39954 39956 39959 39959 39964 39965 39969 39969 39971 39973 39976 39977 39979 39981 39985 39988 39990 39991 39993 39993 39995 40001 40004 40004 40006 40006 40008 40014 40016 40016 40018 40018 40020 40025 40030 40032 40034 40035 40038 40040 40045 40046 40049 40049 40051 40053 40055 40058 40165 40167 40169 40170 40173 40173 40177 40183 40185 40189 40191 40192 40195 40201 40208 40208 40210 40210 40212 40213 40215 40217 40219 40219 40221 40224 40226 40227 40229 40230 40232 40233 40237 40241 40243 40243 40246 40248 40251 40251 40253 40259 40261 40261 40266 40268 40271 40271 40273 40276 40278 40285 40287 40289 40295 40300 40303 40309 40311 40313 40315 40315 40317 40317 40319 40322 40324 40332 40336 40336 40338 40338 40340 40340 40342 40356 40358 40362 40364 40365 40367 40367 40369 40380 40382 40383 40385 40387 40389 40389 40391 40392 40394 40403 40405 40415 40417 40422 40424 40425 40427 40432 40434 40443 40445 40455 40457 40457 40459 40459 40461 40461 40463 40469 40471 40471 40473 40475 40477 40478 40565 40565 40569 40570 40572 40573 40575 40576 40578 40579 40582 40590 40593 40596 40599 40599 40601 40605 40607 40609 40612 40613 40615 40615 40617 40617 40621 40622 40624 40624 40628 40631 40635 40636 40638 40638 40640 40640 40642 40643 40648 40648 40652 40657 40659 40662 40664 40664 40666 40672 40676 40680 40683 40683 40685 40688 40690 40695 40697 40701 40703 40705 40710 40711 40713 40714 40718 40720 40722 40723 40725 40726 40728 40732 40734 40734 40736 40736 40738 40741 40744 40760 40763 40763 40765 40766 40768 40771 40774 40783 40786 40786 40788 40793 40795 40801 40803 40807 40810 40812 40814 40818 40820 40827 40830 40830 40845 40845 40848 40850 40852 40853 40856 40856 40860 40860 40864 40864 40866 40866 40868 40868 63153 63560 64012 64013 65072 65073 65075 65092 65097 65106 65108 65111 65113 65126 65128 65131 65281 65281 65283 65286 65288 65338 65340 65340 65343 65343 65345 65374 65504 65505 65507 65507 65509 65509 917504 917631)) (make-character-set :mib-enum 2257 :name "windows-1257" :aliases 'nil :mime-encoding 'nil :source '"Microsoft (http://www.iana.org/assignments/charset-reg/windows-1257) [Lazhintseva]" :comments 'nil :references 'nil :ranges #(0 127 160 160 162 164 166 169 171 185 187 190 196 198 201 201 211 211 213 216 220 220 223 223 228 230 233 233 243 243 245 248 252 252 256 257 260 263 268 269 274 275 278 281 290 291 298 299 302 303 310 311 315 316 321 326 332 333 342 343 346 347 352 353 362 363 370 371 377 382 711 711 729 729 731 731 8211 8212 8216 8218 8220 8222 8224 8226 8230 8230 8240 8240 8249 8250 8364 8364 8482 8482)) (make-character-set :mib-enum 104 :name "ISO-2022-CN" :aliases 'nil :mime-encoding 'nil :source '"RFC-1922" :comments 'nil :references '("[RFC1922]") :ranges #(0 127 164 164 167 168 176 177 183 183 215 215 224 225 232 234 236 237 242 243 247 247 249 250 252 252 257 257 275 275 283 283 299 299 333 333 363 363 462 462 464 464 466 466 468 468 470 470 472 472 474 474 476 476 711 711 713 715 729 729 913 929 931 937 945 961 963 969 1025 1025 1040 1103 1105 1105 8211 8214 8216 8217 8220 8221 8229 8230 8240 8240 8242 8243 8245 8245 8251 8251 8254 8254 8451 8451 8453 8453 8457 8457 8470 8470 8544 8555 8560 8569 8592 8595 8598 8601 8712 8712 8719 8719 8721 8721 8725 8725 8730 8730 8733 8736 8741 8741 8743 8747 8750 8750 8756 8759 8764 8765 8776 8776 8780 8780 8786 8786 8800 8801 8804 8807 8814 8815 8857 8857 8869 8869 8895 8895 8978 8978 9216 9247 9249 9249 9312 9321 9332 9371 9472 9547 9552 9552 9566 9566 9569 9569 9578 9578 9581 9587 9601 9615 9620 9621 9632 9633 9650 9651 9660 9661 9670 9671 9675 9675 9678 9679 9698 9701 9733 9734 9737 9737 9792 9794 12288 12291 12293 12293 12296 12311 12317 12318 12321 12329 12353 12435 12449 12534 12539 12539 12549 12585 12832 12841 12963 12963 13198 13199 13212 13214 13217 13217 13252 13252 13262 13262 13265 13266 13269 13269 19968 19969 19971 19971 19975 19985 19987 19990 19992 19999 20002 20002 20004 20008 20010 20014 20016 20020 20022 20022 20024 20031 20034 20035 20037 20037 20039 20041 20043 20048 20050 20052 20054 20054 20056 20057 20060 20065 20070 20070 20073 20073 20080 20081 20083 20083 20094 20095 20098 20100 20102 20102 20104 20105 20107 20111 20113 20117 20120 20123 20126 20130 20132 20137 20139 20142 20146 20147 20149 20150 20153 20155 20159 20171 20173 20174 20177 20177 20179 20186 20188 20191 20193 20193 20195 20197 20200 20204 20208 20215 20219 20219 20221 20221 20223 20226 20228 20229 20232 20235 20237 20245 20247 20251 20253 20256 20258 20258 20260 20263 20266 20269 20271 20272 20274 20276 20278 20278 20280 20280 20282 20287 20289 20289 20291 20291 20294 20297 20300 20325 20327 20327 20329 20332 20334 20336 20339 20361 20363 20363 20365 20365 20367 20370 20372 20376 20378 20382 20384 20384 20387 20387 20389 20394 20396 20396 20398 20399 20402 20403 20405 20407 20409 20411 20415 20421 20423 20423 20425 20427 20429 20433 20435 20436 20438 20449 20451 20451 20454 20454 20456 20458 20460 20463 20465 20465 20467 20472 20474 20474 20478 20478 20480 20480 20485 20487 20489 20489 20491 20495 20497 20508 20510 20515 20517 20529 20531 20531 20533 20533 20535 20535 20538 20538 20540 20540 20542 20542 20544 20545 20547 20547 20549 20559 20561 20561 20563 20563 20565 20565 20567 20567 20570 20581 20584 20592 20594 20599 20602 20603 20605 20608 20610 20611 20613 20613 20615 20616 20619 20622 20625 20626 20628 20630 20632 20638 20642 20643 20645 20645 20647 20649 20652 20664 20666 20667 20669 20671 20673 20674 20676 20683 20686 20687 20689 20689 20691 20695 20698 20699 20701 20701 20704 20704 20707 20714 20716 20721 20723 20723 20725 20726 20728 20729 20731 20731 20733 20736 20738 20748 20752 20757 20759 20760 20762 20762 20764 20764 20767 20770 20772 20774 20777 20778 20781 20782 20784 20789 20791 20797 20799 20801 20803 20809 20811 20813 20817 20818 20820 20823 20825 20831 20833 20835 20837 20837 20839 20841 20843 20846 20848 20849 20851 20857 20859 20861 20864 20866 20869 20869 20871 20874 20876 20877 20879 20879 20881 20889 20891 20892 20894 20894 20896 20896 20898 20898 20900 20901 20906 20908 20911 20915 20917 20919 20921 20921 20923 20926 20928 20928 20932 20945 20948 20948 20951 20952 20955 20958 20960 20961 20964 20964 20971 20971 20973 20973 20975 20977 20979 20979 20981 20982 20984 20989 20991 20995 20998 21002 21004 21006 21008 21011 21014 21022 21024 21025 21028 21029 21032 21035 21037 21038 21040 21043 21045 21051 21053 21053 21055 21060 21062 21063 21065 21070 21072 21074 21076 21078 21082 21087 21089 21090 21093 21093 21095 21095 21097 21103 21106 21106 21108 21109 21111 21112 21114 21117 21119 21124 21127 21133 21136 21137 21139 21139 21142 21145 21147 21147 21149 21155 21158 21158 21160 21166 21169 21171 21179 21180 21182 21187 21191 21191 21193 21193 21195 21195 21197 21197 21200 21200 21202 21203 21205 21209 21211 21211 21213 21215 21218 21220 21222 21222 21225 21225 21227 21227 21231 21233 21235 21237 21239 21244 21246 21248 21253 21254 21256 21259 21261 21266 21269 21271 21273 21274 21276 21277 21279 21283 21286 21286 21290 21290 21293 21297 21300 21300 21303 21303 21305 21313 21315 21317 21319 21322 21324 21327 21329 21335 21338 21338 21340 21340 21342 21348 21350 21351 21353 21353 21355 21356 21358 21365 21367 21372 21375 21375 21378 21378 21380 21382 21385 21391 21394 21394 21396 21402 21404 21407 21410 21417 21420 21422 21426 21426 21428 21428 21430 21430 21433 21433 21435 21435 21439 21439 21441 21443 21448 21453 21457 21457 21460 21460 21462 21465 21467 21467 21471 21478 21480 21491 21493 21497 21499 21501 21505 21505 21507 21508 21510 21523 21525 21529 21531 21537 21539 21561 21563 21566 21568 21571 21573 21576 21578 21579 21582 21584 21586 21593 21595 21596 21600 21608 21611 21612 21615 21624 21626 21634 21636 21636 21638 21640 21643 21650 21652 21654 21656 21659 21661 21661 21664 21681 21683 21684 21686 21688 21690 21705 21708 21719 21721 21722 21724 21730 21732 21739 21741 21742 21745 21747 21751 21752 21754 21757 21759 21759 21761 21761 21763 21772 21774 21778 21780 21780 21783 21783 21786 21787 21792 21792 21794 21796 21798 21799 21802 21802 21804 21817 21819 21820 21822 21825 21827 21830 21832 21835 21837 21842 21845 21847 21852 21852 21854 21855 21857 21863 21866 21866 21868 21870 21877 21880 21883 21892 21895 21903 21905 21909 21912 21914 21916 21917 21919 21919 21921 21928 21930 21934 21937 21939 21941 21941 21943 21943 21945 21945 21947 21947 21949 21952 21954 21974 21977 21981 21983 21983 21985 21996 21999 21999 22002 22003 22005 22007 22009 22010 22012 22018 22020 22020 22022 22022 22024 22025 22028 22032 22034 22040 22043 22047 22051 22052 22055 22055 22057 22058 22060 22070 22072 22075 22077 22082 22085 22086 22088 22090 22092 22094 22099 22100 22103 22106 22108 22108 22110 22110 22112 22112 22114 22118 22120 22132 22134 22137 22139 22140 22142 22151 22156 22160 22163 22163 22165 22165 22167 22170 22172 22173 22179 22179 22181 22184 22186 22191 22194 22199 22204 22206 22208 22211 22213 22214 22216 22221 22225 22225 22227 22228 22231 22231 22234 22235 22237 22242 22244 22245 22247 22247 22250 22251 22253 22254 22256 22257 22260 22261 22263 22263 22265 22266 22269 22271 22273 22276 22278 22285 22290 22292 22294 22294 22296 22296 22298 22300 22302 22304 22306 22307 22312 22314 22316 22320 22323 22324 22329 22331 22334 22334 22336 22338 22341 22341 22343 22343 22345 22354 22359 22359 22362 22370 22372 22372 22374 22374 22376 22379 22381 22381 22383 22391 22395 22397 22400 22400 22402 22406 22411 22412 22415 22415 22418 22421 22423 22427 22429 22439 22441 22441 22443 22443 22445 22446 22450 22450 22452 22454 22456 22458 22460 22461 22463 22463 22465 22467 22470 22471 22475 22476 22478 22480 22482 22482 22484 22485 22488 22490 22492 22493 22495 22501 22503 22503 22505 22505 22508 22525 22528 22530 22532 22542 22544 22545 22548 22549 22553 22553 22555 22558 22560 22561 22563 22565 22567 22570 22572 22585 22587 22587 22589 22589 22591 22591 22596 22596 22600 22607 22609 22613 22615 22619 22621 22622 22626 22629 22632 22632 22635 22637 22639 22639 22641 22641 22644 22646 22649 22659 22661 22667 22670 22676 22680 22682 22684 22689 22691 22691 22693 22694 22696 22697 22699 22700 22702 22703 22705 22705 22707 22707 22714 22714 22716 22719 22721 22722 22725 22729 22734 22735 22737 22742 22744 22747 22749 22751 22754 22756 22759 22761 22763 22764 22766 22768 22771 22772 22774 22774 22777 22778 22780 22783 22786 22788 22790 22791 22796 22799 22802 22802 22804 22807 22809 22810 22812 22812 22815 22816 22818 22818 22820 22821 22823 22823 22825 22831 22833 22833 22836 22836 22839 22842 22844 22844 22846 22846 22848 22850 22852 22853 22855 22859 22862 22865 22867 22872 22874 22874 22876 22876 22880 22882 22885 22885 22887 22887 22889 22891 22893 22894 22896 22900 22902 22905 22907 22920 22922 22922 22925 22928 22930 22931 22934 22937 22941 22942 22944 22955 22958 22959 22961 22966 22969 22974 22976 22977 22979 22979 22981 22984 22986 22996 22998 23000 23002 23006 23008 23009 23011 23014 23016 23018 23020 23022 23025 23031 23033 23041 23043 23050 23052 23052 23055 23055 23057 23057 23059 23059 23061 23065 23067 23068 23070 23072 23075 23075 23077 23077 23081 23081 23085 23086 23089 23097 23100 23100 23102 23102 23104 23108 23110 23114 23116 23117 23120 23123 23125 23128 23130 23136 23138 23138 23140 23143 23145 23146 23148 23149 23152 23152 23156 23160 23162 23165 23167 23167 23171 23172 23178 23180 23182 23184 23186 23189 23191 23191 23194 23199 23202 23202 23205 23207 23209 23210 23212 23212 23214 23234 23236 23236 23238 23245 23250 23250 23252 23267 23269 23270 23272 23278 23281 23281 23283 23289 23291 23291 23293 23293 23295 23295 23297 23299 23301 23301 23303 23305 23307 23308 23311 23312 23315 23316 23318 23319 23321 23323 23325 23326 23328 23329 23331 23336 23338 23338 23340 23344 23346 23346 23348 23348 23351 23352 23356 23360 23363 23363 23365 23365 23367 23368 23371 23374 23376 23377 23379 23389 23391 23391 23394 23398 23401 23404 23406 23406 23408 23411 23413 23413 23415 23416 23418 23419 23421 23421 23423 23425 23427 23429 23431 23433 23435 23436 23438 23439 23442 23443 23445 23445 23447 23454 23456 23464 23466 23470 23472 23472 23475 23478 23480 23481 23485 23490 23492 23495 23498 23502 23504 23508 23510 23510 23512 23513 23517 23532 23534 23538 23541 23542 23544 23548 23551 23551 23553 23553 23555 23556 23558 23570 23572 23574 23576 23576 23578 23578 23580 23581 23583 23583 23586 23586 23588 23589 23591 23592 23594 23594 23596 23596 23600 23601 23603 23604 23607 23618 23620 23633 23636 23638 23640 23641 23644 23646 23648 23658 23660 23663 23665 23665 23667 23668 23673 23676 23678 23679 23681 23682 23686 23686 23688 23693 23695 23709 23711 23729 23731 23731 23733 23736 23741 23741 23743 23743 23745 23745 23748 23748 23750 23756 23758 23760 23762 23764 23766 23771 23774 23775 23777 23777 23780 23782 23784 23784 23786 23786 23788 23790 23792 23793 23796 23796 23798 23801 23803 23803 23805 23805 23807 23811 23814 23815 23819 23823 23825 23826 23828 23828 23830 23831 23833 23835 23837 23840 23842 23849 23853 23854 23856 23866 23868 23875 23877 23877 23879 23879 23881 23884 23886 23886 23888 23890 23893 23893 23896 23897 23899 23899 23901 23902 23906 23907 23909 23909 23911 23913 23915 23916 23919 23919 23921 23922 23924 23924 23927 23927 23929 23930 23932 23938 23940 23940 23942 23946 23949 23949 23954 23957 23959 23959 23961 23962 23964 23970 23975 23978 23980 23986 23988 23989 23991 23992 23994 23994 23996 23997 24000 24000 24002 24003 24005 24007 24009 24009 24011 24011 24013 24013 24015 24015 24017 24018 24020 24022 24024 24024 24027 24027 24029 24034 24037 24041 24043 24043 24046 24052 24055 24055 24057 24057 24061 24063 24065 24070 24072 24072 24074 24074 24076 24076 24078 24081 24084 24093 24095 24105 24107 24107 24109 24110 24113 24113 24115 24116 24118 24120 24123 24126 24128 24133 24138 24143 24147 24149 24151 24153 24155 24163 24166 24176 24178 24182 24184 24192 24194 24194 24196 24196 24198 24205 24207 24209 24211 24215 24217 24220 24222 24224 24226 24232 24234 24238 24240 24249 24254 24254 24257 24258 24260 24268 24270 24270 24273 24291 24293 24298 24300 24300 24302 24303 24305 24308 24310 24311 24314 24314 24318 24325 24327 24328 24330 24331 24335 24335 24337 24341 24343 24344 24346 24347 24349 24349 24351 24352 24354 24362 24365 24369 24371 24371 24373 24378 24380 24380 24384 24384 24387 24388 24390 24390 24392 24396 24398 24400 24402 24409 24413 24414 24417 24418 24420 24423 24425 24429 24431 24433 24435 24436 24438 24441 24443 24450 24452 24460 24464 24466 24469 24473 24475 24476 24478 24481 24485 24486 24488 24495 24498 24498 24501 24503 24505 24505 24507 24513 24515 24518 24521 24521 24524 24525 24527 24530 24532 24537 24541 24542 24544 24545 24547 24549 24551 24552 24554 24555 24557 24559 24561 24561 24563 24565 24567 24568 24570 24571 24573 24582 24585 24599 24601 24606 24608 24610 24612 24623 24626 24629 24631 24631 24633 24633 24635 24636 24639 24647 24649 24649 24651 24653 24656 24656 24658 24661 24664 24667 24669 24671 24674 24688 24690 24691 24694 24694 24696 24701 24703 24705 24707 24714 24716 24718 24720 24720 24722 24722 24724 24727 24730 24733 24735 24736 24738 24739 24742 24742 24744 24744 24747 24749 24751 24754 24756 24769 24771 24783 24785 24785 24787 24789 24792 24797 24799 24802 24804 24804 24806 24809 24811 24828 24830 24833 24835 24838 24840 24843 24845 24848 24850 24854 24856 24856 24858 24861 24863 24864 24867 24868 24870 24873 24875 24876 24878 24879 24882 24882 24884 24884 24886 24887 24891 24891 24894 24897 24900 24911 24913 24918 24920 24920 24922 24923 24925 24927 24929 24931 24933 24936 24938 24940 24942 24942 24944 24951 24953 24954 24956 24956 24958 24958 24960 24960 24962 24963 24969 24974 24976 24980 24982 24982 24986 24987 24989 24989 24991 24991 24993 24994 24996 24996 24999 25016 25018 25018 25020 25020 25022 25023 25025 25027 25029 25037 25041 25042 25044 25044 25046 25046 25048 25048 25054 25056 25059 25067 25069 25070 25072 25074 25077 25089 25091 25092 25094 25106 25108 25115 25119 25125 25127 25127 25129 25134 25136 25136 25138 25140 25142 25143 25146 25146 25149 25155 25158 25166 25168 25172 25176 25180 25182 25182 25184 25191 25193 25204 25206 25207 25209 25217 25219 25220 25222 25226 25228 25228 25230 25231 25233 25240 25242 25243 25247 25250 25252 25253 25256 25265 25267 25270 25272 25273 25275 25279 25282 25282 25284 25300 25302 25308 25311 25311 25314 25315 25317 25321 25323 25347 25351 25353 25355 25361 25363 25366 25370 25371 25373 25381 25384 25389 25391 25391 25394 25396 25398 25398 25400 25406 25408 25425 25428 25434 25438 25439 25441 25443 25445 25445 25447 25449 25451 25451 25453 25458 25461 25464 25466 25469 25472 25477 25479 25482 25484 25490 25492 25492 25494 25497 25499 25509 25511 25521 25523 25524 25527 25528 25530 25530 25532 25534 25536 25536 25538 25552 25554 25555 25557 25569 25571 25573 25575 25579 25581 25590 25592 25593 25597 25597 25599 25602 25605 25606 25609 25616 25618 25624 25626 25628 25630 25640 25642 25648 25651 25655 25657 25658 25661 25665 25667 25672 25674 25675 25677 25678 25680 25684 25688 25689 25691 25697 25701 25705 25707 25712 25714 25723 25725 25725 25727 25727 25730 25730 25732 25733 25735 25740 25743 25747 25749 25754 25756 25760 25762 25766 25769 25769 25771 25774 25776 25779 25781 25781 25783 25784 25786 25797 25799 25799 25801 25803 25805 25808 25810 25810 25812 25812 25814 25819 25822 25822 25824 25824 25826 25828 25830 25830 25832 25833 25835 25837 25839 25844 25847 25848 25850 25857 25859 25860 25862 25863 25865 25865 25868 25872 25874 25881 25883 25885 25888 25894 25897 25903 25906 25913 25915 25915 25917 25919 25921 25921 25923 25923 25925 25926 25928 25930 25932 25932 25935 25935 25937 25937 25939 25945 25947 25950 25954 25960 25962 25964 25967 25968 25970 25980 25983 25988 25991 25991 25995 25996 26000 26007 26009 26009 26011 26018 26020 26021 26023 26032 26034 26035 26038 26041 26043 26045 26047 26047 26049 26054 26059 26064 26066 26067 26070 26071 26074 26075 26077 26082 26085 26089 26092 26103 26106 26109 26112 26112 26114 26133 26137 26137 26140 26141 26143 26146 26148 26152 26155 26155 26157 26159 26161 26166 26169 26170 26172 26172 26174 26174 26177 26179 26181 26181 26183 26183 26185 26188 26191 26191 26193 26199 26201 26207 26209 26210 26212 26214 26216 26216 26218 26218 26220 26220 26222 26226 26228 26228 26230 26236 26238 26238 26240 26240 26242 26242 26244 26244 26246 26253 26256 26257 26260 26265 26269 26269 26271 26274 26279 26283 26286 26290 26292 26293 26295 26299 26301 26302 26304 26304 26308 26308 26310 26316 26319 26319 26322 26322 26326 26326 26328 26334 26336 26336 26339 26340 26342 26342 26344 26345 26347 26350 26352 26352 26354 26356 26358 26361 26364 26364 26366 26369 26371 26373 26376 26379 26381 26381 26383 26384 26386 26389 26391 26392 26395 26395 26397 26397 26399 26403 26406 26408 26410 26415 26417 26417 26419 26421 26424 26432 26434 26435 26437 26441 26443 26449 26451 26451 26453 26455 26457 26458 26460 26465 26469 26469 26472 26474 26476 26477 26479 26495 26497 26497 26499 26503 26505 26505 26507 26510 26512 26517 26519 26522 26524 26527 26530 26531 26533 26533 26535 26536 26538 26539 26541 26544 26546 26555 26560 26566 26568 26580 26584 26592 26594 26599 26601 26616 26618 26618 26620 26621 26623 26624 26629 26629 26631 26636 26638 26639 26641 26644 26646 26648 26650 26650 26652 26653 26655 26657 26661 26662 26664 26667 26669 26671 26673 26677 26679 26686 26688 26694 26696 26705 26707 26709 26720 26729 26731 26731 26733 26735 26737 26738 26740 26745 26747 26755 26757 26759 26761 26764 26767 26772 26774 26775 26779 26781 26783 26788 26790 26805 26816 26816 26818 26818 26820 26820 26822 26825 26827 26830 26832 26840 26842 26842 26844 26849 26851 26852 26854 26860 26862 26877 26881 26881 26884 26888 26890 26901 26903 26903 26911 26912 26916 26917 26922 26922 26925 26925 26927 26928 26930 26933 26935 26937 26939 26941 26943 26946 26948 26949 26952 26956 26958 26959 26961 26964 26966 26976 26978 26979 26981 26982 26984 26993 26996 27004 27008 27008 27010 27012 27014 27017 27021 27022 27024 27025 27027 27036 27038 27038 27040 27041 27043 27057 27059 27063 27065 27065 27067 27071 27073 27076 27078 27078 27081 27088 27091 27092 27097 27097 27099 27099 27103 27104 27106 27106 27108 27112 27115 27118 27121 27124 27126 27128 27131 27138 27140 27146 27149 27149 27151 27151 27153 27153 27155 27161 27163 27163 27165 27169 27171 27171 27173 27176 27178 27178 27183 27183 27185 27186 27188 27189 27192 27201 27204 27204 27206 27209 27211 27211 27213 27217 27220 27222 27224 27227 27229 27234 27236 27243 27245 27245 27247 27247 27249 27249 27254 27254 27257 27257 27260 27260 27262 27265 27267 27269 27271 27271 27273 27273 27276 27278 27280 27287 27290 27292 27294 27302 27304 27305 27307 27311 27315 27316 27318 27323 27325 27325 27330 27331 27333 27335 27339 27341 27343 27345 27347 27347 27353 27361 27365 27365 27367 27368 27370 27372 27374 27377 27379 27379 27384 27388 27392 27392 27394 27396 27400 27403 27407 27411 27414 27418 27422 27422 27424 27429 27431 27432 27436 27437 27439 27439 27441 27444 27446 27455 27457 27459 27461 27470 27472 27473 27476 27478 27481 27481 27483 27484 27486 27495 27498 27498 27501 27501 27506 27506 27510 27513 27515 27516 27518 27524 27526 27535 27537 27547 27550 27559 27562 27563 27565 27568 27570 27575 27578 27578 27580 27581 27583 27597 27599 27600 27602 27611 27614 27614 27616 27620 27622 27624 27626 27628 27631 27632 27634 27635 27637 27637 27639 27641 27643 27657 27659 27661 27663 27665 27667 27670 27672 27675 27677 27677 27679 27692 27694 27696 27698 27702 27704 27704 27707 27707 27709 27715 27718 27719 27721 27728 27730 27730 27732 27733 27735 27735 27737 27737 27739 27745 27748 27755 27757 27757 27759 27764 27766 27766 27768 27771 27773 27774 27776 27792 27794 27798 27800 27805 27807 27807 27809 27809 27811 27815 27817 27822 27824 27828 27830 27847 27849 27850 27852 27853 27855 27863 27865 27870 27872 27875 27877 27877 27879 27891 27893 27902 27904 27905 27907 27908 27911 27922 27926 27931 27933 27936 27938 27938 27941 27941 27943 27971 27973 27976 27978 27979 27981 27983 27985 27988 27992 27994 27996 27996 27998 28010 28012 28016 28020 28032 28034 28046 28048 28053 28055 28056 28059 28059 28061 28065 28067 28068 28070 28076 28078 28079 28082 28085 28087 28088 28090 28096 28098 28098 28100 28109 28111 28134 28136 28151 28153 28157 28160 28160 28163 28163 28165 28165 28170 28170 28172 28174 28176 28177 28180 28180 28182 28183 28185 28189 28191 28201 28203 28214 28216 28225 28227 28231 28233 28235 28237 28238 28241 28246 28248 28248 28250 28265 28267 28267 28270 28271 28273 28276 28279 28281 28286 28287 28291 28291 28293 28294 28296 28297 28301 28304 28306 28308 28310 28313 28315 28327 28330 28331 28334 28340 28342 28343 28345 28376 28378 28378 28380 28380 28382 28386 28388 28390 28392 28393 28395 28399 28401 28402 28404 28409 28411 28419 28421 28426 28429 28431 28434 28437 28440 28442 28444 28444 28446 28455 28457 28467 28469 28476 28478 28481 28483 28483 28486 28487 28491 28491 28493 28501 28503 28504 28506 28516 28518 28519 28521 28528 28530 28532 28534 28536 28538 28544 28546 28546 28548 28553 28555 28558 28560 28560 28562 28567 28572 28572 28574 28574 28576 28596 28598 28598 28600 28602 28604 28605 28607 28612 28614 28623 28625 28626 28628 28629 28632 28632 28635 28644 28646 28649 28651 28658 28660 28660 28663 28663 28666 28668 28670 28673 28676 28679 28681 28687 28689 28689 28692 28701 28703 28708 28710 28715 28719 28725 28727 28732 28734 28742 28744 28746 28748 28748 28751 28751 28753 28754 28757 28760 28762 28763 28765 28774 28776 28781 28783 28785 28788 28790 28792 28792 28794 28794 28796 28800 28802 28806 28809 28810 28814 28814 28817 28822 28824 28826 28828 28829 28831 28831 28833 28833 28836 28836 28841 28841 28843 28849 28851 28853 28855 28862 28864 28867 28869 28872 28874 28875 28877 28879 28881 28884 28887 28898 28900 28900 28902 28905 28907 28909 28911 28912 28915 28916 28918 28925 28927 28928 28930 28930 28932 28932 28934 28934 28937 28942 28944 28944 28947 28947 28949 28956 28958 28963 28965 28966 28968 28968 28974 28978 28982 28982 28986 28986 28993 28999 29001 29006 29008 29008 29010 29012 29014 29014 29016 29018 29020 29034 29036 29036 29038 29038 29040 29040 29042 29043 29048 29048 29050 29051 29053 29053 29056 29058 29060 29063 29065 29066 29071 29072 29074 29074 29076 29076 29079 29089 29092 29093 29095 29098 29100 29100 29103 29107 29109 29109 29112 29113 29116 29131 29134 29136 29138 29138 29140 29142 29144 29148 29151 29154 29156 29160 29164 29166 29168 29170 29172 29172 29176 29177 29179 29183 29185 29187 29189 29191 29194 29194 29196 29197 29200 29200 29203 29204 29209 29211 29213 29215 29218 29219 29222 29226 29228 29229 29232 29233 29237 29243 29245 29247 29249 29250 29252 29252 29254 29261 29263 29263 29266 29267 29270 29270 29272 29275 29277 29283 29286 29287 29289 29290 29292 29292 29294 29296 29298 29313 29316 29318 29320 29331 29333 29336 29338 29339 29341 29343 29345 29354 29356 29360 29364 29370 29373 29373 29375 29382 29384 29390 29392 29394 29396 29396 29398 29402 29404 29404 29406 29409 29411 29412 29414 29414 29416 29428 29430 29441 29443 29443 29447 29448 29450 29452 29454 29455 29457 29459 29461 29465 29467 29470 29473 29475 29477 29479 29481 29486 29488 29500 29502 29504 29506 29509 29513 29514 29516 29518 29520 29522 29527 29531 29533 29538 29541 29552 29554 29555 29557 29560 29562 29579 29582 29582 29585 29591 29595 29595 29597 29597 29599 29602 29604 29606 29608 29609 29611 29616 29618 29628 29630 29632 29634 29635 29637 29645 29647 29652 29654 29662 29664 29664 29667 29667 29669 29669 29671 29675 29677 29678 29682 29682 29684 29686 29688 29688 29690 29690 29692 29697 29699 29709 29711 29712 29718 29718 29722 29723 29725 29725 29728 29734 29736 29750 29754 29754 29756 29756 29759 29762 29764 29764 29766 29766 29770 29771 29773 29778 29780 29781 29783 29783 29785 29788 29790 29791 29794 29796 29799 29799 29801 29802 29805 29811 29813 29815 29817 29817 29820 29825 29827 29827 29829 29835 29838 29838 29840 29840 29842 29842 29844 29845 29847 29848 29850 29850 29852 29852 29854 29857 29859 29859 29861 29867 29869 29869 29871 29874 29877 29880 29882 29883 29885 29891 29893 29893 29898 29899 29903 29903 29906 29906 29908 29926 29928 29929 29932 29932 29934 29935 29940 29943 29947 29947 29949 29952 29954 29956 29959 29960 29963 29965 29967 29978 29980 29981 29983 29983 29985 29986 29989 29990 29992 30003 30005 30005 30007 30011 30013 30016 30021 30021 30023 30024 30027 30028 30030 30031 30036 30036 30041 30045 30047 30047 30050 30054 30058 30060 30063 30064 30066 30066 30068 30068 30070 30073 30077 30080 30083 30084 30086 30087 30090 30092 30095 30098 30100 30106 30109 30109 30111 30117 30119 30119 30122 30124 30126 30134 30136 30149 30151 30162 30164 30171 30173 30180 30182 30184 30186 30187 30189 30189 30191 30209 30211 30211 30213 30213 30216 30221 30223 30225 30227 30251 30253 30253 30255 30261 30264 30264 30266 30266 30268 30272 30274 30275 30278 30281 30284 30285 30288 30288 30290 30292 30294 30298 30300 30300 30302 30309 30313 30322 30325 30325 30328 30329 30331 30335 30337 30338 30340 30340 30342 30347 30350 30351 30353 30355 30357 30358 30361 30366 30372 30372 30374 30374 30378 30379 30381 30386 30388 30389 30392 30392 30394 30395 30397 30399 30402 30406 30408 30410 30413 30420 30422 30424 30426 30431 30433 30433 30435 30439 30441 30442 30444 30453 30455 30460 30462 30462 30465 30465 30467 30469 30471 30475 30477 30477 30480 30483 30485 30485 30489 30491 30493 30493 30495 30496 30498 30499 30501 30505 30509 30509 30511 30511 30513 30526 30528 30529 30531 30535 30538 30546 30548 30550 30553 30556 30558 30563 30565 30575 30585 30585 30588 30597 30599 30601 30603 30607 30609 30610 30613 30613 30615 30615 30617 30627 30629 30629 30631 30637 30640 30647 30650 30653 30655 30655 30658 30658 30660 30660 30663 30663 30665 30666 30668 30672 30675 30677 30679 30684 30686 30686 30688 30688 30690 30691 30693 30693 30695 30697 30699 30707 30710 30723 30725 30726 30729 30729 30732 30740 30742 30744 30746 30746 30748 30749 30751 30755 30757 30773 30775 30780 30782 30782 30784 30784 30787 30787 30789 30789 30791 30794 30796 30798 30800 30800 30802 30802 30805 30807 30812 30814 30816 30816 30818 30818 30820 30821 30824 30833 30839 30839 30841 30841 30843 30844 30846 30848 30851 30855 30857 30857 30860 30863 30865 30865 30867 30876 30878 30885 30887 30893 30896 30900 30905 30908 30910 30910 30913 30913 30915 30917 30920 30929 30932 30933 30937 30939 30941 30947 30949 30949 30951 30954 30956 30957 30959 30959 30962 30964 30967 30967 30969 30975 30977 30978 30980 30981 30985 30985 30988 30988 30990 30990 30992 30996 30999 30999 31001 31001 31003 31006 31009 31009 31011 31021 31023 31023 31025 31025 31028 31029 31032 31042 31044 31052 31055 31063 31066 31077 31079 31083 31085 31085 31087 31088 31090 31092 31095 31098 31100 31101 31103 31106 31108 31109 31112 31112 31114 31115 31117 31120 31122 31128 31130 31132 31136 31138 31140 31140 31142 31144 31146 31150 31152 31156 31158 31163 31165 31169 31171 31171 31173 31174 31176 31177 31179 31179 31181 31183 31185 31186 31189 31190 31192 31192 31196 31200 31203 31204 31206 31207 31209 31216 31222 31224 31226 31227 31229 31229 31232 31232 31234 31238 31240 31240 31242 31246 31248 31253 31255 31260 31262 31264 31266 31267 31270 31270 31272 31272 31275 31275 31278 31281 31283 31283 31287 31287 31289 31289 31291 31293 31295 31296 31300 31300 31302 31304 31306 31310 31313 31313 31316 31316 31318 31320 31322 31324 31327 31330 31335 31337 31339 31342 31344 31345 31348 31355 31358 31361 31363 31373 31375 31378 31380 31385 31388 31392 31394 31395 31397 31398 31400 31407 31409 31416 31418 31418 31422 31425 31428 31429 31431 31431 31434 31435 31441 31441 31446 31446 31448 31449 31454 31456 31459 31462 31467 31467 31469 31471 31478 31479 31481 31483 31485 31485 31487 31489 31491 31494 31496 31499 31502 31509 31512 31515 31517 31518 31520 31520 31522 31526 31528 31528 31530 31541 31544 31544 31546 31548 31550 31550 31552 31552 31556 31570 31572 31572 31574 31574 31576 31576 31578 31579 31581 31581 31584 31591 31593 31593 31597 31598 31600 31609 31611 31611 31614 31614 31616 31616 31618 31618 31620 31621 31623 31624 31626 31633 31636 31641 31643 31645 31648 31650 31652 31652 31654 31661 31663 31663 31665 31665 31668 31669 31671 31673 31678 31678 31680 31681 31684 31684 31686 31687 31689 31692 31694 31694 31697 31697 31699 31701 31704 31723 31726 31726 31728 31732 31735 31737 31739 31747 31749 31751 31753 31761 31766 31766 31769 31769 31772 31779 31781 31789 31792 31792 31795 31795 31799 31801 31803 31809 31811 31811 31813 31813 31815 31818 31820 31821 31824 31824 31827 31828 31831 31831 31833 31836 31839 31840 31843 31847 31849 31852 31854 31855 31858 31861 31864 31869 31871 31873 31876 31877 31880 31882 31884 31885 31889 31890 31892 31896 31900 31903 31905 31909 31912 31912 31914 31914 31918 31919 31921 31925 31929 31935 31937 31937 31941 31941 31943 31944 31946 31950 31952 31954 31956 31959 31961 31961 31964 31968 31970 31970 31975 31976 31978 31978 31980 31980 31982 31986 31988 31988 31990 31992 31995 31995 31997 31998 32000 32034 32039 32041 32043 32044 32046 32051 32053 32054 32056 32071 32074 32074 32078 32086 32088 32088 32091 32092 32094 32095 32097 32099 32102 32107 32109 32115 32119 32119 32121 32125 32127 32129 32131 32134 32136 32136 32140 32143 32145 32148 32150 32150 32156 32163 32166 32167 32169 32170 32172 32178 32180 32181 32183 32194 32196 32199 32201 32204 32206 32206 32210 32210 32215 32219 32221 32225 32227 32227 32230 32234 32236 32236 32238 32244 32246 32247 32249 32251 32259 32259 32264 32279 32282 32293 32297 32299 32301 32329 32332 32332 32336 32346 32348 32348 32350 32355 32360 32363 32365 32365 32367 32368 32370 32382 32384 32386 32390 32392 32394 32397 32399 32399 32401 32401 32403 32412 32415 32429 32431 32435 32437 32442 32445 32469 32471 32483 32485 32491 32493 32504 32506 32521 32523 32527 32529 32541 32543 32566 32568 32570 32573 32575 32578 32581 32584 32584 32586 32589 32591 32593 32596 32597 32599 32600 32602 32611 32613 32622 32624 32631 32633 32639 32641 32641 32643 32643 32645 32654 32657 32658 32660 32662 32666 32674 32676 32681 32684 32685 32687 32691 32693 32707 32709 32709 32711 32711 32713 32722 32724 32725 32727 32728 32731 32732 32734 32739 32741 32742 32744 32757 32759 32761 32763 32769 32771 32775 32779 32786 32788 32793 32795 32796 32798 32802 32804 32810 32812 32812 32816 32817 32819 32825 32827 32827 32829 32831 32834 32835 32838 32840 32842 32845 32847 32850 32852 32852 32854 32854 32856 32856 32858 32858 32860 32862 32868 32868 32871 32871 32873 32874 32876 32876 32879 32883 32885 32889 32893 32896 32898 32903 32905 32908 32911 32912 32914 32915 32917 32918 32920 32925 32927 32933 32937 32939 32941 32943 32945 32946 32948 32949 32951 32952 32954 32954 32956 32970 32972 32977 32980 32990 32992 32993 32995 33005 33007 33014 33016 33022 33024 33026 33029 33030 33032 33034 33037 33046 33048 33051 33053 33055 33057 33061 33063 33063 33065 33065 33067 33069 33071 33074 33078 33078 33080 33082 33085 33086 33091 33092 33094 33096 33098 33109 33113 33116 33118 33118 33120 33122 33124 33127 33129 33129 33131 33131 33133 33140 33142 33152 33154 33155 33158 33165 33167 33167 33169 33169 33173 33173 33175 33184 33186 33187 33190 33196 33198 33198 33200 33205 33207 33207 33209 33223 33225 33226 33228 33229 33231 33234 33237 33237 33239 33243 33245 33251 33253 33258 33260 33262 33266 33268 33271 33276 33278 33282 33284 33293 33296 33298 33300 33302 33307 33315 33317 33317 33320 33320 33322 33325 33327 33344 33346 33346 33348 33349 33351 33351 33353 33353 33355 33355 33358 33363 33365 33372 33374 33375 33377 33377 33379 33380 33382 33382 33384 33385 33387 33397 33399 33402 33404 33408 33410 33413 33416 33416 33418 33419 33421 33428 33431 33457 33459 33470 33472 33476 33479 33480 33482 33487 33489 33497 33499 33500 33502 33505 33507 33512 33514 33517 33519 33527 33529 33531 33534 33534 33536 33545 33548 33551 33553 33553 33556 33559 33561 33564 33566 33566 33568 33568 33570 33570 33572 33581 33583 33583 33585 33596 33599 33620 33622 33622 33626 33628 33630 33633 33635 33647 33651 33656 33658 33663 33665 33665 33667 33667 33669 33680 33682 33694 33696 33696 33698 33707 33710 33716 33718 33722 33724 33725 33727 33740 33742 33743 33745 33745 33748 33753 33755 33765 33767 33772 33774 33782 33784 33791 33793 33793 33795 33796 33798 33799 33801 33811 33816 33816 33819 33821 33827 33833 33835 33837 33839 33853 33855 33856 33858 33863 33865 33865 33867 33870 33872 33874 33876 33876 33878 33879 33881 33889 33891 33891 33893 33897 33899 33905 33907 33914 33917 33918 33922 33922 33926 33929 33931 33937 33940 33940 33943 33954 33956 33956 33959 33964 33966 33970 33972 33972 33974 33974 33976 33981 33983 33986 33988 33991 33993 34004 34006 34007 34011 34011 34013 34013 34015 34016 34019 34019 34021 34028 34030 34036 34038 34039 34041 34048 34050 34050 34054 34063 34065 34074 34076 34081 34083 34097 34103 34110 34112 34113 34115 34122 34125 34126 34129 34129 34131 34137 34139 34139 34141 34142 34144 34158 34161 34162 34164 34172 34174 34174 34176 34193 34196 34198 34200 34212 34214 34218 34222 34225 34227 34234 34237 34249 34251 34251 34253 34259 34261 34261 34263 34266 34268 34271 34273 34278 34280 34285 34287 34290 34294 34299 34301 34305 34308 34311 34313 34316 34321 34321 34326 34332 34334 34343 34345 34346 34348 34350 34353 34358 34360 34364 34366 34368 34371 34371 34374 34376 34379 34390 34393 34396 34398 34399 34401 34405 34407 34417 34419 34420 34423 34423 34425 34434 34437 34439 34442 34446 34448 34449 34451 34458 34460 34462 34465 34469 34471 34474 34476 34476 34479 34481 34483 34508 34510 34513 34515 34516 34518 34527 34530 34532 34534 34534 34536 34542 34544 34555 34558 34558 34560 34574 34577 34579 34581 34581 34583 34588 34590 34590 34592 34602 34604 34606 34608 34613 34615 34616 34618 34620 34622 34627 34630 34633 34636 34672 34675 34686 34689 34693 34695 34697 34699 34699 34701 34701 34703 34708 34710 34712 34714 34719 34722 34724 34728 34728 34730 34736 34738 34752 34754 34758 34760 34764 34769 34772 34775 34777 34779 34792 34794 34799 34802 34804 34806 34807 34809 34812 34814 34819 34821 34822 34824 34829 34832 34833 34835 34839 34841 34841 34843 34845 34847 34854 34856 34860 34862 34867 34869 34873 34875 34881 34883 34885 34888 34888 34890 34894 34898 34903 34905 34907 34909 34909 34913 34917 34919 34930 34932 34935 34937 34937 34940 34949 34952 34953 34955 34958 34961 34963 34965 34972 34974 34975 34977 34978 34980 34980 34983 34984 34986 34989 34993 34994 34998 35002 35004 35006 35008 35010 35013 35014 35017 35022 35024 35024 35026 35026 35028 35039 35041 35045 35047 35048 35051 35052 35054 35060 35062 35070 35073 35074 35077 35079 35081 35084 35086 35086 35088 35099 35102 35103 35105 35107 35109 35111 35113 35128 35131 35134 35137 35138 35140 35140 35142 35142 35145 35145 35147 35148 35151 35155 35158 35172 35174 35174 35177 35183 35185 35188 35190 35190 35193 35196 35198 35199 35201 35203 35205 35206 35208 35208 35211 35211 35215 35215 35219 35219 35221 35224 35227 35231 35233 35236 35238 35238 35242 35242 35244 35247 35250 35250 35254 35255 35257 35258 35261 35266 35268 35276 35278 35286 35289 35302 35304 35305 35307 35309 35311 35316 35318 35320 35322 35324 35326 35328 35330 35332 35335 35336 35338 35338 35340 35340 35342 35347 35349 35352 35355 35355 35357 35359 35362 35363 35365 35365 35367 35367 35370 35370 35372 35373 35376 35377 35380 35380 35382 35382 35385 35388 35390 35393 35396 35398 35400 35400 35402 35402 35404 35410 35412 35417 35419 35419 35422 35422 35424 35427 35430 35430 35432 35433 35435 35438 35440 35447 35449 35452 35455 35455 35457 35463 35465 35469 35471 35471 35473 35475 35477 35478 35480 35482 35486 35486 35488 35489 35491 35496 35498 35499 35504 35504 35506 35506 35510 35510 35512 35520 35522 35529 35531 35531 35533 35533 35535 35535 35537 35545 35547 35554 35556 35556 35558 35560 35563 35563 35565 35576 35578 35580 35582 35586 35588 35592 35594 35595 35597 35614 35616 35616 35618 35624 35626 35628 35630 35633 35635 35635 35637 35639 35641 35646 35648 35650 35653 35659 35662 35674 35676 35677 35679 35680 35683 35683 35685 35688 35690 35693 35695 35696 35700 35700 35703 35707 35709 35712 35714 35714 35716 35718 35720 35720 35722 35724 35726 35726 35730 35734 35736 35738 35740 35740 35742 35755 35757 35760 35762 35770 35772 35782 35784 35791 35793 35817 35819 35848 35850 35869 35871 35895 35897 35897 35899 35903 35905 35907 35909 35920 35924 35927 35930 35930 35932 35933 35935 35935 35937 35938 35940 35942 35944 35949 35951 35955 35957 35963 35965 35965 35968 35970 35972 35974 35977 35978 35980 35981 35983 35989 35991 35994 35996 35998 36000 36005 36007 36012 36015 36016 36018 36037 36039 36040 36042 36042 36044 36044 36047 36047 36049 36051 36053 36053 36055 36055 36057 36058 36060 36072 36074 36074 36076 36078 36080 36081 36083 36085 36088 36094 36096 36096 36098 36098 36100 36106 36109 36109 36111 36112 36115 36119 36121 36121 36123 36123 36125 36127 36129 36176 36179 36182 36184 36190 36192 36196 36198 36201 36203 36208 36210 36217 36219 36219 36221 36221 36224 36225 36228 36229 36233 36246 36249 36249 36251 36252 36255 36257 36259 36259 36261 36261 36263 36264 36266 36271 36273 36282 36284 36284 36286 36287 36289 36296 36299 36305 36307 36307 36309 36324 36326 36332 36334 36341 36343 36352 36354 36359 36361 36362 36364 36365 36367 36391 36393 36396 36398 36401 36403 36406 36408 36410 36412 36418 36420 36421 36423 36430 36432 36439 36441 36455 36457 36458 36460 36461 36463 36464 36466 36468 36470 36470 36472 36472 36474 36476 36479 36479 36481 36482 36484 36504 36506 36506 36508 36513 36515 36518 36520 36524 36527 36527 36530 36530 36538 36538 36541 36541 36544 36544 36546 36546 36553 36559 36561 36564 36567 36568 36571 36577 36581 36585 36587 36588 36590 36591 36593 36593 36596 36604 36606 36611 36613 36619 36621 36622 36624 36632 36634 36640 36643 36646 36649 36650 36652 36652 36654 36655 36658 36665 36667 36667 36670 36672 36674 36681 36683 36683 36685 36699 36701 36708 36710 36713 36715 36735 36737 36747 36749 36753 36755 36764 36766 36767 36771 36771 36774 36774 36776 36777 36779 36779 36781 36786 36788 36788 36790 36790 36793 36793 36797 36799 36801 36802 36804 36809 36811 36811 36813 36814 36816 36825 36827 36838 36840 36843 36845 36846 36848 36848 36851 36870 36873 36877 36879 36882 36884 36887 36889 36900 36902 36902 36909 36911 36913 36914 36916 36918 36920 36920 36923 36927 36929 36930 36932 36932 36935 36935 36937 36939 36941 36949 36951 36953 36955 36958 36960 36960 36962 36963 36965 36965 36967 36969 36971 36971 36973 36976 36978 37000 37002 37003 37005 37005 37007 37009 37011 37013 37015 37017 37019 37019 37021 37027 37029 37031 37034 37034 37036 37036 37038 37046 37048 37051 37053 37055 37057 37057 37059 37061 37063 37064 37066 37067 37070 37073 37075 37085 37087 37101 37103 37109 37112 37129 37131 37131 37133 37138 37140 37140 37142 37156 37158 37174 37176 37179 37182 37185 37187 37200 37202 37203 37205 37208 37210 37210 37213 37221 37224 37226 37228 37228 37230 37242 37245 37255 37257 37261 37263 37267 37273 37283 37285 37285 37287 37288 37290 37301 37303 37303 37305 37306 37308 37310 37312 37315 37317 37319 37321 37329 37331 37333 37335 37338 37340 37341 37346 37348 37350 37358 37361 37361 37363 37365 37367 37369 37373 37373 37375 37383 37385 37386 37388 37389 37391 37394 37396 37399 37401 37402 37404 37404 37406 37406 37411 37415 37421 37422 37424 37428 37430 37434 37437 37440 37445 37446 37448 37460 37462 37463 37466 37467 37470 37470 37472 37473 37475 37479 37484 37485 37487 37488 37490 37490 37492 37492 37494 37494 37496 37504 37506 37507 37509 37512 37514 37518 37521 37521 37523 37533 37536 37548 37550 37550 37554 37559 37563 37564 37568 37587 37589 37589 37591 37593 37597 37601 37604 37604 37606 37610 37614 37617 37623 37628 37630 37634 37636 37636 37638 37638 37640 37641 37643 37648 37650 37654 37656 37659 37661 37675 37677 37679 37683 37686 37688 37689 37692 37692 37694 37694 37702 37703 37705 37714 37716 37724 37726 37726 37728 37729 37731 37733 37735 37735 37738 37738 37740 37741 37744 37745 37749 37751 37753 37756 37758 37758 37760 37760 37762 37763 37768 37770 37772 37775 37777 37778 37780 37787 37789 37791 37793 37802 37804 37804 37806 37813 37815 37815 37824 37824 37826 37828 37831 37832 37834 37834 37836 37842 37844 37850 37852 37855 37857 37860 37862 37864 37868 37868 37870 37870 37877 37888 37891 37891 37894 37895 37897 37910 37912 37913 37920 37920 37928 37932 37934 37934 37936 37939 37941 37952 37956 37964 37967 37970 37973 37973 37975 37975 37981 37982 37984 37984 37986 37988 37992 37995 37997 38008 38012 38019 38021 38032 38034 38037 38039 38039 38041 38086 38088 38094 38096 38098 38101 38105 38107 38117 38119 38138 38140 38171 38173 38175 38177 38182 38184 38194 38196 38204 38206 38210 38212 38215 38217 38218 38220 38228 38230 38233 38235 38239 38241 38253 38255 38259 38262 38263 38266 38269 38271 38272 38274 38275 38278 38278 38280 38281 38283 38292 38296 38296 38299 38300 38302 38303 38305 38305 38307 38309 38312 38313 38315 38318 38320 38321 38325 38327 38329 38336 38339 38339 38341 38349 38352 38358 38362 38364 38366 38373 38376 38379 38381 38398 38400 38406 38408 38418 38420 38423 38425 38426 38428 38436 38440 38440 38442 38442 38444 38454 38457 38461 38463 38464 38466 38481 38483 38485 38488 38488 38491 38495 38497 38500 38503 38509 38511 38520 38524 38526 38528 38528 38531 38539 38541 38549 38551 38553 38555 38556 38558 38558 38561 38562 38564 38564 38567 38570 38572 38572 38574 38574 38576 38577 38579 38580 38582 38582 38584 38585 38587 38607 38610 38627 38629 38629 38632 38634 38639 38643 38645 38651 38653 38658 38660 38665 38667 38667 38669 38675 38678 38678 38680 38681 38684 38688 38690 38704 38706 38706 38709 38709 38712 38714 38717 38719 38722 38724 38726 38729 38731 38731 38738 38739 38742 38742 38744 38748 38750 38750 38752 38754 38757 38758 38760 38762 38764 38764 38766 38766 38768 38768 38770 38772 38774 38776 38778 38789 38792 38792 38794 38795 38797 38799 38801 38802 38804 38804 38807 38810 38812 38814 38816 38822 38824 38824 38826 38831 38834 38836 38838 38839 38841 38841 38843 38843 38847 38847 38849 38849 38851 38855 38857 38857 38859 38864 38867 38873 38876 38879 38881 38881 38883 38883 38885 38887 38889 38893 38896 38897 38899 38899 38901 38902 38904 38907 38909 38920 38922 38922 38924 38931 38934 38936 38939 38942 38944 38945 38948 38948 38950 38953 38955 38955 38957 38957 38959 38960 38962 38962 38965 38965 38967 38969 38971 38971 38977 38977 38979 38982 38984 38986 38988 38995 38999 39001 39003 39008 39010 39013 39015 39015 39017 39019 39023 39050 39052 39053 39055 39057 39059 39060 39062 39064 39066 39074 39076 39081 39084 39087 39089 39091 39094 39094 39096 39096 39098 39106 39108 39108 39110 39110 39113 39113 39115 39116 39118 39118 39121 39123 39125 39125 39128 39131 39134 39135 39138 39139 39141 39141 39143 39147 39149 39149 39151 39151 39154 39154 39156 39156 39158 39158 39161 39162 39164 39166 39168 39168 39170 39171 39173 39173 39175 39178 39180 39181 39184 39192 39194 39195 39198 39199 39201 39201 39204 39205 39207 39219 39221 39221 39226 39226 39228 39231 39233 39233 39235 39235 39237 39237 39239 39241 39243 39244 39246 39246 39248 39257 39259 39260 39262 39263 39265 39265 39267 39267 39269 39269 39271 39282 39284 39287 39290 39290 39292 39293 39295 39297 39300 39304 39306 39307 39309 39309 39311 39321 39324 39326 39329 39329 39331 39331 39333 39336 39339 39349 39353 39355 39357 39357 39361 39363 39367 39367 39369 39369 39371 39385 39387 39389 39391 39391 39394 39397 39399 39399 39401 39402 39404 39406 39408 39409 39412 39412 39414 39423 39425 39431 39433 39435 39437 39439 39441 39441 39444 39446 39449 39454 39456 39456 39458 39461 39463 39463 39465 39470 39472 39474 39476 39482 39485 39494 39496 39498 39500 39504 39506 39511 39513 39515 39518 39520 39522 39522 39524 39537 39539 39554 39556 39560 39562 39564 39567 39571 39574 39576 39578 39589 39591 39592 39595 39595 39597 39597 39599 39601 39603 39604 39606 39612 39614 39618 39621 39623 39626 39629 39631 39638 39640 39640 39644 39644 39647 39647 39649 39649 39651 39651 39654 39655 39659 39663 39665 39667 39670 39671 39673 39678 39681 39681 39683 39686 39688 39688 39690 39699 39701 39706 39710 39712 39714 39717 39719 39721 39723 39723 39726 39727 39729 39731 39733 39733 39735 39735 39738 39740 39742 39743 39745 39759 39761 39762 39764 39766 39768 39771 39775 39777 39780 39780 39782 39784 39788 39788 39791 39793 39796 39799 39802 39806 39808 39808 39810 39810 39813 39816 39824 39827 39829 39829 39834 39835 39838 39838 39840 39842 39844 39846 39848 39848 39850 39851 39853 39855 39861 39862 39864 39865 39869 39869 39871 39873 39875 39876 39878 39882 39891 39895 39897 39900 39902 39902 39904 39906 39908 39912 39914 39916 39920 39920 39927 39928 39933 39933 39941 39945 39947 39947 39949 39950 39954 39956 39959 39959 39964 39965 39969 39969 39971 39973 39976 39977 39979 39981 39985 39988 39990 39991 39993 39993 39995 40001 40004 40004 40006 40006 40008 40014 40016 40016 40018 40018 40020 40025 40030 40032 40034 40035 40038 40040 40045 40046 40049 40049 40051 40053 40055 40058 40060 40060 40063 40063 40065 40066 40069 40072 40075 40075 40077 40078 40080 40082 40084 40085 40090 40092 40094 40105 40107 40107 40109 40110 40112 40120 40122 40125 40131 40135 40138 40144 40147 40153 40156 40159 40162 40162 40165 40167 40169 40170 40173 40173 40177 40183 40185 40189 40191 40192 40195 40201 40208 40208 40210 40210 40212 40213 40215 40217 40219 40219 40221 40224 40226 40227 40229 40230 40232 40233 40237 40241 40243 40243 40246 40248 40251 40251 40253 40259 40261 40261 40266 40268 40271 40271 40273 40276 40278 40285 40287 40289 40295 40300 40303 40309 40311 40313 40315 40315 40317 40317 40319 40322 40324 40332 40336 40336 40338 40338 40340 40340 40342 40356 40358 40362 40364 40365 40367 40367 40369 40380 40382 40383 40385 40387 40389 40389 40391 40392 40394 40403 40405 40415 40417 40422 40424 40425 40427 40432 40434 40443 40445 40455 40457 40457 40459 40459 40461 40461 40463 40469 40471 40471 40473 40475 40477 40483 40485 40486 40488 40493 40495 40495 40497 40499 40501 40506 40509 40511 40513 40524 40526 40527 40529 40529 40533 40533 40535 40536 40538 40540 40542 40542 40547 40548 40550 40557 40560 40561 40563 40563 40565 40565 40569 40570 40572 40576 40578 40579 40582 40590 40593 40596 40599 40599 40601 40605 40607 40609 40612 40615 40617 40617 40621 40622 40624 40624 40628 40632 40635 40638 40640 40640 40642 40644 40648 40649 40652 40657 40659 40662 40664 40664 40666 40672 40674 40674 40676 40683 40685 40688 40690 40695 40697 40705 40710 40711 40713 40715 40717 40720 40722 40723 40725 40732 40734 40734 40736 40736 40738 40741 40744 40761 40763 40763 40765 40766 40768 40772 40774 40786 40788 40793 40795 40801 40803 40807 40810 40812 40814 40818 40820 40827 40830 40832 40835 40845 40848 40850 40852 40853 40856 40860 40863 40864 40866 40866 40868 40868 65072 65074 65077 65092 65097 65102 65104 65106 65108 65111 65113 65126 65128 65131 65281 65374 65504 65505 65507 65507 65509 65509 917504 917631)) (make-character-set :mib-enum 2254 :name "windows-1254" :aliases 'nil :mime-encoding 'nil :source '"Microsoft (http://www.iana.org/assignments/charset-reg/windows-1254) [Lazhintseva]" :comments 'nil :references 'nil :ranges #(0 127 160 207 209 220 223 239 241 252 255 255 286 287 304 305 338 339 350 353 376 376 402 402 710 710 732 732 8211 8212 8216 8218 8220 8222 8224 8226 8230 8230 8240 8240 8249 8250 8364 8364 8482 8482)) (make-character-set :mib-enum 2255 :name "windows-1255" :aliases 'nil :mime-encoding 'nil :source '"Microsoft (http://www.iana.org/assignments/charset-reg/windows-1255) [Lazhintseva]" :comments 'nil :references 'nil :ranges #(0 127 160 163 165 169 171 185 187 191 215 215 247 247 402 402 710 710 732 732 1456 1465 1467 1475 1488 1514 1520 1524 8206 8207 8211 8212 8216 8218 8220 8222 8224 8226 8230 8230 8240 8240 8249 8250 8362 8362 8364 8364 8482 8482 64285 64285 64287 64287 64298 64310 64312 64316 64318 64318 64320 64321 64323 64324 64326 64334 917504 917631)) (make-character-set :mib-enum 2027 :name "macintosh" :aliases '("csMacintosh" "mac") :mime-encoding 'nil :source '"The Unicode Standard ver1.0, ISBN 0-201-56788-1, Oct 1991" :comments 'nil :references '("[RFC1345,KXS2]") :ranges #(0 127 160 165 167 172 174 177 180 184 186 187 191 207 209 214 216 220 223 239 241 252 255 255 305 305 338 339 376 376 402 402 710 711 728 733 960 960 8211 8212 8216 8218 8220 8222 8224 8226 8230 8230 8240 8240 8249 8250 8260 8260 8482 8482 8486 8486 8706 8706 8710 8710 8719 8719 8721 8721 8730 8730 8734 8734 8747 8747 8776 8776 8800 8800 8804 8805 9674 9674 64257 64258)) (make-character-set :mib-enum 18 :name "Extended_UNIX_Code_Packed_Format_for_Japanese" :aliases '(#18="EUC-JP" "csEUCPkdFmtJapanese") :mime-encoding '#18# :source '"Standardized by OSF, UNIX International, and UNIX Systems Laboratories Pacific. Uses ISO 2022 rules to select code set 0: US-ASCII (a single 7-bit byte set) code set 1: JIS X0208-1990 (a double 8-bit byte set) restricted to A0-FF in both bytes code set 2: Half Width Katakana (a single 7-bit byte set) requiring SS2 as the character prefix code set 3: JIS X0212-1990 (a double 7-bit byte set) restricted to A0-FF in both bytes requiring SS3 as the character prefix" :comments '("Alias: EUC-JP (preferred MIME name)") :references 'nil :ranges #(0 141 144 159 161 170 172 172 174 177 180 180 182 182 184 184 186 186 191 207 209 275 278 290 292 299 302 333 336 382 461 476 501 501 711 711 728 731 733 733 900 902 904 906 908 908 910 929 931 974 1025 1036 1038 1103 1105 1116 1118 1119 8208 8208 8213 8214 8216 8217 8220 8221 8224 8225 8229 8230 8240 8240 8242 8243 8251 8251 8254 8254 8451 8451 8470 8470 8482 8482 8491 8491 8592 8595 8658 8658 8660 8660 8704 8704 8706 8707 8711 8712 8715 8715 8722 8722 8730 8730 8733 8734 8736 8736 8743 8748 8756 8757 8765 8765 8786 8786 8800 8801 8806 8807 8810 8811 8834 8835 8838 8839 8869 8869 8978 8978 9472 9475 9484 9484 9487 9488 9491 9492 9495 9496 9499 9501 9504 9504 9507 9509 9512 9512 9515 9516 9519 9520 9523 9524 9527 9528 9531 9532 9535 9535 9538 9538 9547 9547 9632 9633 9650 9651 9660 9661 9670 9671 9675 9675 9678 9679 9711 9711 9733 9734 9792 9792 9794 9794 9834 9834 9837 9837 9839 9839 12288 12291 12293 12309 12316 12316 12353 12435 12443 12446 12449 12534 12539 12542 19968 19973 19975 19982 19984 19986 19988 19993 19998 19999 20001 20001 20003 20004 20006 20006 20008 20008 20010 20011 20013 20018 20021 20022 20024 20025 20027 20028 20031 20037 20039 20039 20043 20043 20045 20047 20049 20049 20053 20058 20060 20063 20066 20067 20072 20073 20081 20081 20083 20085 20089 20089 20094 20096 20098 20098 20101 20102 20104 20110 20113 20114 20116 20121 20123 20130 20132 20134 20136 20136 20139 20144 20147 20147 20150 20150 20153 20154 20160 20164 20166 20167 20170 20171 20173 20176 20180 20187 20189 20197 20200 20200 20205 20211 20213 20215 20219 20219 20221 20227 20232 20242 20245 20247 20249 20250 20252 20253 20270 20273 20275 20286 20288 20288 20290 20291 20294 20297 20299 20320 20323 20323 20329 20330 20332 20332 20334 20337 20339 20339 20341 20351 20353 20358 20360 20372 20374 20379 20381 20385 20395 20395 20397 20399 20402 20402 20405 20407 20409 20409 20411 20422 20424 20434 20436 20436 20439 20440 20442 20445 20447 20453 20462 20464 20466 20467 20469 20470 20472 20472 20474 20474 20476 20481 20484 20487 20489 20500 20502 20511 20513 20526 20528 20528 20530 20531 20533 20534 20537 20537 20539 20539 20544 20547 20549 20554 20556 20556 20558 20563 20565 20567 20569 20570 20572 20572 20575 20576 20578 20579 20581 20583 20586 20586 20588 20589 20592 20594 20596 20598 20600 20600 20605 20605 20608 20609 20611 20614 20618 20618 20621 20628 20630 20630 20632 20636 20638 20642 20650 20650 20652 20653 20655 20656 20658 20661 20663 20663 20665 20666 20669 20670 20672 20672 20674 20677 20679 20679 20681 20682 20684 20689 20691 20694 20696 20696 20698 20698 20700 20703 20706 20713 20717 20719 20721 20722 20725 20726 20729 20731 20734 20734 20736 20740 20742 20745 20747 20750 20752 20752 20754 20754 20756 20767 20769 20769 20771 20771 20775 20776 20778 20778 20780 20781 20783 20783 20785 20789 20791 20796 20799 20816 20818 20821 20823 20824 20826 20826 20828 20828 20831 20831 20834 20834 20836 20838 20840 20846 20849 20849 20853 20856 20860 20860 20862 20862 20864 20864 20866 20870 20873 20883 20885 20889 20893 20893 20896 20902 20904 20909 20912 20920 20922 20922 20924 20927 20930 20930 20932 20934 20936 20937 20939 20941 20943 20943 20945 20947 20949 20950 20952 20952 20955 20958 20960 20962 20965 20967 20969 20970 20973 20974 20976 20986 20989 20990 20992 21000 21002 21003 21006 21006 21009 21016 21021 21021 21026 21026 21028 21029 21031 21034 21038 21038 21040 21043 21045 21052 21059 21061 21063 21063 21065 21069 21071 21071 21076 21080 21082 21084 21086 21089 21091 21094 21097 21098 21102 21109 21111 21113 21117 21117 21119 21120 21122 21123 21125 21125 21127 21130 21132 21133 21137 21144 21146 21148 21151 21152 21155 21159 21161 21165 21167 21169 21172 21182 21184 21185 21187 21193 21196 21197 21199 21199 21201 21202 21204 21209 21211 21226 21228 21228 21232 21242 21246 21251 21253 21254 21256 21256 21258 21261 21263 21265 21267 21267 21269 21281 21283 21283 21285 21285 21287 21293 21295 21299 21301 21301 21304 21315 21317 21325 21329 21332 21335 21340 21342 21342 21344 21345 21347 21347 21349 21350 21353 21353 21356 21365 21367 21369 21371 21371 21374 21375 21378 21380 21383 21384 21390 21390 21395 21396 21398 21398 21400 21402 21405 21405 21407 21409 21412 21414 21416 21419 21421 21424 21426 21432 21434 21435 21437 21437 21440 21440 21442 21443 21445 21445 21448 21455 21458 21463 21465 21467 21469 21491 21493 21496 21498 21498 21505 21508 21512 21521 21523 21523 21530 21531 21533 21533 21535 21537 21542 21551 21553 21553 21556 21558 21560 21561 21563 21566 21568 21568 21570 21572 21574 21578 21581 21583 21585 21585 21598 21599 21602 21602 21604 21604 21606 21611 21613 21614 21616 21617 21619 21623 21627 21629 21631 21633 21635 21638 21640 21641 21643 21650 21653 21654 21660 21660 21663 21663 21665 21666 21668 21679 21681 21683 21687 21698 21700 21700 21702 21706 21709 21710 21720 21720 21728 21730 21733 21734 21736 21738 21740 21743 21746 21746 21750 21750 21754 21754 21756 21761 21764 21769 21772 21776 21780 21782 21802 21803 21806 21807 21809 21811 21813 21814 21816 21817 21819 21822 21824 21825 21828 21831 21833 21834 21836 21837 21839 21841 21843 21843 21846 21848 21850 21854 21856 21857 21859 21860 21862 21862 21883 21884 21886 21892 21894 21899 21902 21903 21905 21908 21911 21914 21916 21919 21923 21924 21927 21934 21936 21936 21938 21938 21942 21942 21951 21951 21953 21953 21955 21959 21961 21961 21963 21964 21966 21966 21969 21972 21975 21976 21978 21980 21982 21983 21986 21988 21993 21993 22006 22007 22009 22009 22013 22015 22021 22022 22024 22026 22029 22034 22036 22036 22038 22041 22043 22043 22057 22057 22060 22060 22063 22073 22075 22077 22079 22084 22086 22086 22089 22089 22091 22096 22100 22100 22107 22107 22110 22110 22112 22116 22118 22118 22120 22125 22127 22127 22129 22130 22132 22133 22136 22136 22138 22138 22144 22144 22148 22152 22154 22156 22159 22159 22164 22165 22169 22170 22173 22176 22178 22178 22181 22185 22187 22190 22193 22193 22195 22196 22198 22199 22204 22204 22206 22206 22208 22211 22213 22213 22216 22225 22227 22227 22231 22241 22243 22248 22251 22251 22253 22254 22256 22259 22262 22263 22265 22266 22269 22269 22271 22276 22279 22285 22287 22287 22289 22291 22293 22294 22296 22296 22298 22301 22303 22304 22306 22314 22316 22320 22323 22324 22327 22328 22331 22331 22333 22336 22338 22338 22341 22343 22346 22346 22348 22354 22369 22370 22372 22379 22381 22385 22387 22389 22391 22391 22393 22396 22398 22399 22401 22403 22408 22409 22411 22412 22419 22421 22423 22423 22425 22426 22428 22436 22439 22442 22444 22444 22448 22448 22451 22451 22456 22456 22461 22461 22464 22464 22467 22467 22470 22472 22475 22476 22478 22479 22482 22486 22492 22497 22499 22500 22502 22503 22505 22505 22509 22509 22512 22512 22516 22522 22524 22528 22530 22534 22536 22541 22549 22549 22553 22553 22555 22555 22557 22561 22564 22564 22566 22567 22570 22570 22573 22573 22575 22578 22580 22581 22585 22586 22589 22589 22591 22593 22601 22605 22607 22610 22612 22613 22615 22618 22622 22623 22625 22626 22628 22628 22631 22633 22635 22635 22640 22640 22642 22642 22645 22645 22648 22649 22652 22652 22654 22657 22659 22659 22661 22661 22663 22666 22668 22669 22671 22672 22675 22676 22678 22679 22684 22685 22687 22690 22694 22694 22696 22697 22699 22699 22702 22702 22705 22707 22712 22716 22718 22718 22721 22722 22724 22725 22727 22728 22730 22730 22732 22734 22736 22746 22748 22751 22753 22754 22756 22757 22761 22761 22763 22764 22766 22771 22775 22775 22777 22781 22786 22786 22789 22790 22793 22796 22799 22800 22802 22806 22808 22813 22817 22821 22823 22835 22837 22840 22846 22847 22851 22852 22854 22857 22862 22869 22871 22875 22877 22883 22885 22885 22887 22895 22898 22902 22904 22905 22907 22909 22913 22916 22922 22926 22930 22931 22933 22935 22937 22937 22939 22939 22941 22941 22943 22943 22947 22949 22951 22952 22956 22960 22962 22963 22967 22967 22969 22972 22974 22974 22977 22977 22979 22980 22982 22982 22984 22987 22989 22989 22992 22996 23001 23002 23004 23007 23011 23016 23018 23019 23022 23023 23025 23026 23028 23028 23030 23031 23035 23035 23039 23041 23043 23044 23049 23049 23052 23054 23057 23059 23064 23064 23066 23066 23068 23068 23070 23072 23075 23077 23079 23082 23085 23085 23087 23088 23093 23094 23100 23100 23104 23105 23108 23113 23116 23116 23120 23120 23125 23125 23130 23130 23134 23134 23138 23139 23141 23143 23146 23146 23148 23149 23159 23159 23162 23163 23166 23167 23179 23179 23184 23184 23186 23187 23190 23190 23193 23196 23198 23200 23202 23202 23207 23207 23212 23212 23217 23219 23221 23221 23224 23224 23226 23231 23233 23234 23236 23236 23238 23238 23240 23241 23243 23244 23247 23248 23254 23255 23258 23258 23260 23260 23264 23265 23267 23267 23269 23270 23273 23274 23278 23278 23285 23286 23290 23291 23293 23293 23296 23297 23304 23305 23307 23308 23318 23319 23321 23321 23323 23323 23325 23325 23329 23330 23333 23333 23338 23338 23340 23341 23344 23344 23346 23346 23348 23348 23350 23350 23352 23352 23358 23358 23360 23361 23363 23363 23365 23365 23371 23372 23376 23378 23380 23384 23386 23391 23395 23398 23400 23401 23403 23403 23406 23409 23411 23411 23413 23413 23416 23416 23418 23418 23420 23425 23427 23441 23443 23453 23455 23455 23458 23462 23464 23465 23468 23482 23484 23484 23487 23495 23497 23497 23500 23501 23503 23504 23506 23508 23510 23515 23517 23522 23524 23529 23531 23531 23534 23537 23539 23542 23544 23544 23546 23546 23549 23551 23553 23554 23556 23567 23569 23569 23571 23571 23574 23575 23578 23578 23582 23584 23586 23588 23590 23590 23592 23593 23595 23598 23600 23602 23605 23606 23608 23617 23621 23622 23624 23624 23626 23627 23629 23633 23635 23635 23637 23637 23641 23642 23644 23644 23646 23646 23648 23653 23655 23657 23660 23665 23668 23670 23673 23677 23687 23688 23690 23690 23692 23692 23695 23698 23700 23700 23709 23709 23711 23715 23718 23718 23720 23724 23729 23736 23738 23740 23742 23742 23749 23749 23751 23751 23753 23753 23755 23755 23762 23762 23767 23767 23769 23769 23773 23773 23776 23777 23784 23786 23789 23794 23796 23796 23798 23798 23802 23803 23805 23805 23809 23809 23814 23815 23819 23819 23821 23822 23825 23826 23828 23835 23839 23839 23842 23844 23846 23847 23849 23849 23851 23851 23857 23857 23860 23860 23865 23865 23869 23869 23871 23871 23874 23875 23878 23878 23880 23880 23882 23884 23886 23886 23888 23890 23893 23893 23897 23897 23900 23900 23903 23906 23908 23908 23913 23914 23916 23917 23919 23920 23923 23923 23926 23926 23929 23930 23934 23935 23937 23940 23943 23944 23946 23948 23952 23952 23954 23957 23961 23961 23963 23963 23965 23965 23967 23968 23970 23970 23975 23975 23979 23980 23982 23982 23984 23984 23986 23986 23988 23988 23991 23994 23996 23997 24003 24003 24007 24007 24009 24009 24011 24014 24016 24016 24018 24019 24022 24022 24024 24025 24027 24027 24029 24030 24032 24033 24035 24041 24043 24043 24046 24046 24049 24053 24055 24057 24059 24059 24061 24062 24064 24064 24066 24067 24070 24071 24075 24077 24081 24082 24084 24086 24088 24091 24093 24093 24095 24096 24101 24101 24104 24104 24107 24107 24109 24112 24114 24115 24117 24120 24125 24126 24128 24128 24131 24133 24135 24135 24137 24137 24139 24140 24142 24142 24144 24145 24148 24152 24155 24156 24158 24159 24161 24164 24168 24168 24170 24174 24176 24176 24178 24182 24184 24193 24195 24196 24199 24199 24202 24203 24206 24207 24213 24215 24218 24218 24220 24220 24224 24224 24226 24226 24228 24232 24234 24237 24241 24241 24243 24243 24245 24248 24253 24255 24257 24259 24262 24262 24264 24268 24270 24278 24282 24291 24293 24293 24296 24297 24299 24300 24304 24305 24307 24308 24310 24312 24314 24316 24318 24319 24321 24324 24326 24337 24339 24345 24347 24349 24351 24351 24353 24361 24363 24369 24372 24376 24379 24385 24388 24389 24391 24392 24394 24394 24396 24398 24400 24401 24403 24404 24406 24409 24411 24413 24416 24420 24422 24423 24425 24429 24431 24437 24439 24442 24444 24453 24455 24461 24463 24467 24470 24473 24476 24478 24480 24482 24484 24484 24487 24497 24499 24500 24504 24505 24508 24509 24515 24517 24519 24521 24523 24525 24528 24532 24534 24537 24540 24542 24544 24546 24548 24548 24552 24563 24565 24566 24568 24568 24570 24573 24575 24575 24583 24583 24586 24586 24589 24592 24594 24605 24607 24609 24612 24619 24621 24621 24623 24623 24625 24625 24627 24627 24629 24629 24634 24634 24640 24643 24646 24653 24656 24658 24660 24663 24665 24666 24669 24669 24671 24677 24679 24685 24687 24689 24693 24693 24695 24695 24702 24703 24705 24708 24710 24710 24712 24718 24721 24728 24730 24731 24733 24736 24738 24746 24752 24760 24763 24766 24770 24770 24772 24779 24782 24783 24785 24785 24787 24789 24792 24803 24805 24805 24807 24808 24816 24829 24832 24835 24838 24842 24844 24855 24857 24860 24862 24863 24865 24866 24871 24872 24874 24876 24880 24881 24884 24887 24889 24889 24892 24895 24897 24898 24900 24910 24915 24915 24917 24917 24920 24922 24925 24928 24930 24931 24933 24933 24935 24936 24939 24940 24942 24952 24955 24956 24958 24964 24967 24967 24970 24971 24973 24974 24976 24980 24982 24986 24988 24989 24991 24992 24996 24997 24999 25006 25010 25010 25014 25014 25016 25018 25020 25020 25022 25022 25024 25027 25030 25040 25045 25045 25052 25055 25057 25059 25061 25063 25065 25065 25068 25069 25071 25071 25074 25074 25076 25076 25078 25080 25082 25082 25084 25089 25091 25092 25095 25098 25100 25102 25104 25110 25114 25123 25126 25127 25129 25131 25134 25136 25138 25140 25144 25145 25147 25147 25149 25149 25151 25156 25158 25161 25163 25166 25168 25174 25176 25176 25178 25180 25182 25182 25184 25184 25187 25188 25192 25192 25197 25199 25201 25201 25203 25203 25206 25206 25209 25210 25212 25216 25218 25220 25225 25226 25229 25240 25243 25244 25246 25246 25254 25254 25256 25256 25259 25260 25265 25265 25267 25267 25269 25271 25273 25279 25282 25282 25284 25290 25292 25309 25312 25313 25322 25322 25324 25327 25329 25335 25340 25343 25345 25348 25351 25357 25360 25361 25363 25363 25366 25366 25368 25369 25375 25375 25383 25387 25389 25389 25391 25391 25397 25398 25401 25402 25404 25407 25409 25412 25414 25414 25417 25424 25426 25429 25431 25432 25435 25436 25445 25449 25451 25454 25457 25458 25460 25464 25466 25469 25471 25472 25474 25476 25479 25482 25484 25484 25486 25488 25490 25490 25492 25494 25496 25499 25502 25519 25522 25522 25524 25525 25531 25531 25533 25534 25536 25537 25539 25542 25544 25545 25550 25558 25562 25564 25568 25569 25571 25571 25573 25573 25577 25578 25580 25580 25582 25582 25586 25590 25592 25594 25606 25606 25609 25610 25613 25613 25615 25616 25618 25620 25622 25624 25628 25628 25630 25630 25632 25632 25634 25634 25636 25638 25640 25642 25644 25645 25647 25648 25652 25654 25658 25658 25661 25663 25666 25666 25675 25675 25678 25679 25681 25684 25688 25688 25690 25693 25695 25697 25699 25699 25703 25703 25705 25705 25709 25709 25711 25711 25715 25716 25718 25718 25720 25720 25722 25723 25725 25725 25731 25731 25733 25733 25735 25736 25743 25747 25749 25749 25752 25755 25757 25759 25761 25761 25763 25766 25768 25769 25771 25774 25776 25776 25778 25779 25785 25785 25787 25791 25793 25794 25796 25797 25799 25799 25801 25806 25808 25810 25812 25813 25815 25816 25818 25818 25824 25831 25833 25834 25836 25837 25839 25842 25844 25847 25850 25851 25853 25857 25860 25861 25864 25866 25871 25871 25875 25876 25878 25878 25880 25881 25883 25887 25890 25892 25894 25894 25897 25900 25902 25903 25905 25905 25908 25919 25923 25923 25925 25925 25927 25929 25933 25933 25935 25938 25940 25945 25949 25952 25954 25955 25958 25959 25963 25964 25968 25968 25970 25970 25972 25973 25975 25976 25978 25978 25981 25981 25985 25987 25989 25989 25991 25994 25996 25996 25998 25998 26000 26002 26005 26005 26007 26009 26011 26013 26015 26017 26019 26023 26027 26032 26034 26036 26039 26039 26041 26041 26044 26045 26047 26047 26049 26054 26056 26057 26059 26060 26062 26064 26066 26066 26068 26068 26070 26073 26075 26075 26079 26082 26085 26089 26092 26093 26096 26098 26100 26101 26105 26107 26110 26112 26114 26116 26118 26122 26124 26127 26129 26134 26140 26161 26163 26167 26169 26169 26172 26172 26175 26182 26185 26188 26190 26191 26193 26194 26199 26201 26203 26210 26212 26212 26214 26220 26222 26224 26227 26236 26238 26241 26243 26244 26247 26249 26251 26254 26256 26258 26262 26269 26271 26272 26274 26274 26276 26276 26278 26278 26283 26283 26285 26286 26289 26290 26292 26293 26296 26297 26299 26300 26302 26308 26311 26313 26316 26316 26318 26319 26324 26324 26326 26326 26329 26333 26335 26336 26342 26342 26344 26345 26347 26348 26350 26350 26352 26352 26354 26357 26359 26368 26371 26371 26373 26373 26375 26377 26379 26379 26381 26383 26387 26391 26393 26393 26395 26400 26402 26402 26406 26408 26410 26414 26417 26417 26419 26420 26422 26424 26426 26426 26429 26431 26433 26433 26437 26441 26444 26444 26446 26449 26451 26454 26457 26457 26460 26470 26474 26474 26476 26487 26491 26492 26494 26495 26497 26497 26500 26501 26503 26503 26505 26505 26507 26508 26510 26513 26515 26515 26517 26525 26528 26530 26534 26534 26537 26537 26543 26553 26555 26557 26560 26566 26568 26570 26574 26580 26583 26586 26588 26590 26593 26594 26596 26596 26598 26599 26601 26601 26604 26604 26606 26615 26617 26617 26619 26619 26622 26623 26626 26628 26643 26644 26646 26647 26649 26649 26653 26655 26657 26658 26663 26669 26671 26676 26680 26681 26683 26685 26687 26694 26696 26696 26698 26698 26700 26702 26704 26709 26711 26713 26715 26717 26719 26719 26723 26723 26727 26727 26731 26731 26734 26738 26740 26743 26745 26748 26750 26751 26753 26758 26760 26760 26765 26765 26767 26767 26771 26772 26774 26776 26778 26781 26783 26787 26789 26794 26797 26803 26805 26806 26809 26812 26820 26822 26824 26829 26831 26842 26844 26845 26847 26849 26851 26851 26853 26853 26855 26856 26858 26866 26869 26870 26873 26877 26880 26881 26884 26886 26888 26899 26902 26903 26905 26908 26913 26915 26917 26918 26920 26920 26922 26922 26928 26929 26931 26934 26936 26937 26939 26939 26941 26941 26943 26943 26946 26946 26949 26949 26953 26954 26958 26958 26963 26965 26967 26967 26969 26974 26976 26982 26984 26997 26999 27010 27018 27018 27021 27022 27025 27026 27028 27030 27032 27032 27035 27036 27040 27041 27045 27048 27051 27051 27053 27055 27057 27058 27060 27060 27063 27064 27066 27068 27070 27071 27073 27073 27075 27075 27077 27077 27079 27080 27082 27086 27088 27089 27091 27091 27094 27097 27101 27102 27106 27106 27109 27109 27111 27112 27115 27115 27117 27119 27121 27123 27125 27125 27129 27129 27131 27131 27133 27139 27141 27141 27146 27148 27151 27151 27153 27157 27159 27159 27161 27163 27165 27172 27176 27179 27182 27182 27184 27184 27186 27186 27188 27195 27197 27199 27204 27211 27214 27214 27216 27218 27221 27222 27224 27225 27227 27227 27231 27231 27233 27234 27236 27236 27238 27239 27242 27242 27249 27251 27256 27256 27262 27265 27267 27268 27270 27271 27273 27273 27275 27275 27277 27278 27280 27281 27287 27287 27291 27296 27298 27299 27301 27301 27306 27308 27310 27313 27315 27316 27320 27320 27323 27323 27325 27327 27329 27331 27334 27334 27336 27337 27340 27340 27344 27345 27347 27350 27354 27359 27364 27364 27367 27368 27370 27370 27372 27372 27376 27378 27386 27389 27394 27399 27401 27402 27407 27410 27414 27415 27419 27419 27421 27425 27427 27428 27431 27432 27435 27436 27439 27439 27442 27442 27445 27451 27453 27455 27459 27459 27462 27463 27465 27466 27468 27470 27472 27472 27474 27476 27478 27478 27480 27481 27483 27483 27485 27485 27487 27492 27494 27495 27497 27499 27502 27504 27507 27509 27512 27513 27515 27515 27517 27520 27522 27526 27529 27531 27533 27533 27541 27544 27547 27547 27550 27552 27554 27556 27560 27573 27575 27584 27587 27590 27593 27593 27595 27598 27602 27604 27606 27606 27608 27608 27610 27611 27615 27615 27617 27617 27619 27619 27622 27623 27627 27628 27630 27631 27633 27633 27635 27635 27639 27639 27641 27641 27647 27647 27650 27650 27652 27653 27656 27657 27661 27668 27671 27671 27673 27673 27675 27675 27679 27679 27683 27684 27686 27688 27692 27692 27694 27694 27699 27704 27706 27707 27710 27714 27722 27723 27725 27728 27730 27730 27732 27733 27735 27735 27737 27744 27746 27746 27751 27752 27754 27755 27757 27757 27759 27760 27762 27764 27766 27766 27768 27771 27773 27774 27777 27779 27781 27785 27788 27789 27792 27792 27794 27804 27807 27807 27809 27810 27819 27819 27822 27822 27824 27828 27832 27839 27841 27842 27844 27846 27849 27850 27852 27853 27855 27863 27865 27869 27872 27875 27877 27877 27879 27884 27886 27892 27908 27908 27911 27911 27914 27916 27918 27919 27921 27923 27927 27927 27929 27931 27934 27935 27941 27947 27950 27951 27953 27955 27957 27958 27960 27961 27963 27967 27969 27969 27972 27973 27991 27991 27993 27994 27996 27996 27998 27999 28001 28001 28003 28007 28009 28010 28012 28012 28014 28016 28020 28020 28023 28025 28028 28028 28034 28034 28037 28037 28039 28040 28044 28044 28046 28046 28049 28057 28059 28060 28074 28074 28076 28076 28079 28079 28082 28082 28084 28085 28087 28089 28092 28093 28095 28096 28100 28104 28106 28108 28110 28111 28113 28114 28117 28118 28120 28121 28123 28123 28125 28130 28132 28134 28136 28140 28142 28145 28147 28151 28153 28156 28160 28160 28164 28165 28167 28171 28179 28179 28181 28181 28185 28187 28189 28199 28201 28201 28203 28207 28210 28210 28214 28214 28216 28220 28222 28222 28227 28229 28232 28235 28237 28239 28241 28244 28246 28248 28251 28255 28258 28259 28263 28264 28267 28267 28270 28271 28274 28275 28278 28278 28283 28283 28285 28288 28290 28290 28300 28301 28303 28304 28307 28307 28310 28310 28312 28313 28316 28317 28319 28320 28322 28322 28325 28325 28327 28327 28330 28330 28333 28335 28337 28339 28342 28343 28346 28347 28349 28349 28351 28357 28359 28367 28369 28369 28371 28373 28381 28382 28395 28399 28402 28402 28404 28404 28407 28409 28411 28411 28413 28415 28417 28418 28420 28420 28422 28422 28424 28426 28428 28429 28431 28431 28433 28433 28435 28438 28440 28440 28442 28443 28448 28448 28450 28451 28454 28454 28457 28461 28463 28467 28470 28470 28472 28472 28475 28476 28478 28479 28481 28481 28485 28485 28495 28495 28497 28500 28503 28511 28513 28514 28516 28516 28518 28518 28520 28520 28524 28528 28532 28532 28536 28536 28538 28538 28540 28542 28544 28548 28550 28552 28555 28558 28560 28564 28566 28567 28570 28570 28575 28577 28579 28584 28586 28586 28590 28593 28595 28595 28597 28598 28601 28601 28604 28604 28608 28611 28613 28616 28618 28618 28628 28629 28632 28632 28634 28635 28638 28641 28644 28644 28648 28649 28651 28652 28654 28657 28659 28659 28661 28662 28665 28666 28668 28670 28672 28673 28677 28679 28681 28681 28683 28683 28685 28685 28687 28687 28689 28689 28693 28693 28695 28696 28698 28699 28701 28704 28707 28707 28710 28711 28716 28716 28719 28720 28722 28722 28724 28724 28727 28727 28729 28729 28732 28732 28734 28734 28739 28740 28744 28748 28750 28750 28753 28753 28756 28757 28760 28760 28765 28766 28771 28773 28779 28780 28782 28784 28789 28790 28792 28792 28796 28798 28801 28801 28805 28806 28809 28810 28814 28814 28818 28818 28820 28825 28827 28827 28836 28836 28843 28849 28851 28852 28855 28858 28872 28872 28874 28875 28879 28879 28881 28881 28883 28886 28888 28889 28892 28893 28895 28895 28900 28900 28913 28913 28921 28922 28925 28925 28931 28935 28937 28937 28939 28940 28943 28943 28948 28948 28953 28954 28956 28956 28958 28958 28960 28961 28966 28966 28971 28971 28973 28973 28975 28977 28982 28982 28984 28984 28988 28988 28993 28993 28997 28999 29001 29004 29006 29006 29008 29008 29010 29010 29013 29015 29017 29018 29020 29020 29022 29022 29024 29024 29026 29026 29028 29033 29036 29036 29038 29038 29049 29049 29053 29053 29056 29056 29060 29061 29063 29064 29066 29066 29068 29068 29071 29071 29074 29074 29076 29077 29081 29083 29087 29088 29090 29090 29096 29096 29100 29100 29103 29107 29113 29114 29118 29121 29123 29124 29128 29129 29131 29132 29134 29134 29136 29136 29138 29143 29145 29146 29148 29148 29151 29152 29157 29159 29164 29166 29173 29173 29176 29177 29179 29180 29182 29184 29190 29193 29197 29197 29200 29200 29203 29203 29207 29207 29210 29211 29213 29213 29215 29215 29220 29220 29224 29224 29226 29229 29231 29232 29234 29234 29236 29238 29240 29251 29253 29256 29259 29260 29262 29264 29266 29267 29269 29270 29272 29283 29287 29289 29291 29291 29294 29295 29297 29298 29300 29300 29303 29305 29307 29314 29316 29316 29319 29319 29321 29321 29325 29326 29330 29331 29334 29334 29339 29339 29344 29344 29346 29346 29351 29352 29356 29359 29361 29362 29364 29364 29366 29366 29369 29369 29374 29374 29377 29380 29382 29383 29385 29385 29388 29388 29390 29390 29392 29392 29394 29394 29397 29401 29403 29403 29407 29410 29413 29413 29417 29417 29420 29421 29427 29428 29431 29438 29442 29442 29444 29445 29447 29447 29450 29451 29453 29453 29458 29459 29462 29465 29467 29471 29474 29474 29476 29477 29479 29484 29486 29487 29489 29490 29492 29495 29498 29499 29501 29503 29507 29509 29517 29520 29522 29522 29526 29528 29533 29536 29539 29539 29542 29548 29550 29554 29557 29557 29559 29564 29568 29569 29571 29575 29577 29577 29579 29579 29582 29582 29584 29584 29587 29587 29589 29592 29596 29596 29598 29600 29602 29602 29605 29606 29609 29611 29613 29613 29618 29619 29621 29621 29623 29623 29625 29625 29627 29629 29631 29632 29634 29634 29637 29638 29640 29647 29650 29651 29654 29654 29657 29657 29661 29662 29664 29665 29667 29667 29669 29671 29673 29674 29677 29678 29681 29681 29684 29685 29687 29691 29693 29697 29699 29703 29705 29706 29713 29713 29722 29723 29730 29730 29732 29734 29736 29750 29753 29754 29759 29761 29763 29764 29766 29767 29771 29771 29773 29773 29777 29778 29781 29781 29783 29783 29785 29792 29794 29796 29798 29803 29805 29811 29814 29814 29822 29822 29824 29825 29827 29827 29829 29831 29833 29833 29835 29835 29839 29842 29848 29850 29852 29852 29854 29859 29862 29867 29870 29874 29877 29877 29881 29881 29883 29883 29885 29885 29887 29887 29896 29898 29900 29900 29903 29904 29907 29908 29912 29912 29914 29916 29918 29920 29922 29924 29926 29931 29934 29938 29940 29940 29942 29944 29946 29948 29951 29951 29955 29958 29964 29966 29969 29971 29973 29976 29978 29978 29980 29980 29982 29985 29987 29996 29999 30003 30006 30016 30019 30020 30022 30034 30036 30036 30039 30039 30041 30050 30052 30055 30057 30059 30061 30061 30063 30065 30067 30068 30070 30079 30081 30082 30085 30087 30089 30091 30094 30101 30105 30106 30108 30109 30114 30117 30123 30123 30129 30133 30136 30138 30140 30151 30154 30154 30156 30159 30162 30162 30164 30165 30167 30169 30171 30172 30174 30180 30183 30183 30185 30185 30188 30188 30190 30196 30201 30202 30204 30204 30206 30212 30215 30221 30223 30223 30226 30227 30229 30230 30233 30233 30235 30247 30249 30249 30253 30253 30256 30256 30258 30261 30264 30268 30272 30284 30290 30290 30293 30294 30296 30297 30300 30300 30303 30303 30305 30306 30308 30309 30311 30314 30316 30322 30324 30324 30326 30326 30328 30328 30330 30334 30336 30337 30339 30344 30347 30350 30352 30352 30355 30355 30357 30358 30361 30365 30367 30368 30370 30376 30378 30378 30381 30382 30384 30384 30388 30388 30391 30394 30397 30397 30399 30399 30401 30403 30405 30406 30408 30414 30418 30418 30420 30420 30422 30423 30425 30425 30427 30428 30430 30433 30435 30440 30442 30442 30444 30444 30446 30446 30448 30450 30452 30452 30454 30454 30456 30457 30459 30460 30462 30462 30464 30465 30468 30468 30470 30476 30478 30478 30482 30482 30484 30485 30487 30487 30489 30492 30494 30496 30498 30498 30500 30502 30504 30505 30509 30511 30516 30522 30524 30526 30528 30528 30530 30530 30533 30535 30538 30538 30541 30543 30546 30546 30550 30551 30554 30556 30558 30568 30570 30572 30576 30576 30578 30580 30585 30586 30589 30592 30596 30596 30603 30606 30609 30609 30612 30614 30618 30618 30622 30624 30626 30626 30629 30629 30631 30631 30634 30634 30636 30641 30643 30643 30645 30646 30649 30649 30651 30655 30659 30659 30663 30663 30665 30665 30669 30669 30673 30674 30677 30677 30679 30679 30681 30684 30686 30688 30690 30695 30697 30698 30700 30705 30707 30708 30712 30712 30715 30716 30722 30722 30725 30726 30729 30729 30732 30734 30737 30738 30740 30741 30749 30749 30752 30755 30757 30759 30765 30766 30768 30768 30770 30770 30772 30773 30775 30775 30778 30778 30783 30783 30787 30789 30791 30792 30796 30796 30798 30798 30802 30802 30812 30814 30816 30817 30819 30820 30824 30824 30826 30828 30830 30831 30834 30834 30836 30836 30842 30842 30844 30844 30846 30846 30849 30849 30854 30855 30858 30858 30860 30863 30865 30865 30867 30869 30871 30872 30874 30874 30877 30879 30881 30881 30883 30884 30887 30890 30892 30893 30895 30899 30901 30901 30906 30911 30913 30913 30917 30924 30926 30926 30928 30934 30938 30939 30943 30945 30948 30948 30950 30952 30954 30954 30956 30956 30959 30959 30962 30964 30966 30967 30970 30971 30973 30973 30975 30977 30982 30983 30988 30988 30990 30990 30992 30994 31001 31002 31004 31004 31006 31008 31013 31015 31017 31021 31025 31025 31028 31029 31034 31041 31044 31051 31055 31057 31059 31064 31066 31072 31074 31074 31077 31077 31079 31081 31083 31083 31085 31085 31090 31090 31095 31095 31097 31100 31102 31105 31108 31109 31114 31119 31121 31121 31123 31126 31128 31128 31131 31133 31137 31137 31142 31147 31150 31153 31155 31156 31160 31163 31165 31170 31172 31172 31175 31179 31183 31183 31185 31186 31188 31190 31192 31192 31194 31194 31197 31207 31209 31213 31216 31217 31224 31224 31227 31228 31232 31232 31234 31235 31239 31246 31249 31249 31252 31253 31255 31260 31262 31265 31271 31271 31275 31275 31277 31282 31284 31285 31287 31296 31298 31305 31308 31312 31317 31319 31321 31321 31324 31325 31327 31331 31333 31333 31335 31335 31337 31339 31341 31341 31344 31344 31348 31350 31352 31354 31357 31366 31368 31368 31370 31371 31376 31384 31390 31392 31395 31395 31401 31402 31404 31404 31406 31408 31411 31411 31413 31414 31417 31420 31423 31423 31427 31439 31441 31443 31445 31445 31449 31453 31455 31459 31461 31462 31464 31469 31471 31473 31476 31476 31478 31478 31480 31483 31485 31487 31490 31490 31492 31492 31494 31496 31498 31499 31503 31503 31505 31505 31508 31508 31512 31513 31515 31515 31518 31520 31523 31523 31525 31537 31539 31542 31545 31545 31549 31549 31551 31553 31557 31561 31563 31570 31572 31574 31581 31581 31584 31584 31588 31591 31593 31594 31596 31605 31607 31607 31610 31610 31620 31620 31622 31623 31625 31625 31627 31627 31629 31634 31636 31649 31653 31653 31658 31658 31660 31661 31663 31666 31668 31670 31672 31672 31674 31677 31680 31682 31684 31692 31695 31695 31700 31700 31702 31703 31705 31707 31709 31709 31712 31712 31716 31718 31720 31722 31725 31725 31730 31738 31740 31740 31742 31742 31744 31748 31750 31751 31753 31753 31755 31759 31761 31764 31767 31767 31769 31769 31771 31771 31775 31777 31779 31779 31781 31784 31786 31788 31793 31793 31795 31796 31798 31802 31805 31808 31811 31811 31814 31814 31818 31818 31820 31821 31823 31830 31832 31841 31843 31845 31847 31847 31849 31849 31852 31854 31856 31856 31858 31859 31861 31861 31865 31865 31868 31870 31873 31875 31878 31879 31881 31881 31883 31883 31885 31885 31887 31888 31890 31890 31892 31893 31895 31896 31899 31899 31902 31906 31908 31912 31915 31915 31917 31918 31920 31923 31926 31927 31929 31936 31938 31938 31940 31941 31943 31946 31949 31951 31954 31962 31964 31968 31970 31970 31974 31975 31977 31977 31979 31979 31983 31983 31986 31986 31988 31990 31992 31992 31994 31995 31998 31998 32000 32000 32002 32011 32013 32013 32015 32030 32032 32035 32038 32038 32042 32051 32053 32053 32057 32058 32060 32072 32075 32081 32083 32083 32086 32087 32089 32094 32097 32099 32101 32104 32106 32106 32110 32110 32112 32115 32117 32118 32120 32123 32125 32125 32127 32127 32129 32131 32133 32134 32136 32137 32139 32141 32143 32143 32145 32145 32147 32147 32150 32151 32153 32159 32162 32163 32166 32167 32170 32187 32189 32191 32194 32199 32202 32207 32209 32210 32213 32213 32215 32218 32220 32222 32224 32226 32228 32230 32232 32237 32239 32239 32241 32242 32244 32246 32249 32251 32256 32257 32260 32261 32264 32267 32272 32274 32277 32277 32279 32279 32283 32291 32294 32296 32299 32303 32305 32307 32309 32311 32313 32315 32317 32319 32321 32321 32323 32327 32330 32331 32333 32334 32336 32336 32338 32338 32340 32342 32344 32346 32349 32351 32353 32354 32357 32359 32361 32363 32365 32368 32371 32371 32376 32377 32379 32383 32385 32387 32390 32394 32396 32406 32408 32408 32410 32414 32566 32566 32568 32568 32570 32575 32579 32581 32583 32583 32588 32597 32600 32600 32603 32605 32607 32609 32611 32619 32621 32622 32624 32626 32629 32629 32631 32633 32637 32640 32642 32643 32645 32648 32650 32657 32660 32660 32662 32663 32666 32666 32668 32670 32673 32676 32678 32678 32680 32682 32685 32687 32690 32690 32692 32692 32694 32694 32696 32697 32700 32701 32703 32705 32707 32707 32709 32710 32712 32712 32714 32714 32716 32716 32718 32719 32722 32722 32724 32725 32731 32731 32735 32737 32739 32739 32741 32742 32744 32745 32747 32748 32750 32752 32754 32755 32761 32769 32771 32776 32778 32793 32796 32801 32804 32804 32806 32806 32808 32808 32812 32812 32814 32814 32816 32816 32819 32823 32825 32832 32836 32836 32838 32838 32842 32842 32850 32850 32854 32854 32856 32856 32858 32858 32862 32866 32868 32868 32870 32870 32872 32872 32877 32877 32879 32887 32889 32889 32893 32895 32897 32897 32900 32905 32907 32908 32910 32910 32915 32915 32918 32918 32920 32920 32922 32926 32929 32930 32933 32935 32937 32941 32943 32943 32945 32946 32948 32948 32952 32954 32963 32964 32966 32966 32968 32968 32972 32975 32978 32978 32980 32987 32989 32990 32992 32993 32996 32997 33005 33012 33014 33014 33016 33018 33020 33022 33026 33027 33029 33035 33046 33048 33050 33052 33054 33054 33056 33056 33059 33060 33063 33063 33065 33065 33068 33068 33071 33073 33075 33075 33077 33077 33081 33082 33084 33084 33086 33086 33093 33095 33098 33100 33102 33102 33104 33109 33111 33111 33119 33121 33125 33129 33131 33131 33133 33137 33140 33140 33143 33146 33151 33158 33160 33160 33162 33163 33166 33168 33171 33171 33173 33174 33176 33176 33178 33182 33184 33184 33186 33188 33192 33193 33198 33198 33200 33200 33202 33205 33208 33208 33210 33211 33213 33216 33218 33219 33221 33222 33224 33227 33229 33231 33233 33233 33235 33235 33237 33237 33239 33243 33245 33249 33251 33253 33255 33256 33258 33261 33264 33270 33272 33283 33285 33285 33287 33290 33292 33296 33298 33300 33302 33311 33313 33314 33320 33324 33326 33326 33330 33338 33344 33344 33347 33351 33355 33355 33358 33359 33361 33361 33366 33366 33368 33370 33372 33373 33375 33376 33378 33380 33382 33384 33386 33387 33389 33391 33393 33394 33396 33396 33398 33400 33403 33403 33405 33409 33411 33412 33415 33415 33417 33419 33421 33422 33425 33426 33428 33428 33430 33430 33432 33435 33437 33437 33439 33441 33443 33460 33463 33471 33477 33478 33488 33493 33495 33495 33497 33500 33502 33512 33514 33515 33517 33517 33519 33519 33521 33521 33523 33524 33526 33527 33529 33531 33533 33534 33536 33547 33550 33550 33558 33560 33563 33567 33569 33571 33576 33576 33579 33594 33596 33597 33600 33600 33602 33605 33607 33607 33609 33610 33613 33624 33648 33648 33651 33651 33653 33653 33655 33656 33659 33661 33663 33664 33666 33666 33668 33671 33673 33674 33677 33678 33682 33686 33688 33696 33698 33698 33702 33709 33713 33713 33717 33717 33725 33729 33733 33733 33735 33735 33737 33738 33740 33740 33742 33745 33747 33748 33750 33750 33752 33752 33756 33757 33759 33760 33768 33771 33775 33778 33780 33780 33782 33785 33787 33789 33793 33793 33795 33796 33798 33799 33802 33807 33809 33809 33811 33811 33813 33813 33817 33817 33824 33824 33826 33826 33833 33834 33836 33836 33839 33839 33841 33841 33845 33845 33848 33849 33852 33853 33861 33866 33869 33871 33873 33874 33878 33884 33888 33895 33897 33905 33907 33914 33916 33917 33921 33922 33924 33925 33931 33931 33936 33936 33938 33941 33945 33945 33948 33948 33950 33951 33953 33953 33958 33958 33960 33962 33965 33965 33967 33967 33969 33970 33972 33972 33976 33986 33988 33988 33990 33997 33999 34001 34003 34003 34006 34006 34009 34010 34012 34012 34023 34023 34026 34026 34028 34028 34030 34034 34036 34036 34039 34039 34042 34045 34047 34048 34050 34051 34054 34055 34060 34060 34062 34062 34064 34065 34067 34069 34071 34072 34074 34074 34076 34076 34078 34079 34081 34087 34090 34093 34095 34095 34098 34102 34109 34109 34111 34113 34115 34115 34118 34118 34120 34123 34126 34131 34133 34138 34140 34148 34152 34155 34157 34157 34159 34159 34167 34167 34169 34171 34173 34177 34180 34188 34191 34193 34195 34196 34199 34201 34203 34205 34207 34208 34210 34210 34212 34223 34228 34228 34230 34234 34236 34239 34241 34242 34247 34247 34249 34251 34253 34256 34261 34261 34264 34264 34266 34266 34268 34269 34271 34272 34276 34278 34280 34282 34285 34285 34291 34291 34294 34295 34297 34300 34302 34304 34306 34306 34308 34311 34314 34315 34317 34318 34320 34323 34326 34331 34334 34334 34337 34338 34343 34343 34345 34345 34349 34349 34351 34352 34358 34358 34360 34360 34362 34362 34364 34365 34367 34370 34374 34374 34381 34382 34384 34384 34386 34394 34396 34404 34407 34407 34409 34409 34411 34412 34415 34415 34417 34417 34421 34423 34425 34427 34440 34440 34442 34445 34449 34449 34451 34451 34453 34454 34456 34456 34458 34458 34460 34460 34465 34465 34467 34468 34470 34475 34477 34477 34479 34481 34483 34489 34495 34497 34499 34503 34505 34505 34507 34507 34509 34510 34513 34514 34516 34517 34519 34519 34521 34524 34526 34528 34531 34533 34535 34535 34537 34537 34540 34543 34552 34558 34560 34560 34562 34571 34573 34580 34584 34586 34588 34588 34590 34591 34593 34593 34595 34595 34597 34597 34600 34601 34606 34607 34609 34610 34612 34612 34615 34615 34617 34624 34627 34627 34629 34629 34633 34633 34635 34638 34643 34643 34645 34645 34647 34649 34653 34653 34655 34657 34659 34662 34664 34664 34666 34666 34670 34671 34673 34674 34676 34676 34678 34678 34680 34680 34683 34683 34687 34687 34690 34697 34699 34701 34704 34704 34707 34707 34709 34709 34711 34713 34718 34720 34722 34723 34727 34727 34731 34735 34737 34737 34739 34739 34741 34741 34746 34747 34749 34753 34756 34756 34758 34763 34766 34766 34768 34768 34770 34770 34773 34774 34777 34778 34780 34780 34783 34784 34786 34788 34794 34795 34797 34797 34799 34799 34801 34803 34806 34811 34814 34815 34817 34817 34819 34819 34821 34822 34825 34827 34829 34838 34840 34844 34846 34847 34849 34851 34855 34856 34861 34862 34864 34866 34869 34870 34873 34876 34880 34886 34888 34894 34897 34899 34901 34916 34920 34921 34923 34923 34928 34930 34933 34933 34935 34935 34937 34937 34939 34939 34941 34946 34952 34952 34955 34955 34957 34957 34962 34962 34966 34972 34974 34976 34978 34978 34980 34980 34984 34984 34986 34987 34990 34990 34992 34993 34996 34997 34999 34999 35002 35002 35005 35013 35018 35023 35025 35029 35032 35033 35035 35039 35041 35041 35047 35048 35055 35061 35063 35065 35068 35070 35073 35074 35076 35076 35078 35079 35082 35082 35084 35088 35090 35091 35093 35094 35096 35098 35100 35102 35104 35104 35109 35112 35114 35115 35120 35122 35125 35126 35128 35131 35134 35134 35136 35142 35145 35145 35148 35149 35151 35151 35154 35154 35158 35159 35162 35164 35166 35172 35174 35174 35178 35179 35181 35184 35186 35189 35191 35191 35194 35199 35201 35201 35203 35203 35206 35211 35213 35213 35215 35216 35219 35224 35226 35228 35231 35233 35237 35239 35241 35242 35244 35244 35247 35248 35250 35255 35258 35258 35260 35261 35263 35264 35282 35282 35284 35288 35290 35290 35292 35293 35299 35299 35301 35303 35305 35305 35307 35307 35309 35309 35313 35313 35315 35316 35318 35318 35320 35321 35325 35325 35327 35328 35330 35333 35335 35336 35338 35338 35340 35340 35342 35352 35355 35355 35357 35360 35362 35366 35370 35373 35375 35375 35377 35377 35379 35383 35386 35390 35392 35393 35395 35395 35397 35401 35405 35406 35408 35416 35419 35422 35424 35427 35429 35431 35433 35433 35435 35438 35440 35443 35445 35447 35449 35452 35454 35456 35458 35463 35465 35465 35467 35469 35471 35475 35477 35482 35486 35489 35491 35497 35500 35504 35506 35507 35510 35511 35513 35513 35515 35516 35518 35519 35522 35524 35526 35533 35535 35535 35537 35543 35546 35554 35556 35556 35558 35559 35563 35566 35568 35569 35571 35576 35578 35578 35580 35580 35582 35586 35588 35591 35594 35596 35598 35598 35600 35601 35604 35604 35606 35607 35609 35617 35622 35622 35624 35624 35627 35629 35632 35632 35635 35635 35639 35639 35641 35641 35644 35644 35646 35646 35649 35654 35656 35657 35660 35663 35666 35668 35670 35670 35672 35676 35678 35679 35683 35683 35686 35686 35691 35693 35695 35698 35700 35700 35702 35705 35708 35710 35712 35713 35715 35717 35722 35728 35730 35734 35737 35738 35740 35740 35742 35743 35895 35898 35901 35903 35905 35905 35909 35916 35918 35921 35923 35925 35927 35931 35933 35933 35937 35940 35942 35942 35944 35949 35955 35955 35957 35958 35960 35964 35966 35966 35970 35970 35973 35975 35977 35982 35984 35984 35986 35988 35992 35993 35995 35998 36000 36002 36004 36004 36007 36016 36018 36020 36022 36029 36031 36043 36045 36047 36049 36049 36051 36051 36053 36054 36057 36062 36064 36068 36070 36070 36072 36072 36074 36074 36076 36077 36079 36080 36082 36082 36085 36085 36087 36088 36090 36095 36097 36097 36099 36101 36103 36107 36109 36109 36111 36112 36114 36116 36118 36119 36123 36123 36196 36199 36201 36201 36203 36206 36208 36209 36211 36212 36215 36215 36223 36223 36225 36226 36228 36229 36232 36232 36234 36234 36237 36237 36240 36241 36245 36245 36249 36249 36254 36256 36259 36259 36262 36262 36264 36264 36267 36268 36271 36271 36274 36275 36277 36277 36279 36279 36281 36284 36286 36286 36288 36288 36290 36290 36293 36296 36298 36300 36302 36303 36305 36305 36308 36311 36313 36315 36317 36317 36319 36319 36321 36321 36323 36325 36327 36328 36330 36332 36335 36341 36348 36349 36351 36351 36353 36353 36356 36358 36360 36363 36367 36369 36372 36372 36374 36374 36381 36387 36390 36391 36394 36394 36400 36401 36403 36409 36413 36413 36416 36418 36420 36420 36423 36432 36436 36437 36441 36441 36443 36452 36457 36457 36460 36461 36463 36466 36468 36468 36470 36470 36473 36476 36481 36485 36487 36487 36489 36491 36493 36493 36496 36501 36505 36507 36509 36510 36513 36514 36519 36519 36521 36529 36531 36531 36533 36533 36538 36539 36542 36542 36544 36545 36547 36552 36554 36557 36559 36559 36561 36562 36564 36564 36571 36572 36575 36575 36578 36579 36584 36584 36587 36587 36589 36590 36592 36593 36599 36606 36608 36608 36610 36611 36613 36613 36615 36618 36620 36620 36623 36624 36626 36633 36635 36641 36643 36643 36645 36650 36652 36655 36659 36667 36670 36679 36681 36681 36684 36687 36689 36693 36695 36696 36700 36703 36705 36709 36763 36769 36771 36776 36781 36786 36789 36792 36794 36796 36798 36802 36804 36806 36810 36811 36813 36814 36816 36821 36826 36826 36832 36832 36834 36838 36840 36843 36845 36849 36852 36859 36861 36862 36864 36870 36872 36872 36875 36881 36883 36891 36893 36899 36903 36906 36908 36911 36913 36921 36924 36924 36926 36927 36929 36933 36935 36935 36937 36950 36952 36953 36955 36958 36960 36963 36965 36969 36972 36976 36978 36978 36980 36986 36988 36989 36991 36997 36999 37004 37006 37009 37013 37013 37015 37017 37019 37019 37024 37027 37029 37030 37032 37032 37034 37034 37039 37046 37048 37048 37053 37054 37057 37057 37059 37061 37063 37064 37066 37066 37068 37068 37070 37070 37074 37074 37077 37077 37079 37081 37083 37085 37087 37087 37089 37090 37092 37093 37096 37096 37099 37099 37101 37101 37103 37104 37108 37111 37117 37120 37122 37122 37124 37126 37128 37128 37133 37133 37136 37136 37138 37138 37140 37140 37142 37146 37148 37148 37150 37150 37152 37152 37154 37155 37157 37157 37159 37159 37161 37161 37165 37170 37172 37172 37174 37175 37177 37178 37180 37181 37187 37187 37191 37199 37202 37204 37206 37211 37217 37221 37223 37223 37225 37226 37228 37229 37234 37237 37239 37243 37249 37251 37253 37255 37257 37259 37261 37262 37264 37269 37271 37272 37276 37276 37278 37278 37281 37282 37284 37284 37286 37286 37288 37288 37290 37302 37304 37304 37306 37309 37311 37315 37317 37321 37323 37329 37331 37332 37334 37343 37345 37345 37347 37351 37353 37354 37356 37361 37365 37367 37369 37369 37371 37373 37375 37377 37380 37383 37385 37386 37388 37390 37392 37398 37400 37400 37404 37406 37411 37414 37416 37417 37420 37420 37422 37424 37427 37434 37436 37436 37438 37440 37442 37451 37453 37457 37463 37470 37472 37474 37476 37481 37486 37489 37493 37497 37499 37504 37507 37507 37509 37509 37512 37514 37517 37518 37521 37523 37525 37532 37535 37536 37540 37541 37543 37544 37547 37547 37549 37549 37551 37551 37554 37554 37558 37565 37567 37571 37573 37576 37579 37584 37586 37587 37589 37589 37591 37593 37596 37597 37599 37601 37603 37605 37607 37610 37612 37614 37616 37616 37618 37619 37624 37628 37631 37632 37634 37634 37638 37638 37640 37640 37645 37645 37647 37649 37652 37653 37656 37658 37660 37676 37678 37679 37682 37687 37690 37691 37700 37700 37703 37705 37707 37707 37709 37709 37712 37714 37716 37720 37722 37724 37726 37726 37728 37728 37732 37733 37735 37735 37737 37738 37740 37745 37747 37750 37754 37754 37756 37762 37768 37768 37770 37773 37775 37775 37778 37778 37780 37784 37786 37787 37790 37790 37793 37793 37795 37796 37798 37801 37803 37806 37808 37808 37812 37814 37817 37818 37825 37825 37827 37837 37840 37841 37843 37843 37846 37849 37852 37855 37857 37858 37860 37864 37879 37883 37885 37885 37889 37892 37895 37897 37901 37904 37907 37914 37919 37919 37921 37921 37931 37931 37934 37935 37937 37942 37944 37944 37946 37947 37949 37949 37951 37951 37953 37953 37955 37957 37960 37960 37962 37962 37964 37964 37969 37971 37973 37973 37977 37980 37982 37987 37992 37992 37994 37995 37997 38002 38005 38005 38007 38007 38012 38015 38017 38017 38019 38020 38263 38265 38270 38270 38272 38272 38274 38276 38279 38287 38289 38289 38291 38292 38294 38294 38296 38297 38301 38313 38315 38317 38322 38322 38324 38324 38326 38326 38329 38335 38339 38339 38342 38349 38352 38358 38360 38362 38364 38370 38372 38374 38428 38430 38433 38434 38436 38438 38440 38440 38442 38442 38444 38444 38446 38447 38449 38451 38455 38461 38463 38466 38468 38468 38475 38477 38479 38480 38482 38482 38484 38484 38486 38488 38491 38495 38497 38502 38506 38506 38508 38508 38510 38510 38512 38512 38514 38520 38522 38527 38529 38534 38536 38539 38541 38543 38545 38545 38548 38557 38559 38560 38563 38570 38574 38580 38582 38588 38592 38593 38596 38599 38601 38606 38609 38610 38613 38614 38616 38623 38626 38627 38632 38635 38639 38642 38646 38647 38649 38651 38656 38656 38658 38666 38669 38671 38673 38673 38675 38675 38678 38678 38681 38686 38689 38692 38695 38696 38698 38698 38704 38707 38712 38713 38717 38718 38721 38724 38726 38726 38728 38730 38734 38735 38738 38738 38741 38748 38750 38750 38752 38756 38758 38763 38765 38766 38769 38769 38771 38772 38774 38781 38783 38785 38788 38790 38793 38793 38795 38795 38797 38797 38799 38800 38805 38810 38812 38812 38814 38816 38818 38819 38822 38822 38824 38824 38827 38830 38833 38838 38840 38842 38844 38844 38846 38847 38849 38849 38851 38862 38864 38865 38867 38868 38871 38873 38875 38878 38880 38881 38884 38884 38893 38895 38897 38904 38906 38907 38911 38911 38913 38915 38917 38920 38922 38922 38924 38932 38934 38938 38940 38940 38942 38942 38944 38945 38947 38950 38955 38960 38962 38965 38967 38968 38971 38974 38980 38980 38982 38983 38986 38991 38993 39003 39006 39006 39010 39011 39013 39015 39018 39020 39023 39025 39027 39028 39080 39080 39082 39083 39085 39089 39092 39092 39094 39096 39098 39099 39103 39103 39106 39110 39112 39112 39116 39116 39131 39132 39135 39135 39137 39139 39141 39143 39145 39147 39149 39151 39154 39156 39158 39158 39164 39166 39170 39171 39173 39173 39175 39178 39180 39180 39184 39192 39194 39202 39204 39204 39206 39208 39211 39212 39214 39214 39217 39221 39225 39230 39232 39234 39237 39241 39243 39246 39248 39250 39252 39253 39255 39257 39259 39260 39262 39264 39318 39321 39323 39323 39325 39325 39327 39327 39333 39334 39336 39336 39340 39342 39344 39349 39353 39354 39356 39357 39359 39359 39361 39361 39363 39366 39368 39369 39376 39381 39384 39391 39394 39394 39399 39399 39402 39406 39408 39410 39412 39413 39416 39417 39419 39419 39421 39423 39425 39429 39435 39436 39438 39443 39446 39446 39449 39449 39454 39454 39456 39456 39458 39460 39463 39464 39467 39467 39469 39470 39472 39472 39475 39475 39477 39480 39486 39486 39488 39493 39495 39495 39498 39502 39505 39505 39508 39511 39514 39515 39517 39517 39519 39519 39522 39522 39524 39525 39529 39531 39592 39592 39594 39594 39596 39600 39602 39602 39604 39606 39608 39609 39611 39612 39614 39617 39619 39620 39622 39622 39624 39624 39630 39640 39643 39644 39646 39648 39650 39655 39657 39663 39665 39669 39671 39671 39673 39675 39677 39677 39679 39686 39688 39689 39691 39694 39696 39696 39698 39698 39702 39702 39704 39708 39711 39712 39714 39715 39717 39723 39725 39727 39729 39733 39735 39735 39737 39741 39745 39749 39752 39752 39755 39759 39761 39761 39764 39768 39770 39771 39774 39774 39777 39777 39779 39779 39781 39782 39784 39784 39786 39791 39795 39797 39799 39801 39807 39808 39811 39815 39817 39819 39821 39828 39830 39831 39834 39834 39837 39840 39846 39854 39856 39858 39860 39860 39863 39865 39867 39868 39870 39873 39878 39882 39886 39890 39892 39892 39894 39896 39899 39899 39901 39901 39903 39903 39905 39909 39911 39912 39914 39915 39919 39923 39925 39925 39927 39930 39933 39933 39935 39936 39938 39938 39940 39940 39942 39942 39944 39949 39951 39958 39960 39964 39966 39966 39969 39978 39981 39986 39989 39991 39993 39995 39997 39998 40001 40001 40003 40010 40014 40016 40018 40020 40022 40024 40026 40032 40035 40035 40039 40043 40046 40046 40048 40048 40050 40050 40053 40056 40059 40059 40165 40167 40169 40169 40171 40172 40176 40176 40178 40180 40182 40183 40185 40185 40194 40195 40198 40201 40203 40203 40206 40206 40209 40210 40213 40213 40215 40216 40219 40223 40227 40227 40230 40230 40232 40232 40234 40236 40239 40240 40242 40244 40250 40255 40257 40264 40266 40266 40272 40273 40275 40276 40281 40281 40284 40293 40297 40300 40303 40304 40306 40306 40310 40311 40314 40316 40318 40318 40323 40324 40326 40327 40329 40330 40333 40335 40338 40339 40341 40344 40346 40346 40353 40353 40356 40356 40361 40364 40366 40367 40369 40370 40372 40373 40376 40380 40383 40383 40385 40388 40390 40391 40393 40394 40399 40399 40403 40407 40409 40410 40414 40416 40421 40423 40425 40425 40427 40427 40429 40432 40434 40436 40440 40442 40445 40446 40450 40450 40455 40455 40458 40458 40462 40462 40464 40466 40469 40470 40473 40478 40565 40565 40568 40573 40575 40581 40583 40584 40587 40588 40590 40591 40593 40595 40597 40600 40603 40603 40605 40607 40612 40614 40616 40618 40620 40624 40627 40629 40632 40636 40638 40639 40644 40644 40646 40646 40648 40648 40651 40656 40658 40658 40660 40661 40664 40665 40667 40672 40676 40677 40679 40680 40684 40690 40692 40697 40699 40701 40703 40703 40706 40707 40711 40713 40718 40727 40729 40731 40735 40738 40742 40742 40746 40748 40751 40751 40753 40754 40756 40756 40759 40759 40761 40767 40769 40769 40771 40775 40778 40779 40782 40783 40786 40792 40794 40794 40797 40803 40806 40810 40812 40819 40821 40823 40826 40826 40829 40829 40845 40845 40847 40850 40852 40855 40860 40862 40864 40867 40869 40869 65281 65281 65283 65286 65288 65292 65294 65374 65377 65439 65507 65507 65509 65509 917504 917631)) (make-character-set :mib-enum 2101 :name "Big5-HKSCS" :aliases 'nil :mime-encoding 'nil :source '"See (http://www.iana.org/assignments/charset-reg/Big5-HKSCS)" :comments 'nil :references '("[Yick]") :ranges #(0 128 162 163 165 165 167 168 176 177 183 183 192 193 200 202 210 211 215 215 224 225 232 234 236 237 242 243 247 250 252 252 256 257 274 275 282 283 299 299 331 333 339 339 363 363 461 462 464 466 468 468 470 470 472 472 474 474 476 476 592 593 596 596 603 603 609 609 618 618 629 629 643 643 650 650 710 711 713 715 729 729 913 929 931 937 945 961 963 969 1025 1025 1040 1103 1105 1105 7870 7873 8211 8212 8216 8217 8220 8221 8226 8226 8229 8230 8242 8242 8245 8245 8251 8251 8254 8254 8451 8451 8453 8453 8457 8457 8470 8470 8481 8481 8544 8553 8560 8569 8592 8595 8598 8601 8632 8633 8679 8679 8730 8730 8734 8736 8739 8739 8741 8741 8745 8747 8750 8750 8756 8757 8764 8764 8786 8786 8800 8801 8806 8807 8869 8869 8895 8895 9312 9321 9332 9341 9472 9472 9474 9474 9484 9484 9488 9488 9492 9492 9496 9496 9500 9500 9508 9508 9516 9516 9524 9524 9532 9532 9552 9587 9601 9615 9620 9621 9632 9633 9650 9651 9660 9661 9670 9671 9675 9675 9678 9679 9698 9701 9733 9734 9737 9737 9792 9794 10045 10045 11904 11904 11908 11908 11910 11912 11914 11914 11916 11917 11925 11925 11932 11933 11941 11941 11943 11943 11946 11946 11948 11948 11950 11950 11958 11958 11964 11964 11966 11966 11974 11974 11978 11978 11980 11981 11983 11983 11990 11991 11998 11998 12003 12003 12083 12083 12288 12291 12293 12306 12308 12309 12317 12318 12321 12329 12353 12435 12443 12446 12449 12534 12540 12542 12549 12585 12849 12849 12963 12963 13198 13199 13212 13214 13217 13217 13252 13252 13262 13262 13265 13266 13269 13269 13365 13365 13376 13376 13388 13388 13412 13412 13427 13427 13434 13434 13437 13438 13459 13459 13462 13462 13477 13477 13487 13487 13500 13500 13505 13505 13512 13512 13535 13535 13540 13540 13563 13563 13574 13574 13630 13630 13649 13649 13651 13651 13665 13665 13677 13677 13680 13680 13682 13682 13687 13688 13700 13700 13719 13720 13729 13729 13733 13733 13741 13741 13759 13759 13761 13761 13765 13765 13767 13767 13770 13770 13774 13774 13778 13778 13782 13782 13787 13787 13789 13789 13809 13811 13819 13819 13822 13822 13833 13833 13848 13848 13850 13850 13859 13859 13869 13869 13877 13877 13881 13881 13886 13886 13895 13897 13902 13902 13919 13919 13946 13946 13953 13953 13978 13978 13989 13989 13994 13994 13996 13996 14000 14001 14005 14005 14009 14009 14012 14012 14017 14017 14019 14021 14023 14024 14035 14036 14038 14038 14045 14045 14049 14050 14053 14054 14069 14069 14081 14081 14083 14083 14088 14088 14090 14090 14093 14093 14108 14108 14114 14115 14117 14117 14124 14125 14128 14128 14130 14131 14138 14138 14144 14144 14147 14147 14178 14178 14191 14191 14231 14231 14240 14240 14265 14265 14270 14270 14322 14322 14328 14328 14331 14331 14351 14351 14361 14361 14368 14368 14381 14381 14390 14390 14392 14392 14435 14435 14496 14496 14531 14531 14540 14540 14545 14545 14586 14586 14600 14600 14612 14612 14631 14631 14642 14642 14655 14655 14669 14669 14691 14691 14720 14720 14729 14730 14738 14738 14745 14745 14747 14747 14753 14753 14756 14756 14776 14776 14812 14812 14818 14818 14821 14821 14828 14828 14840 14840 14843 14843 14846 14846 14849 14849 14851 14851 14854 14854 14871 14872 14889 14890 14900 14900 14923 14923 14930 14930 14935 14935 14940 14940 14942 14942 14950 14951 14999 14999 15019 15019 15037 15037 15070 15070 15072 15072 15088 15088 15090 15090 15099 15099 15118 15118 15129 15129 15138 15138 15147 15147 15161 15161 15170 15170 15192 15192 15200 15200 15217 15218 15227 15228 15232 15232 15254 15254 15257 15257 15265 15265 15292 15292 15294 15294 15298 15298 15300 15300 15319 15319 15325 15325 15340 15340 15346 15348 15373 15373 15377 15377 15381 15381 15384 15384 15444 15444 15563 15563 15565 15565 15569 15569 15574 15574 15580 15580 15595 15595 15599 15599 15635 15635 15645 15645 15666 15666 15675 15675 15686 15686 15692 15692 15694 15694 15697 15697 15711 15711 15714 15714 15721 15722 15727 15727 15733 15733 15741 15741 15749 15749 15754 15754 15759 15759 15761 15761 15781 15781 15789 15789 15796 15796 15807 15807 15814 15815 15820 15821 15827 15827 15835 15835 15847 15848 15851 15851 15859 15859 15863 15863 15868 15869 15878 15878 15936 15936 15939 15939 15944 15944 15957 15957 15988 15988 16040 16042 16045 16045 16049 16049 16056 16056 16063 16063 16066 16066 16071 16071 16074 16074 16076 16076 16080 16081 16086 16087 16090 16090 16094 16094 16097 16098 16103 16103 16105 16105 16107 16107 16112 16112 16115 16116 16122 16122 16124 16124 16127 16128 16132 16132 16134 16134 16142 16142 16211 16211 16216 16217 16227 16227 16252 16252 16275 16275 16320 16320 16343 16343 16348 16348 16357 16357 16365 16365 16377 16378 16388 16388 16413 16413 16441 16441 16453 16453 16467 16467 16471 16471 16482 16482 16485 16485 16490 16490 16495 16495 16552 16552 16571 16571 16575 16575 16584 16584 16600 16600 16607 16607 16634 16634 16643 16644 16649 16649 16654 16654 16690 16690 16743 16743 16748 16748 16750 16750 16767 16767 16784 16784 16818 16818 16836 16836 16842 16842 16847 16847 16859 16859 16879 16879 16889 16889 16913 16913 16960 16960 16992 16992 17002 17002 17018 17018 17036 17036 17044 17044 17077 17077 17081 17081 17084 17084 17140 17140 17147 17148 17195 17195 17262 17262 17303 17303 17338 17338 17345 17345 17369 17369 17375 17375 17389 17389 17394 17394 17409 17410 17427 17427 17445 17445 17453 17453 17530 17530 17551 17551 17567 17568 17570 17570 17584 17584 17591 17591 17600 17600 17605 17605 17614 17614 17629 17629 17631 17631 17636 17636 17641 17644 17652 17652 17667 17668 17673 17673 17675 17675 17686 17686 17693 17693 17703 17703 17710 17710 17715 17715 17723 17723 17725 17725 17727 17727 17731 17731 17745 17746 17749 17749 17756 17756 17762 17762 17770 17770 17783 17783 17797 17797 17897 17897 17926 17926 17935 17935 17941 17941 17943 17943 18011 18011 18042 18042 18048 18048 18127 18128 18165 18165 18195 18195 18200 18200 18254 18254 18300 18300 18328 18328 18342 18342 18358 18358 18389 18389 18413 18413 18420 18420 18432 18432 18443 18443 18487 18487 18525 18525 18545 18545 18587 18587 18605 18606 18640 18640 18653 18653 18669 18669 18675 18675 18682 18682 18694 18694 18705 18705 18718 18718 18725 18725 18730 18730 18733 18733 18741 18741 18748 18748 18750 18750 18757 18757 18769 18769 18771 18771 18789 18789 18794 18794 18802 18802 18825 18825 18849 18849 18855 18855 18911 18911 18917 18917 18919 18919 18959 18959 18973 18973 18980 18980 18997 18997 19094 19094 19124 19124 19128 19128 19153 19153 19172 19172 19199 19199 19225 19225 19244 19244 19255 19255 19311 19312 19314 19314 19323 19323 19326 19326 19342 19342 19344 19344 19347 19347 19350 19351 19357 19357 19389 19390 19392 19392 19460 19460 19463 19463 19470 19470 19515 19515 19518 19518 19547 19547 19565 19565 19581 19581 19620 19620 19630 19630 19632 19632 19639 19639 19661 19661 19681 19681 19693 19693 19721 19721 19728 19728 19764 19764 19857 19857 19868 19868 19968 19969 19971 19972 19975 19985 19988 19990 19992 19994 19996 19996 19998 19999 20001 20001 20004 20004 20006 20006 20008 20008 20010 20014 20016 20019 20022 20025 20027 20029 20031 20031 20034 20035 20037 20037 20039 20041 20043 20043 20045 20047 20050 20051 20054 20054 20056 20063 20073 20074 20083 20083 20088 20088 20094 20105 20107 20110 20113 20117 20120 20123 20126 20130 20132 20134 20136 20136 20139 20142 20147 20147 20150 20151 20153 20156 20159 20164 20166 20171 20173 20174 20180 20186 20188 20191 20193 20193 20195 20197 20200 20203 20206 20206 20208 20216 20219 20219 20221 20221 20223 20229 20232 20235 20237 20245 20248 20250 20253 20253 20258 20258 20264 20265 20268 20269 20271 20272 20274 20276 20278 20287 20289 20291 20293 20297 20299 20324 20327 20327 20329 20332 20334 20336 20338 20363 20365 20365 20367 20370 20372 20376 20378 20382 20386 20386 20392 20392 20395 20395 20398 20400 20402 20403 20405 20407 20409 20411 20413 20413 20415 20421 20423 20433 20435 20436 20438 20449 20452 20453 20460 20460 20462 20463 20465 20474 20477 20478 20480 20480 20483 20483 20485 20489 20491 20495 20497 20508 20510 20515 20517 20529 20531 20533 20535 20535 20540 20540 20544 20545 20547 20547 20549 20559 20561 20561 20563 20563 20565 20568 20570 20582 20584 20592 20594 20599 20602 20602 20605 20605 20608 20611 20613 20613 20615 20616 20619 20622 20624 20626 20628 20630 20632 20638 20642 20643 20646 20646 20652 20664 20666 20667 20669 20671 20673 20674 20676 20683 20685 20689 20691 20695 20697 20699 20701 20701 20703 20705 20707 20714 20716 20721 20723 20726 20728 20729 20731 20750 20752 20757 20759 20760 20762 20762 20764 20764 20767 20770 20772 20774 20777 20779 20781 20782 20784 20789 20791 20797 20799 20801 20803 20809 20811 20813 20818 20818 20820 20823 20825 20835 20837 20837 20839 20846 20849 20849 20852 20857 20860 20860 20864 20864 20866 20866 20870 20874 20877 20877 20879 20879 20881 20888 20890 20890 20892 20892 20894 20894 20896 20896 20898 20898 20900 20901 20903 20904 20906 20908 20912 20921 20924 20926 20931 20948 20951 20952 20955 20962 20964 20964 20973 20973 20976 20977 20979 20982 20984 20986 20988 20990 20992 20995 20997 21004 21006 21006 21008 21011 21014 21015 21020 21025 21028 21034 21038 21038 21040 21048 21050 21052 21057 21057 21059 21060 21062 21063 21065 21070 21074 21074 21076 21079 21081 21090 21096 21103 21106 21109 21111 21117 21119 21124 21127 21133 21135 21137 21139 21140 21142 21147 21151 21153 21155 21156 21158 21158 21160 21166 21173 21173 21177 21177 21179 21180 21182 21182 21184 21187 21189 21189 21191 21191 21193 21193 21196 21197 21200 21203 21205 21209 21211 21211 21213 21220 21222 21222 21225 21225 21227 21227 21231 21233 21235 21237 21239 21244 21246 21247 21249 21249 21253 21254 21256 21259 21261 21266 21269 21271 21273 21274 21276 21277 21279 21283 21287 21287 21290 21290 21292 21293 21295 21300 21303 21305 21307 21317 21319 21322 21324 21326 21329 21332 21335 21335 21338 21338 21340 21345 21347 21348 21350 21351 21353 21353 21356 21365 21367 21369 21371 21375 21378 21378 21380 21380 21386 21386 21390 21391 21394 21396 21398 21402 21404 21408 21410 21410 21412 21422 21424 21424 21426 21426 21428 21428 21430 21430 21433 21433 21435 21435 21441 21443 21445 21445 21448 21453 21456 21458 21460 21460 21462 21467 21471 21478 21480 21491 21493 21496 21499 21500 21502 21502 21505 21505 21507 21508 21510 21524 21526 21526 21528 21537 21539 21555 21557 21561 21563 21566 21568 21571 21573 21576 21578 21579 21581 21583 21588 21588 21600 21613 21615 21624 21626 21634 21636 21640 21643 21656 21658 21658 21660 21660 21662 21662 21664 21684 21686 21705 21707 21712 21718 21718 21722 21722 21726 21726 21728 21739 21741 21743 21745 21747 21751 21752 21754 21757 21759 21759 21761 21780 21783 21784 21786 21786 21790 21790 21795 21795 21797 21800 21802 21817 21819 21820 21822 21825 21827 21835 21837 21843 21845 21847 21852 21855 21857 21862 21865 21867 21873 21875 21877 21879 21881 21881 21883 21892 21894 21909 21912 21914 21916 21917 21919 21919 21921 21934 21936 21941 21945 21948 21951 21983 21985 21994 21996 21996 21999 22002 22005 22007 22009 22018 22020 22022 22024 22025 22028 22039 22043 22051 22053 22053 22055 22055 22057 22058 22060 22064 22066 22075 22077 22083 22085 22086 22088 22090 22092 22096 22098 22100 22103 22106 22109 22110 22112 22118 22120 22132 22134 22140 22142 22151 22153 22160 22162 22163 22165 22165 22167 22170 22172 22175 22177 22177 22180 22184 22186 22191 22193 22199 22201 22201 22204 22211 22213 22214 22216 22221 22225 22225 22227 22228 22230 22231 22234 22235 22237 22242 22244 22245 22247 22247 22250 22251 22253 22257 22263 22263 22265 22266 22269 22269 22271 22276 22279 22285 22290 22294 22296 22296 22298 22304 22306 22307 22312 22314 22316 22320 22322 22324 22331 22331 22334 22339 22341 22343 22345 22354 22356 22356 22359 22359 22363 22363 22367 22367 22369 22370 22372 22372 22374 22379 22381 22381 22383 22391 22394 22400 22402 22403 22408 22408 22410 22413 22415 22416 22419 22421 22423 22437 22439 22439 22442 22442 22446 22446 22452 22454 22456 22463 22465 22468 22470 22472 22475 22476 22478 22480 22482 22482 22484 22485 22487 22487 22492 22503 22505 22505 22508 22526 22528 22542 22544 22544 22546 22546 22548 22548 22553 22553 22555 22558 22560 22570 22572 22587 22589 22589 22591 22592 22596 22596 22599 22607 22609 22613 22615 22623 22626 22629 22632 22633 22635 22637 22639 22639 22641 22646 22649 22659 22661 22667 22670 22673 22675 22676 22680 22682 22684 22689 22691 22691 22693 22700 22702 22705 22707 22707 22709 22710 22714 22719 22721 22722 22725 22729 22731 22731 22734 22735 22737 22742 22744 22752 22754 22756 22759 22761 22763 22764 22767 22768 22770 22772 22777 22783 22786 22791 22794 22794 22796 22799 22801 22802 22804 22807 22809 22810 22812 22812 22815 22816 22818 22818 22820 22821 22823 22823 22825 22831 22833 22834 22836 22836 22839 22840 22844 22844 22846 22846 22848 22848 22852 22853 22855 22858 22862 22865 22867 22869 22871 22872 22874 22874 22876 22876 22880 22882 22885 22885 22887 22887 22889 22891 22893 22894 22896 22905 22907 22917 22921 22922 22925 22928 22930 22932 22934 22938 22941 22952 22956 22956 22958 22974 22976 22977 22979 22996 22998 22998 23000 23006 23008 23009 23011 23014 23016 23043 23049 23053 23055 23055 23057 23059 23061 23065 23067 23068 23070 23073 23075 23077 23079 23079 23081 23086 23091 23091 23093 23097 23100 23102 23104 23114 23116 23117 23120 23150 23152 23153 23159 23167 23169 23172 23174 23174 23176 23176 23178 23180 23182 23191 23193 23202 23205 23207 23209 23209 23211 23212 23214 23236 23238 23247 23251 23251 23253 23270 23272 23278 23280 23280 23282 23291 23293 23295 23297 23299 23301 23301 23303 23305 23307 23309 23311 23313 23315 23316 23318 23319 23321 23323 23325 23329 23331 23336 23338 23344 23346 23346 23348 23348 23352 23352 23356 23361 23363 23368 23370 23377 23379 23384 23386 23389 23391 23391 23394 23398 23400 23401 23403 23406 23408 23416 23418 23421 23423 23429 23431 23433 23435 23436 23438 23440 23442 23443 23445 23445 23447 23455 23458 23464 23466 23466 23468 23470 23472 23472 23475 23478 23480 23481 23487 23495 23498 23502 23504 23513 23518 23532 23534 23539 23541 23542 23544 23544 23546 23546 23551 23551 23553 23553 23555 23557 23559 23574 23578 23578 23580 23580 23582 23584 23586 23589 23592 23592 23594 23594 23596 23596 23600 23601 23603 23603 23607 23612 23614 23617 23620 23633 23635 23638 23640 23641 23644 23646 23648 23648 23650 23653 23655 23658 23660 23663 23665 23665 23667 23668 23673 23676 23678 23678 23685 23686 23688 23693 23695 23701 23705 23706 23708 23729 23731 23731 23733 23736 23738 23738 23745 23746 23750 23756 23758 23764 23766 23771 23774 23775 23781 23781 23784 23786 23788 23793 23796 23796 23798 23801 23803 23803 23805 23805 23807 23809 23814 23815 23819 23826 23828 23835 23837 23840 23842 23849 23852 23852 23854 23866 23868 23875 23877 23884 23886 23886 23888 23890 23893 23895 23897 23897 23899 23899 23902 23902 23906 23907 23909 23909 23911 23913 23915 23916 23919 23922 23924 23924 23927 23927 23929 23930 23932 23938 23940 23947 23949 23950 23954 23957 23959 23959 23961 23962 23964 23970 23972 23972 23975 23986 23988 23994 23996 23997 24000 24003 24006 24007 24009 24009 24011 24011 24013 24013 24015 24015 24017 24018 24020 24024 24027 24027 24029 24034 24037 24040 24043 24043 24046 24046 24048 24053 24055 24055 24057 24057 24061 24063 24066 24068 24070 24070 24073 24076 24078 24078 24081 24082 24084 24091 24093 24093 24095 24101 24104 24105 24107 24107 24109 24110 24115 24116 24118 24120 24125 24126 24128 24133 24136 24136 24138 24143 24147 24149 24151 24153 24155 24163 24166 24176 24178 24182 24184 24192 24194 24196 24198 24205 24207 24207 24213 24215 24218 24220 24224 24224 24226 24232 24234 24238 24240 24249 24253 24254 24257 24258 24260 24270 24272 24291 24293 24297 24300 24300 24302 24303 24305 24308 24310 24316 24318 24319 24321 24322 24324 24325 24327 24328 24330 24335 24338 24341 24343 24344 24346 24347 24349 24349 24351 24351 24354 24361 24365 24366 24368 24369 24371 24371 24373 24376 24378 24378 24380 24380 24384 24384 24387 24388 24390 24390 24392 24401 24404 24404 24406 24409 24412 24413 24417 24421 24423 24423 24425 24429 24431 24436 24438 24441 24443 24451 24453 24460 24464 24466 24470 24473 24475 24476 24478 24481 24484 24495 24497 24498 24501 24503 24505 24513 24515 24517 24521 24521 24524 24525 24527 24530 24532 24537 24539 24539 24541 24545 24547 24549 24552 24552 24554 24555 24557 24559 24561 24561 24563 24565 24567 24568 24570 24571 24573 24573 24575 24576 24585 24599 24601 24606 24608 24623 24625 24629 24631 24631 24633 24633 24635 24635 24640 24647 24649 24650 24652 24653 24656 24656 24658 24661 24664 24667 24669 24671 24674 24688 24690 24690 24693 24693 24695 24695 24702 24705 24707 24714 24716 24718 24720 24720 24722 24722 24724 24727 24730 24736 24738 24740 24743 24744 24752 24769 24771 24783 24785 24785 24787 24789 24791 24804 24806 24809 24816 24833 24835 24848 24850 24854 24856 24861 24863 24863 24867 24867 24871 24873 24875 24876 24878 24880 24882 24882 24884 24884 24886 24887 24891 24891 24893 24898 24900 24912 24914 24918 24920 24936 24938 24940 24942 24951 24953 24954 24956 24958 24960 24963 24967 24967 24969 24974 24976 24982 24984 24989 24991 24991 24993 24994 24996 24996 24999 25018 25020 25020 25022 25027 25029 25037 25039 25040 25043 25043 25046 25046 25048 25048 25050 25050 25054 25056 25058 25067 25069 25070 25072 25074 25077 25089 25091 25092 25095 25098 25100 25102 25104 25106 25108 25110 25113 25115 25119 25125 25127 25127 25129 25134 25136 25136 25138 25140 25142 25143 25145 25146 25149 25155 25158 25166 25168 25172 25176 25180 25182 25182 25184 25190 25192 25192 25197 25204 25206 25207 25209 25226 25228 25228 25230 25240 25245 25245 25252 25252 25254 25254 25256 25265 25267 25270 25272 25273 25275 25279 25282 25308 25311 25311 25317 25317 25323 25347 25351 25353 25355 25361 25363 25366 25368 25368 25384 25391 25393 25406 25408 25425 25428 25434 25444 25445 25447 25449 25451 25458 25461 25469 25471 25477 25479 25490 25492 25492 25494 25497 25499 25509 25511 25521 25529 25529 25533 25534 25536 25555 25557 25579 25581 25590 25592 25593 25595 25596 25598 25598 25606 25607 25609 25616 25618 25624 25626 25628 25630 25640 25642 25648 25650 25659 25661 25665 25667 25667 25675 25675 25677 25678 25680 25684 25688 25697 25701 25705 25707 25725 25727 25727 25730 25730 25733 25733 25735 25741 25743 25747 25749 25754 25756 25760 25762 25766 25769 25769 25771 25780 25782 25782 25787 25797 25799 25799 25801 25803 25805 25808 25810 25812 25814 25819 25821 25821 25824 25837 25839 25844 25847 25848 25850 25857 25859 25860 25862 25863 25865 25866 25868 25873 25875 25881 25883 25894 25897 25904 25906 25913 25915 25915 25917 25919 25921 25921 25923 25923 25925 25926 25928 25930 25933 25933 25935 25935 25937 25937 25939 25945 25948 25951 25954 25960 25962 25965 25967 25967 25970 25980 25983 25993 25996 25996 26000 26002 26004 26007 26009 26009 26011 26018 26020 26021 26023 26024 26026 26028 26030 26032 26034 26035 26037 26041 26043 26047 26049 26054 26059 26068 26070 26071 26074 26075 26077 26083 26085 26086 26088 26089 26092 26101 26106 26109 26111 26112 26114 26133 26136 26136 26140 26152 26155 26155 26157 26166 26169 26170 26177 26181 26183 26188 26191 26191 26193 26195 26199 26199 26201 26207 26209 26216 26218 26220 26222 26228 26230 26238 26240 26240 26244 26254 26256 26258 26260 26266 26269 26269 26271 26274 26276 26276 26280 26283 26285 26299 26301 26304 26308 26308 26310 26319 26322 26322 26326 26326 26328 26334 26336 26336 26339 26340 26342 26342 26344 26345 26347 26350 26352 26356 26358 26361 26364 26364 26366 26373 26376 26384 26386 26392 26395 26395 26397 26403 26405 26408 26410 26414 26417 26417 26419 26422 26424 26431 26436 26441 26443 26449 26451 26451 26453 26455 26457 26458 26460 26466 26471 26471 26474 26474 26476 26477 26479 26495 26497 26497 26499 26503 26505 26505 26507 26517 26519 26522 26524 26525 26527 26528 26532 26532 26540 26540 26542 26555 26559 26566 26568 26580 26582 26591 26594 26599 26601 26618 26620 26620 26622 26628 26637 26637 26640 26640 26642 26644 26646 26648 26650 26658 26661 26662 26664 26667 26669 26671 26673 26686 26688 26705 26707 26710 26717 26717 26725 26725 26731 26731 26733 26735 26737 26738 26740 26745 26747 26764 26767 26772 26774 26776 26779 26781 26783 26788 26790 26806 26809 26809 26813 26813 26819 26830 26832 26840 26842 26842 26844 26849 26851 26852 26854 26860 26862 26877 26880 26901 26903 26904 26906 26907 26917 26917 26922 26922 26924 26924 26927 26928 26930 26937 26939 26950 26952 26956 26958 26959 26961 27003 27008 27008 27010 27011 27013 27014 27018 27018 27021 27022 27024 27025 27027 27036 27038 27063 27065 27065 27067 27076 27078 27078 27081 27089 27091 27094 27097 27097 27105 27106 27108 27113 27115 27118 27121 27124 27126 27149 27151 27151 27153 27153 27155 27169 27171 27171 27173 27176 27179 27181 27186 27189 27192 27201 27204 27209 27211 27227 27229 27234 27236 27243 27245 27245 27247 27247 27249 27249 27252 27252 27254 27254 27258 27258 27262 27269 27271 27271 27273 27274 27276 27287 27289 27304 27307 27311 27313 27323 27325 27326 27330 27331 27333 27341 27343 27345 27347 27348 27352 27361 27365 27365 27367 27368 27370 27372 27374 27377 27379 27379 27382 27382 27384 27388 27392 27392 27394 27397 27400 27403 27407 27411 27414 27418 27421 27422 27424 27425 27427 27427 27429 27429 27432 27432 27436 27437 27439 27439 27441 27455 27457 27459 27461 27470 27472 27474 27476 27479 27481 27481 27483 27484 27486 27495 27498 27498 27501 27501 27503 27503 27506 27506 27508 27508 27510 27515 27518 27524 27526 27526 27528 27530 27532 27535 27537 27537 27540 27545 27547 27547 27550 27552 27554 27559 27562 27563 27565 27568 27570 27571 27573 27575 27578 27578 27580 27581 27583 27585 27587 27597 27599 27600 27602 27604 27606 27608 27610 27612 27614 27614 27616 27620 27622 27624 27626 27628 27631 27632 27634 27635 27639 27654 27656 27657 27659 27661 27663 27665 27667 27670 27672 27677 27679 27681 27683 27688 27690 27692 27694 27697 27699 27707 27709 27715 27718 27718 27721 27728 27730 27730 27732 27733 27735 27745 27749 27755 27757 27766 27768 27771 27773 27792 27794 27798 27800 27805 27807 27807 27810 27810 27818 27828 27830 27847 27849 27863 27865 27875 27877 27877 27879 27891 27893 27893 27897 27897 27904 27922 27926 27931 27933 27936 27938 27938 27940 27970 27982 27982 27991 27996 27998 28010 28012 28018 28020 28056 28068 28069 28074 28076 28078 28079 28081 28085 28087 28096 28098 28098 28100 28109 28111 28134 28136 28151 28153 28157 28160 28160 28162 28165 28170 28170 28175 28175 28181 28181 28184 28189 28191 28214 28216 28225 28227 28231 28233 28235 28237 28246 28248 28265 28267 28267 28270 28271 28273 28276 28278 28281 28284 28284 28294 28294 28296 28297 28299 28299 28301 28304 28306 28308 28310 28327 28330 28331 28334 28374 28376 28381 28386 28386 28392 28393 28395 28399 28401 28402 28404 28431 28434 28442 28444 28444 28446 28455 28457 28481 28483 28484 28494 28504 28506 28516 28518 28519 28521 28528 28530 28532 28534 28546 28548 28558 28560 28560 28562 28567 28573 28598 28600 28612 28614 28623 28627 28629 28632 28644 28646 28649 28651 28658 28660 28660 28662 28664 28666 28668 28670 28673 28675 28679 28681 28687 28689 28689 28692 28708 28710 28716 28719 28725 28727 28732 28734 28742 28744 28748 28752 28754 28756 28760 28762 28780 28783 28785 28788 28790 28792 28794 28796 28799 28801 28806 28809 28811 28814 28815 28817 28822 28824 28826 28831 28833 28835 28839 28841 28841 28843 28849 28851 28853 28855 28862 28864 28864 28868 28872 28874 28890 28892 28898 28900 28900 28911 28913 28915 28928 28930 28930 28932 28934 28937 28942 28944 28944 28947 28947 28951 28951 28953 28963 28965 28966 28968 28969 28971 28972 28974 28982 28986 28987 28990 28990 28992 28999 29001 29012 29014 29014 29016 29018 29020 29036 29038 29038 29040 29043 29045 29048 29050 29054 29056 29058 29060 29066 29068 29068 29070 29072 29074 29074 29076 29076 29078 29093 29095 29098 29100 29101 29103 29109 29111 29114 29116 29131 29134 29138 29140 29142 29144 29149 29151 29154 29156 29160 29163 29166 29168 29170 29172 29174 29176 29177 29179 29183 29185 29187 29189 29191 29193 29194 29196 29200 29203 29207 29209 29211 29213 29215 29218 29220 29222 29230 29232 29232 29237 29238 29240 29243 29245 29250 29252 29252 29254 29260 29263 29264 29266 29267 29269 29283 29286 29287 29289 29290 29292 29292 29294 29296 29298 29300 29302 29305 29307 29314 29316 29321 29323 29336 29338 29339 29341 29343 29345 29354 29356 29360 29362 29362 29364 29365 29370 29370 29373 29373 29375 29382 29385 29390 29392 29394 29396 29396 29398 29402 29404 29404 29407 29412 29414 29414 29416 29419 29427 29428 29430 29442 29444 29444 29447 29448 29450 29452 29455 29459 29462 29465 29467 29470 29474 29475 29477 29486 29488 29500 29502 29509 29512 29514 29516 29522 29527 29531 29533 29538 29541 29548 29550 29560 29562 29579 29582 29583 29586 29592 29596 29602 29604 29613 29618 29625 29627 29628 29630 29632 29634 29635 29637 29648 29650 29662 29664 29675 29677 29679 29683 29697 29699 29709 29713 29714 29716 29719 29721 29734 29736 29754 29756 29756 29759 29771 29773 29783 29785 29792 29794 29797 29799 29814 29817 29818 29820 29827 29829 29837 29840 29840 29842 29842 29844 29845 29847 29852 29854 29857 29859 29867 29869 29869 29871 29874 29876 29880 29882 29883 29885 29891 29893 29893 29896 29896 29898 29900 29903 29904 29907 29929 29932 29932 29934 29934 29936 29938 29940 29944 29947 29947 29949 29952 29954 29957 29959 29960 29963 29978 29980 29983 29985 29986 29989 29990 29992 30005 30007 30011 30013 30016 30018 30018 30022 30024 30026 30031 30033 30033 30035 30037 30041 30045 30047 30048 30050 30055 30058 30064 30066 30066 30070 30074 30077 30080 30083 30084 30086 30087 30090 30098 30100 30101 30104 30106 30109 30110 30114 30117 30119 30119 30122 30123 30128 30134 30136 30149 30151 30152 30154 30162 30164 30165 30167 30180 30182 30183 30189 30189 30191 30211 30215 30221 30223 30225 30227 30230 30233 30249 30252 30253 30255 30261 30264 30264 30266 30269 30272 30272 30274 30275 30278 30281 30284 30292 30294 30298 30300 30300 30303 30306 30308 30311 30313 30314 30316 30326 30328 30335 30337 30338 30340 30340 30342 30347 30350 30352 30354 30355 30357 30358 30361 30366 30369 30369 30372 30374 30378 30379 30381 30384 30388 30389 30391 30392 30394 30395 30397 30399 30402 30406 30408 30410 30412 30414 30418 30420 30422 30422 30426 30431 30433 30433 30435 30439 30441 30442 30444 30453 30455 30460 30462 30462 30465 30465 30467 30469 30471 30476 30478 30483 30485 30485 30489 30491 30493 30496 30498 30505 30507 30507 30509 30509 30511 30511 30513 30526 30528 30528 30531 30535 30538 30543 30546 30546 30548 30550 30552 30556 30558 30563 30565 30575 30578 30578 30583 30597 30599 30601 30603 30607 30609 30609 30611 30611 30613 30613 30615 30627 30629 30629 30631 30632 30634 30637 30639 30647 30649 30655 30658 30661 30663 30663 30665 30672 30675 30677 30679 30684 30686 30686 30688 30688 30690 30691 30693 30697 30700 30708 30711 30718 30722 30723 30725 30726 30728 30729 30732 30740 30744 30744 30748 30755 30757 30773 30775 30777 30780 30781 30786 30789 30791 30798 30800 30804 30812 30814 30816 30816 30818 30818 30820 30822 30824 30833 30841 30844 30846 30849 30851 30857 30860 30863 30865 30865 30867 30874 30878 30885 30887 30893 30895 30900 30902 30902 30904 30908 30910 30910 30913 30913 30915 30917 30919 30933 30935 30936 30938 30939 30941 30947 30949 30949 30951 30954 30956 30965 30967 30967 30969 30975 30977 30978 30980 30982 30985 30985 30988 30988 30990 30990 30992 30996 30999 30999 31001 31001 31003 31006 31009 31009 31011 31023 31025 31030 31032 31042 31044 31052 31055 31077 31079 31083 31085 31085 31088 31092 31097 31098 31100 31107 31110 31112 31114 31115 31117 31133 31135 31138 31140 31150 31152 31156 31158 31163 31165 31169 31172 31174 31176 31177 31179 31183 31185 31186 31188 31190 31192 31192 31196 31200 31202 31204 31206 31207 31209 31214 31217 31217 31220 31220 31222 31224 31226 31227 31232 31232 31234 31238 31240 31240 31242 31245 31248 31253 31255 31260 31262 31264 31266 31266 31270 31270 31272 31272 31275 31275 31277 31281 31287 31287 31289 31296 31299 31310 31316 31316 31318 31320 31322 31324 31327 31330 31333 31333 31335 31337 31339 31342 31344 31345 31348 31350 31352 31355 31357 31361 31363 31372 31375 31378 31380 31385 31390 31392 31394 31395 31400 31404 31406 31416 31418 31420 31422 31429 31431 31435 31439 31439 31441 31441 31443 31443 31448 31453 31455 31456 31458 31463 31465 31467 31469 31471 31478 31479 31481 31483 31485 31489 31492 31494 31496 31500 31502 31508 31512 31515 31517 31520 31522 31541 31544 31545 31547 31547 31552 31552 31554 31570 31572 31574 31576 31576 31584 31591 31593 31593 31596 31608 31611 31611 31618 31618 31620 31621 31623 31624 31626 31634 31636 31641 31643 31645 31648 31652 31660 31661 31663 31663 31665 31666 31668 31669 31671 31673 31678 31678 31680 31681 31684 31684 31686 31687 31689 31692 31694 31696 31700 31701 31704 31723 31728 31732 31735 31747 31749 31751 31753 31762 31765 31765 31769 31769 31771 31779 31781 31789 31792 31792 31795 31795 31797 31797 31799 31801 31803 31808 31810 31813 31815 31818 31820 31821 31824 31825 31827 31828 31830 31831 31833 31837 31839 31840 31843 31847 31849 31856 31858 31861 31864 31873 31875 31878 31880 31882 31884 31886 31889 31890 31892 31896 31900 31900 31902 31903 31905 31907 31909 31912 31916 31916 31918 31919 31921 31925 31928 31935 31938 31938 31941 31941 31943 31950 31952 31959 31961 31962 31964 31968 31970 31970 31974 31976 31978 31978 31980 31993 31995 31998 32000 32034 32037 32037 32040 32041 32043 32044 32046 32051 32053 32054 32056 32071 32074 32074 32077 32086 32088 32088 32090 32095 32097 32099 32102 32107 32109 32115 32121 32125 32127 32129 32131 32134 32136 32137 32140 32143 32145 32148 32150 32151 32156 32164 32166 32181 32183 32194 32196 32199 32201 32208 32210 32212 32215 32225 32227 32234 32236 32236 32238 32247 32249 32251 32253 32254 32259 32259 32263 32279 32282 32293 32295 32295 32297 32299 32301 32329 32332 32332 32336 32346 32348 32348 32350 32355 32357 32357 32359 32363 32365 32368 32370 32386 32390 32392 32394 32399 32401 32412 32415 32415 32420 32420 32428 32428 32442 32442 32455 32455 32463 32463 32479 32479 32518 32518 32566 32570 32573 32577 32579 32581 32583 32597 32600 32600 32603 32609 32611 32611 32613 32622 32624 32627 32629 32639 32643 32643 32645 32655 32657 32663 32666 32670 32672 32681 32684 32707 32709 32709 32711 32711 32713 32722 32724 32725 32727 32727 32731 32739 32741 32757 32759 32776 32779 32786 32788 32793 32795 32801 32804 32806 32808 32810 32812 32812 32814 32817 32819 32823 32825 32825 32827 32831 32835 32835 32838 32840 32842 32842 32847 32850 32852 32852 32854 32854 32856 32856 32858 32862 32865 32868 32870 32871 32876 32876 32879 32883 32885 32889 32893 32896 32898 32898 32900 32903 32905 32908 32911 32912 32914 32915 32917 32918 32920 32925 32927 32927 32929 32931 32933 32933 32935 32935 32937 32939 32941 32943 32945 32946 32948 32952 32954 32954 32956 32957 32962 32970 32972 32977 32980 32990 32992 32993 32995 32998 33001 33001 33004 33005 33007 33014 33016 33022 33024 33027 33029 33034 33036 33036 33038 33038 33042 33042 33044 33051 33053 33055 33057 33061 33063 33063 33065 33069 33071 33072 33074 33074 33076 33076 33079 33079 33081 33082 33085 33086 33090 33092 33094 33096 33098 33110 33113 33116 33118 33118 33120 33122 33124 33127 33129 33129 33131 33131 33133 33140 33142 33146 33148 33148 33151 33152 33154 33156 33158 33165 33167 33167 33171 33171 33173 33173 33175 33184 33186 33187 33189 33196 33198 33198 33200 33207 33209 33226 33228 33229 33231 33234 33237 33237 33239 33243 33245 33258 33260 33263 33266 33268 33270 33276 33278 33282 33284 33285 33287 33293 33296 33298 33300 33302 33304 33304 33306 33314 33317 33318 33320 33325 33327 33327 33330 33338 33340 33344 33346 33346 33348 33349 33351 33351 33353 33353 33355 33355 33358 33372 33374 33375 33377 33382 33384 33385 33387 33391 33393 33394 33396 33408 33411 33413 33415 33415 33418 33419 33421 33428 33432 33435 33437 33457 33459 33470 33472 33472 33474 33476 33482 33482 33487 33497 33499 33500 33502 33512 33514 33527 33529 33545 33547 33549 33558 33566 33568 33568 33570 33570 33572 33581 33583 33583 33585 33597 33599 33605 33607 33620 33622 33623 33634 33635 33638 33638 33647 33647 33651 33656 33658 33663 33665 33665 33667 33667 33669 33694 33696 33696 33698 33708 33710 33712 33721 33721 33725 33743 33745 33745 33747 33753 33755 33765 33767 33782 33784 33791 33793 33793 33795 33799 33801 33812 33814 33814 33816 33816 33819 33820 33824 33825 33827 33828 33830 33830 33833 33833 33835 33856 33858 33870 33872 33897 33899 33914 33917 33920 33922 33922 33926 33926 33928 33928 33933 33940 33942 33956 33959 33970 33972 33972 33974 33974 33976 33986 33988 33991 33993 34004 34006 34007 34010 34011 34014 34014 34017 34018 34020 34021 34023 34028 34030 34036 34038 34048 34050 34051 34053 34074 34076 34081 34083 34097 34099 34100 34104 34104 34107 34107 34109 34110 34112 34126 34129 34139 34141 34142 34144 34161 34163 34163 34165 34172 34174 34174 34176 34193 34196 34198 34200 34212 34214 34218 34223 34225 34227 34234 34237 34249 34251 34251 34253 34258 34261 34261 34263 34266 34268 34278 34280 34290 34294 34306 34308 34311 34313 34317 34320 34321 34324 34324 34326 34332 34334 34346 34348 34351 34353 34358 34360 34364 34366 34368 34370 34371 34373 34376 34379 34382 34384 34384 34386 34390 34393 34393 34395 34396 34398 34399 34401 34405 34407 34420 34423 34423 34425 34428 34430 34430 34437 34439 34442 34446 34448 34458 34460 34462 34464 34469 34471 34474 34477 34477 34479 34505 34507 34508 34512 34513 34515 34516 34518 34527 34530 34532 34534 34534 34536 34541 34543 34543 34549 34555 34558 34558 34560 34574 34577 34579 34584 34588 34590 34590 34592 34602 34604 34606 34608 34613 34615 34616 34618 34620 34622 34627 34630 34630 34636 34673 34675 34683 34685 34685 34689 34697 34699 34701 34703 34708 34710 34712 34714 34719 34722 34725 34729 34758 34760 34764 34766 34766 34769 34772 34774 34792 34794 34799 34802 34807 34809 34812 34814 34822 34824 34829 34831 34833 34835 34841 34843 34845 34847 34867 34869 34873 34875 34886 34888 34888 34890 34895 34898 34899 34901 34903 34905 34907 34909 34910 34912 34917 34919 34923 34925 34930 34932 34935 34937 34937 34940 34948 34951 34953 34955 34958 34961 34963 34965 34972 34974 34978 34980 34980 34983 34984 34986 34988 34990 34990 34993 34994 34996 35002 35004 35010 35013 35013 35015 35015 35017 35024 35026 35026 35028 35039 35041 35041 35046 35048 35051 35052 35054 35074 35077 35079 35081 35084 35086 35086 35088 35098 35102 35103 35105 35111 35113 35123 35125 35128 35131 35134 35137 35140 35142 35143 35145 35145 35147 35149 35151 35156 35158 35174 35177 35183 35185 35188 35190 35191 35193 35196 35198 35203 35205 35211 35215 35215 35217 35217 35219 35224 35227 35231 35233 35239 35241 35242 35244 35247 35250 35250 35254 35255 35257 35258 35260 35265 35270 35270 35282 35286 35289 35293 35295 35305 35307 35309 35312 35316 35318 35320 35322 35324 35326 35328 35330 35332 35335 35336 35338 35338 35340 35340 35342 35347 35349 35352 35355 35359 35362 35363 35365 35365 35367 35367 35369 35373 35376 35377 35380 35380 35382 35382 35384 35393 35396 35398 35400 35402 35404 35410 35412 35417 35419 35419 35422 35422 35424 35427 35430 35433 35435 35438 35440 35447 35449 35452 35454 35455 35457 35463 35467 35469 35471 35478 35480 35482 35484 35484 35486 35486 35488 35489 35491 35499 35503 35504 35506 35506 35508 35508 35510 35510 35512 35520 35522 35529 35531 35531 35533 35533 35535 35535 35537 35554 35556 35556 35558 35560 35562 35563 35565 35576 35578 35580 35582 35586 35588 35592 35594 35616 35618 35624 35626 35633 35635 35635 35637 35639 35641 35651 35653 35674 35676 35680 35682 35683 35685 35693 35695 35696 35700 35700 35703 35707 35709 35714 35716 35718 35720 35720 35722 35724 35726 35726 35728 35728 35730 35734 35736 35740 35742 35744 35774 35774 35810 35810 35895 35895 35897 35897 35899 35903 35905 35907 35909 35921 35924 35927 35930 35930 35932 35933 35935 35935 35937 35938 35940 35942 35944 35949 35951 35955 35957 35963 35965 35965 35968 35970 35972 35974 35977 35978 35980 35981 35983 35989 35991 36005 36007 36013 36015 36016 36018 36037 36039 36040 36042 36042 36044 36045 36047 36047 36049 36055 36057 36078 36080 36085 36087 36094 36096 36096 36098 36109 36111 36121 36123 36125 36196 36196 36198 36201 36203 36208 36210 36212 36214 36219 36221 36221 36224 36226 36228 36229 36233 36234 36236 36246 36249 36249 36251 36252 36255 36257 36259 36259 36261 36271 36274 36279 36281 36282 36284 36284 36286 36291 36293 36296 36299 36305 36307 36317 36319 36324 36326 36332 36334 36340 36346 36346 36348 36359 36361 36362 36365 36395 36397 36398 36400 36401 36403 36406 36408 36410 36412 36418 36420 36432 36435 36439 36441 36458 36460 36461 36463 36463 36465 36472 36474 36476 36478 36478 36480 36482 36484 36494 36496 36504 36506 36506 36509 36513 36515 36525 36528 36528 36530 36530 36534 36534 36538 36538 36540 36541 36544 36544 36546 36547 36553 36559 36561 36564 36567 36568 36570 36578 36580 36585 36587 36591 36593 36594 36596 36604 36606 36611 36613 36619 36621 36622 36624 36640 36643 36646 36649 36650 36652 36656 36658 36665 36667 36667 36670 36683 36685 36708 36710 36711 36718 36718 36755 36755 36763 36764 36767 36768 36771 36771 36773 36774 36776 36776 36781 36796 36798 36799 36801 36802 36804 36806 36809 36814 36816 36823 36826 36826 36832 36838 36840 36840 36842 36843 36845 36846 36848 36848 36852 36870 36872 36872 36875 36877 36879 36882 36884 36887 36889 36900 36909 36911 36913 36920 36924 36927 36929 36930 36932 36932 36935 36935 36937 36950 36952 36953 36955 36958 36960 36964 36967 36969 36971 36976 36978 37000 37002 37003 37005 37005 37007 37009 37012 37013 37015 37017 37019 37019 37022 37027 37029 37032 37034 37034 37038 37046 37048 37048 37051 37051 37053 37055 37057 37057 37059 37061 37063 37064 37066 37067 37070 37070 37076 37085 37087 37093 37096 37101 37103 37109 37113 37129 37131 37131 37133 37138 37140 37140 37142 37156 37158 37174 37176 37179 37182 37185 37187 37203 37205 37210 37212 37212 37214 37221 37223 37226 37228 37228 37230 37232 37234 37242 37244 37244 37248 37255 37257 37267 37273 37283 37285 37285 37287 37303 37305 37310 37312 37319 37321 37321 37323 37329 37331 37338 37340 37341 37343 37343 37346 37358 37361 37361 37363 37365 37367 37370 37373 37386 37388 37399 37401 37402 37404 37404 37406 37406 37411 37416 37418 37419 37421 37422 37424 37434 37436 37441 37444 37446 37448 37464 37466 37467 37469 37479 37483 37488 37490 37490 37494 37519 37521 37521 37523 37533 37536 37548 37550 37550 37553 37559 37561 37564 37566 37589 37591 37593 37595 37595 37597 37601 37603 37612 37614 37620 37622 37636 37638 37641 37643 37648 37650 37654 37656 37659 37661 37681 37683 37686 37688 37689 37692 37692 37696 37714 37716 37724 37726 37742 37744 37745 37747 37758 37760 37770 37772 37778 37780 37802 37804 37813 37815 37816 37819 37819 37821 37821 37823 37824 37826 37828 37830 37832 37834 37860 37862 37864 37868 37868 37870 37870 37872 37873 37875 37875 37877 37889 37891 37892 37894 37913 37915 37915 37917 37917 37920 37920 37924 37934 37936 37939 37941 37952 37954 37965 37967 37970 37972 37973 37975 37976 37979 37979 37981 37982 37984 37984 37986 37989 37991 38009 38011 38019 38021 38021 38047 38047 38050 38050 38081 38081 38083 38083 38108 38108 38134 38134 38189 38189 38215 38215 38263 38264 38266 38269 38271 38272 38274 38275 38277 38278 38280 38281 38283 38292 38294 38297 38299 38300 38302 38318 38320 38321 38325 38327 38329 38336 38339 38339 38341 38349 38352 38358 38362 38364 38366 38373 38376 38376 38388 38388 38428 38430 38432 38436 38440 38440 38442 38442 38444 38451 38456 38461 38463 38469 38474 38481 38483 38484 38486 38486 38488 38488 38491 38495 38497 38500 38505 38509 38511 38520 38523 38526 38528 38529 38531 38539 38541 38543 38545 38553 38555 38556 38558 38558 38561 38565 38567 38570 38572 38572 38574 38574 38576 38577 38579 38580 38582 38582 38584 38585 38587 38589 38591 38606 38610 38623 38625 38627 38629 38629 38632 38634 38639 38642 38644 38651 38653 38653 38655 38656 38658 38665 38667 38667 38669 38675 38678 38678 38680 38681 38683 38700 38702 38706 38709 38710 38712 38714 38717 38724 38726 38729 38731 38731 38737 38738 38742 38744 38746 38754 38758 38758 38760 38762 38764 38766 38768 38772 38774 38776 38778 38789 38791 38795 38797 38799 38804 38804 38807 38822 38824 38824 38826 38830 38833 38836 38838 38843 38845 38857 38859 38864 38866 38873 38876 38881 38883 38883 38885 38886 38893 38894 38896 38899 38901 38902 38904 38907 38909 38920 38922 38922 38924 38936 38939 38945 38947 38948 38950 38953 38955 38955 38957 38960 38962 38965 38967 38969 38971 38971 38977 38977 38979 38995 38999 39001 39003 39008 39010 39015 39017 39020 39023 39029 39080 39081 39084 39087 39089 39092 39094 39108 39110 39116 39118 39118 39131 39132 39134 39139 39141 39143 39145 39149 39151 39151 39153 39154 39156 39158 39161 39162 39164 39166 39168 39168 39170 39171 39173 39173 39175 39178 39180 39180 39182 39182 39184 39196 39198 39199 39201 39201 39204 39205 39207 39219 39221 39221 39223 39235 39237 39237 39239 39246 39248 39257 39259 39263 39265 39267 39318 39321 39323 39326 39329 39329 39331 39336 39338 39349 39352 39357 39361 39365 39367 39367 39369 39369 39371 39389 39391 39391 39393 39399 39401 39402 39404 39406 39408 39409 39412 39423 39425 39431 39433 39441 39444 39446 39449 39463 39465 39474 39476 39494 39496 39498 39500 39504 39506 39516 39518 39520 39522 39532 39567 39567 39592 39592 39595 39595 39597 39597 39599 39604 39606 39618 39622 39623 39626 39626 39629 39629 39631 39640 39644 39644 39647 39651 39654 39655 39659 39663 39665 39668 39670 39671 39673 39679 39681 39686 39688 39698 39700 39706 39710 39712 39714 39717 39719 39723 39725 39727 39729 39733 39735 39735 39737 39740 39742 39750 39752 39752 39754 39762 39764 39766 39768 39771 39775 39777 39780 39780 39782 39785 39788 39788 39791 39793 39796 39799 39802 39811 39813 39816 39819 39819 39821 39827 39829 39829 39831 39831 39834 39835 39837 39842 39844 39846 39848 39848 39850 39851 39853 39856 39861 39862 39864 39865 39869 39869 39871 39873 39875 39876 39878 39882 39887 39887 39891 39895 39897 39902 39904 39906 39908 39917 39920 39921 39924 39924 39927 39928 39933 39933 39935 39935 39938 39938 39941 39950 39952 39952 39954 39957 39959 39959 39963 39965 39967 39969 39971 39974 39976 39977 39979 39981 39983 39983 39985 39991 39993 40001 40004 40006 40008 40016 40018 40025 40029 40032 40034 40035 40038 40040 40045 40046 40049 40053 40055 40060 40165 40167 40169 40170 40173 40173 40177 40183 40185 40189 40191 40192 40194 40201 40204 40204 40208 40208 40210 40210 40212 40217 40219 40219 40221 40227 40229 40230 40232 40233 40237 40241 40243 40244 40246 40249 40251 40251 40253 40261 40265 40268 40270 40276 40278 40289 40295 40309 40311 40313 40315 40332 40336 40336 40338 40340 40342 40365 40367 40367 40369 40389 40391 40415 40417 40422 40424 40425 40427 40432 40434 40455 40457 40469 40471 40479 40565 40565 40569 40573 40575 40590 40592 40610 40612 40625 40628 40631 40635 40644 40646 40648 40652 40657 40659 40662 40664 40664 40666 40672 40674 40674 40676 40680 40683 40683 40685 40706 40710 40714 40718 40720 40722 40723 40725 40732 40734 40734 40736 40736 40738 40761 40763 40763 40765 40766 40768 40784 40786 40807 40809 40812 40814 40818 40820 40827 40830 40831 40845 40846 40848 40850 40852 40853 40856 40857 40860 40860 40863 40864 40866 40866 40868 40869 57347 57347 57368 57368 57371 57371 57389 57389 57400 57400 57420 57420 57434 57434 57492 57492 57497 57498 57541 57541 57552 57552 57586 57586 57593 57593 57597 57597 57606 57606 57609 57610 57648 57648 57680 57680 57684 57684 57693 57693 57704 57704 57706 57706 57713 57713 57717 57717 57743 57743 57787 57787 57804 57805 57815 57815 57839 57839 57842 57842 57850 57850 57854 57854 57858 57858 57867 57867 57881 57881 57884 57884 57895 57895 57925 57925 57930 57930 57934 57934 57963 57963 57978 57978 57986 57986 58000 58000 58011 58011 58017 58017 58034 58034 58039 58039 58049 58049 58057 58057 58068 58068 58082 58082 58091 58092 58096 58097 58112 58112 58129 58129 58149 58149 58160 58160 58181 58181 58210 58210 58241 58242 58246 58246 58249 58249 58260 58260 58262 58262 58270 58270 58272 58272 58292 58292 58299 58299 58317 58317 58319 58319 58325 58325 58337 58337 58343 58343 58352 58352 58354 58354 58356 58356 58406 58406 58422 58422 58440 58440 58445 58445 58448 58448 58471 58473 58484 58484 58506 58506 58529 58529 58561 58561 58566 58566 58589 58589 58654 58654 58660 58660 58664 58664 58670 58671 58733 58733 58736 58736 58746 58746 58749 58749 58756 58756 58763 58763 58778 58778 58782 58782 58784 58784 58790 58790 58794 58794 58818 58818 58824 58824 58840 58840 58865 58865 58905 58905 58908 58908 58950 58950 58964 58964 58976 58976 58986 58986 59005 59005 59008 59008 59022 59022 59031 59031 59038 59038 59072 59072 59077 59077 59102 59103 59137 59137 59155 59155 59173 59173 59197 59197 59201 59201 59218 59218 59229 59229 59233 59233 59240 59240 59253 59253 59258 59258 59261 59261 59280 59280 59287 59287 59302 59302 59316 59316 59354 59354 59357 59357 59368 59369 59373 59373 59377 59377 59387 59388 59392 59392 59404 59404 59411 59411 59425 59425 59432 59432 59437 59437 59439 59439 59469 59469 59477 59478 59483 59483 59485 59485 59493 59493 59527 59527 59535 59535 59537 59537 59553 59553 59556 59556 59586 59587 59597 59597 59605 59606 59609 59610 59617 59617 59621 59621 59646 59646 59671 59672 59679 59679 59685 59685 59691 59691 59700 59700 59728 59728 59751 59751 59758 59759 59763 59763 59767 59767 59770 59771 59773 59773 59778 59778 59793 59793 59851 59851 60073 60073 60095 60097 60101 60101 60105 60108 60111 60113 60115 60116 60118 60119 60121 60122 60124 60124 60126 60131 60135 60135 60137 60138 60140 60140 60142 60142 60144 60145 60149 60150 60152 60155 60159 60160 60162 60165 60168 60175 60178 60178 60181 60181 60185 60189 60191 60192 60195 60195 60197 60197 60199 60199 60202 60202 60204 60206 60208 60217 60221 60223 60227 60228 60234 60234 60237 60238 60243 60243 60245 60246 60248 60248 60250 60251 60258 60259 60261 60261 60263 60265 60271 60273 60275 60275 60278 60279 60282 60282 60286 60288 60291 60291 60296 60296 60298 60298 60300 60300 60304 60304 60307 60307 60309 60309 60313 60313 60315 60315 60319 60319 60322 60322 60325 60326 60330 60331 60334 60334 60338 60339 60349 60349 60351 60351 60357 60357 60362 60362 60364 60364 60366 60366 60368 60368 60373 60373 60375 60376 60378 60379 60381 60381 60383 60383 60385 60385 60388 60388 60392 60393 60395 60396 60399 60399 60402 60402 60405 60405 60409 60410 60414 60414 60424 60425 60431 60431 60435 60435 60441 60444 60452 60452 60454 60454 60459 60459 60463 60463 60466 60466 60479 60479 60483 60489 60491 60491 60495 60495 60498 60498 60500 60500 60502 60504 60506 60506 60508 60509 60512 60512 60514 60515 60519 60519 60521 60525 60527 60528 60530 60531 60533 60533 60537 60537 60539 60539 60542 60542 60548 60548 60558 60558 60562 60562 60565 60565 60591 60591 60598 60598 60623 60623 60636 60636 60640 60641 60656 60656 60658 60658 60668 60668 60689 60689 60701 60701 60708 60708 60713 60713 60716 60716 60731 60731 60737 60737 60751 60751 60754 60754 60767 60767 60779 60779 60792 60792 60804 60805 60808 60808 60811 60811 60814 60814 60879 60879 60890 60890 60909 60909 60936 60936 61021 61021 61034 61034 61093 61093 61104 61104 61108 61108 61111 61111 62211 62232 62245 62245 62247 62247 62276 62276 62278 62278 62282 62283 62369 62369 62448 62448 62457 62457 62460 62460 62472 62472 62475 62475 62525 62525 62529 62530 62537 62537 62541 62541 62544 62544 62548 62548 62554 62557 62562 62562 62565 62566 62569 62569 62573 62575 62583 62584 62588 62590 62592 62592 62597 62597 62600 62600 62603 62603 62605 62605 62607 62609 62615 62616 62619 62619 62628 62628 62631 62631 62634 62634 62637 62637 62639 62639 62643 62644 62647 62647 62650 62653 62656 62657 62659 62659 62664 62664 62670 62671 62674 62674 62690 62690 62693 62693 62695 62697 62707 62707 62754 62755 62757 62758 62762 62762 62778 62779 62781 62781 62798 62798 62803 62803 62806 62806 62809 62810 62814 62814 62821 62821 62827 62827 62834 62834 63152 63152 63461 63462 63464 63464 63466 63467 63469 63470 64012 64013 65072 65073 65075 65092 65097 65104 65106 65106 65108 65111 65113 65126 65129 65131 65281 65341 65343 65343 65345 65373 65380 65380 65506 65506 65508 65508 65517 65517 131134 131134 131142 131142 131150 131150 131176 131176 131310 131310 131352 131352 131499 131499 131521 131521 131540 131540 131604 131604 131675 131675 131700 131701 131737 131737 131742 131742 131744 131744 131775 131776 131813 131813 131850 131850 131877 131877 131905 131905 131909 131911 131966 131968 132007 132007 132021 132021 132041 132041 132043 132043 132085 132085 132092 132092 132115 132116 132127 132127 132197 132197 132231 132231 132241 132242 132259 132259 132348 132348 132350 132350 132423 132423 132494 132494 132517 132517 132531 132531 132560 132560 132575 132576 132587 132587 132625 132625 132633 132634 132656 132656 132878 132878 132985 132985 133164 133164 133235 133235 133398 133398 133460 133460 133497 133497 133649 133649 133712 133712 133812 133812 134031 134031 134056 134056 134086 134086 134114 134114 134143 134143 134176 134176 134209 134211 134227 134227 134263 134264 134300 134300 134351 134351 134355 134358 134470 134473 134476 134478 134526 134527 134567 134567 134665 134666 134669 134673 134678 134678 134685 134685 134765 134765 134773 134779 134826 134828 134838 134838 134904 134907 134957 134958 134960 134961 134971 134971 135053 135053 135085 135085 135092 135094 135146 135149 135197 135198 135279 135279 135285 135288 135291 135291 135348 135348 135360 135361 135367 135369 135412 135414 135485 135485 135496 135496 135552 135552 135559 135559 135641 135641 135759 135759 135804 135804 135849 135849 135856 135856 135907 135907 135934 135934 135938 135941 135994 135994 136092 136092 136133 136134 136173 136173 136190 136190 136274 136274 136276 136277 136343 136343 136374 136374 136424 136424 136445 136445 136598 136598 136714 136714 136723 136723 136766 136766 136801 136801 136850 136850 136896 136898 136915 136915 136917 136917 136934 136936 136954 136956 136958 136958 136976 136976 136998 136998 137018 137020 137047 137047 137068 137073 137075 137076 137137 137141 137177 137180 137205 137206 137208 137212 137256 137258 137274 137275 137285 137285 137310 137310 137313 137316 137339 137339 137347 137349 137374 137378 137406 137407 137430 137433 137466 137466 137475 137477 137488 137490 137493 137493 137511 137511 137531 137531 137540 137540 137596 137596 137608 137608 137622 137622 137691 137691 137715 137715 137803 137803 138052 138052 138402 138402 138405 138405 138566 138566 138682 138682 138698 138698 138705 138705 138745 138745 138807 138807 138889 138889 138916 138916 138920 138920 138965 138965 139114 139114 139169 139169 139337 139337 139418 139418 139463 139463 139516 139516 139562 139562 139635 139635 139642 139642 139681 139681 139715 139715 139900 139900 140065 140065 140069 140069 140221 140221 140240 140240 140389 140389 140401 140401 140427 140427 140563 140563 140571 140571 140592 140592 140685 140685 140719 140719 140734 140734 140827 140828 140843 140843 140904 140904 140950 140950 140952 140952 141044 141046 141083 141083 141087 141087 141173 141173 141185 141185 141236 141237 141315 141315 141407 141408 141485 141485 141505 141505 141559 141559 141625 141625 141675 141675 141696 141696 142031 142031 142037 142037 142114 142114 142186 142186 142286 142286 142374 142375 142417 142417 142421 142421 142491 142491 142497 142497 142534 142534 142599 142600 142695 142695 142752 142752 142755 142756 142861 142861 142902 142902 142968 142968 143331 143331 143435 143435 143485 143486 143502 143502 143543 143543 143548 143548 143578 143578 143619 143619 143677 143677 143746 143746 143780 143781 143816 143817 143863 143865 143909 143909 143919 143919 143921 143924 143970 143970 144009 144010 144043 144045 144082 144082 144096 144097 144128 144128 144138 144138 144308 144308 144358 144358 144372 144373 144382 144382 144384 144384 144464 144464 144498 144498 144613 144613 144688 144688 144730 144730 144789 144789 144793 144793 144796 144796 144845 144847 144896 144896 144956 144956 144960 144960 145015 145015 145062 145062 145069 145069 145082 145082 145119 145119 145134 145134 145184 145184 145199 145199 145215 145215 145254 145254 145281 145281 145314 145314 145340 145340 145346 145346 145365 145367 146139 146139 146158 146158 146266 146266 146585 146587 146615 146615 146631 146633 146684 146687 146779 146779 146870 146877 146936 146936 146988 146993 147080 147083 147135 147135 147191 147196 147253 147253 147265 147265 147327 147330 147383 147383 147392 147392 147435 147440 147473 147473 147513 147517 147543 147543 147595 147597 147657 147657 147716 147716 147775 147776 147780 147780 147797 147799 147804 147804 147807 147807 147834 147834 147875 147877 147938 147938 147964 147964 147995 147995 148043 148043 148054 148054 148057 148057 148086 148088 148133 148133 148169 148170 148218 148218 148250 148250 148296 148296 148322 148325 148364 148364 148374 148374 148380 148380 148413 148413 148417 148417 148457 148457 148466 148466 148472 148472 148533 148534 148570 148571 148615 148616 148665 148665 148686 148686 148691 148691 148769 148769 148856 148856 149034 149034 149093 149093 149143 149143 149204 149204 149254 149254 149285 149285 149391 149391 149539 149539 149747 149747 149759 149761 149772 149772 149782 149783 149785 149785 149807 149807 149811 149811 149822 149826 149858 149859 149876 149878 149887 149887 149896 149903 149927 149927 149931 149933 149943 149947 149982 149983 149987 149987 150006 150009 150049 150058 150078 150078 150094 150097 150117 150119 150135 150138 150163 150166 150180 150183 150193 150195 150202 150204 150215 150215 150225 150225 150239 150239 150242 150242 150382 150382 150517 150517 150537 150537 150686 150687 150745 150745 150790 150790 150968 150968 151018 151019 151120 151120 151310 151310 151388 151388 151426 151426 151447 151447 151450 151450 151465 151465 151490 151490 151709 151709 151880 151880 151933 151934 152035 152035 152038 152039 152096 152097 152263 152263 152280 152280 152337 152337 152339 152339 152613 152613 152623 152624 152684 152684 152686 152686 152923 152925 152933 152934 152961 152961 152964 152964 152975 152975 153017 153017 153045 153045 153051 153051 153056 153056 153141 153141 153169 153169 153219 153219 153334 153334 153350 153350 153373 153373 153381 153381 153458 153458 153543 153543 153568 153569 153687 153687 153714 153714 153825 153825 153942 153942 154028 154028 154268 154268 154286 154286 154345 154345 154484 154484 154547 154548 154566 154566 154625 154625 154630 154630 154698 154698 154725 154725 154816 154817 154878 154878 154912 154912 154947 154947 155150 155150 155265 155267 155302 155302 155324 155324 155351 155352 155467 155467 155617 155618 155689 155689 155748 155748 155812 155813 155937 155937 155993 155996 156077 156078 156125 156125 156248 156248 156257 156257 156368 156368 156497 156497 156606 156606 156688 156690 156809 156809 156824 156824 156946 156946 157042 157042 157101 157101 157222 157222 157359 157359 157361 157361 157416 157416 157505 157505 157619 157620 157644 157644 157790 157790 157806 157806 157832 157832 157843 157843 157966 157966 157969 157969 158120 158120 158133 158133 158194 158194 158202 158202 158254 158254 158274 158274 158289 158290 158474 158474 158504 158504 158544 158547 158614 158615 158643 158643 158711 158711 158753 158753 158846 158850 158903 158904 158909 158909 158912 158912 159010 159018 159136 159143 159196 159196 159210 159211 159216 159216 159237 159237 159298 159301 159342 159342 159346 159346 159351 159351 159364 159364 159440 159447 159526 159526 159603 159604 159647 159647 159649 159649 159710 159711 159758 159758 159826 159827 159917 159919 159949 159949 159992 159992 160009 160009 160012 160012 160038 160039 160100 160101 160117 160117 160283 160283 160486 160486 160666 160666 160802 160802 160900 160900 160902 160902 161248 161248 161252 161252 161277 161278 161292 161292 161330 161330 161337 161337 161365 161367 161428 161428 161551 161551 161589 161590 161601 161601 161630 161630 161668 161669 161904 161904 162084 162084 162151 162151 162318 162318 162393 162393 162493 162494 162548 162548 162584 162584 162616 162618 162804 162804 162834 162834 163119 163119 163155 163156 163187 163187 163215 163215 163224 163224 163261 163261 163292 163292 163405 163405 163407 163407 163842 163842 163849 163849 164029 164030 164073 164073 164084 164084 164142 164142 164207 164207 164359 164359 164438 164438 164557 164557 164578 164578 164666 164666 164709 164709 164733 164733 164882 164882 164994 164994 165180 165181 165228 165228 165364 165364 165376 165376 165387 165387 165413 165413 165435 165435 165546 165547 165592 165592 165606 165606 165892 165892 165931 165931 166195 166195 166216 166217 166252 166252 166270 166270 166281 166281 166312 166312 166314 166315 166332 166332 166336 166336 166364 166364 166366 166366 166369 166369 166372 166372 166393 166396 166415 166415 166422 166422 166437 166437 166441 166441 166468 166475 166489 166490 166529 166531 166554 166556 166598 166598 166603 166604 166622 166627 166629 166629 166668 166668 166689 166690 166699 166701 166703 166703 166732 166732 166734 166734 166736 166736 166755 166758 166764 166764 166799 166799 166809 166809 166812 166813 166850 166850 166853 166853 166871 166871 166873 166874 166887 166892 166911 166911 166941 166941 166947 166947 166955 166955 166960 166960 166969 166969 167117 167117 167220 167220 167478 167478 167525 167526 167602 167603 167641 167641 168075 168075 168111 168113 168164 168165 168205 168205 168208 168208 168348 168348 168360 168360 168427 168427 168989 168989 169011 169011 169032 169032 169177 169178 169374 169374 169449 169449 170071 170071 170148 170148 170218 170218 170243 170243 170245 170245 170287 170287 170333 170333 170346 170346 170397 170397 170757 170757 170766 170766 170965 170965 171181 171181 171326 171326 171388 171388 171565 171565 171624 171624 171692 171692 171715 171715 171811 171811 171824 171824 171959 171959 172257 172257 172275 172275 172280 172280 172286 172286 172323 172323 172368 172368 172434 172435 172511 172511 172576 172576 172595 172595 172703 172703 172722 172722 172767 172767 172969 172969 173510 173510 173737 173737 194624 194624 194708 194708 194765 194765 194964 194964 195028 195028 917504 917631)) (make-character-set :mib-enum 3 :name "ANSI_X3.4-1968" :aliases '("csASCII" "cp367" "IBM367" "us" #19="US-ASCII" "ISO646-US" "ASCII" "ISO_646.irv:1991" "ANSI_X3.4-1986" "iso-ir-6") :mime-encoding '#19# :source '"ECMA registry" :comments '("Alias: US-ASCII (preferred MIME name)") :references '("[RFC1345,KXS2]") :ranges #(0 127)) (make-character-set :mib-enum 2050 :name "IBM863" :aliases '("csIBM863" "863" "cp863") :mime-encoding 'nil :source '"IBM Keyboard layouts and code pages, PN 07G4586 June 1991" :comments 'nil :references '("[RFC1345,KXS2]") :ranges #(0 127 160 160 162 164 166 168 171 172 175 180 182 184 187 190 192 192 194 194 199 203 206 207 212 212 217 217 219 220 223 224 226 226 231 235 238 239 243 244 247 247 249 252 402 402 915 915 920 920 931 931 934 934 937 937 945 945 948 949 956 956 960 960 963 964 966 966 8215 8215 8319 8319 8729 8730 8734 8734 8745 8745 8776 8776 8801 8801 8804 8805 8976 8976 8992 8993 9472 9472 9474 9474 9484 9484 9488 9488 9492 9492 9496 9496 9500 9500 9508 9508 9516 9516 9524 9524 9532 9532 9552 9580 9600 9600 9604 9604 9608 9608 9612 9612 9616 9619 9632 9632)) (make-character-set :mib-enum 1015 :name "UTF-16" :aliases 'nil :mime-encoding 'nil :source '"RFC 2781" :comments 'nil :references '("[RFC2781]") :ranges #(0 55295 57344 1114111)) (make-character-set :mib-enum 37 :name #20="ISO-2022-KR" :aliases '("csISO2022KR") :mime-encoding '#20# :source '"RFC-1557 (see also KS_C_5601-1987)" :comments 'nil :references '("[RFC1557,Choi]") :ranges #(0 127 161 161 164 164 167 168 170 170 173 174 176 180 182 186 188 191 198 198 208 208 215 216 222 223 230 230 240 240 247 248 254 254 273 273 294 295 305 307 312 312 319 322 329 331 338 339 358 359 711 711 720 720 728 731 733 733 913 929 931 937 945 961 963 969 1025 1025 1040 1103 1105 1105 8213 8213 8216 8217 8220 8221 8224 8225 8229 8230 8240 8240 8242 8243 8251 8251 8308 8308 8319 8319 8321 8324 8364 8364 8451 8451 8457 8457 8467 8467 8470 8470 8481 8482 8486 8486 8491 8491 8531 8532 8539 8542 8544 8553 8560 8569 8592 8601 8658 8658 8660 8660 8704 8704 8706 8707 8711 8712 8715 8715 8719 8719 8721 8721 8730 8730 8733 8734 8736 8736 8741 8741 8743 8748 8750 8750 8756 8757 8764 8765 8786 8786 8800 8801 8804 8805 8810 8811 8834 8835 8838 8839 8857 8857 8869 8869 8978 8978 9312 9326 9332 9346 9372 9397 9424 9449 9472 9475 9484 9547 9618 9618 9632 9633 9635 9641 9650 9651 9654 9655 9660 9661 9664 9665 9670 9672 9675 9675 9678 9681 9733 9734 9742 9743 9756 9756 9758 9758 9792 9792 9794 9794 9824 9825 9827 9829 9831 9834 9836 9837 12288 12291 12296 12305 12307 12309 12353 12435 12449 12534 12593 12686 12800 12828 12896 12923 12927 12927 13184 13188 13192 13258 13263 13264 13267 13267 13270 13270 13272 13272 13275 13277 19968 19969 19971 19971 19975 19979 19981 19981 19985 19985 19988 19990 19992 19993 19998 19998 20013 20013 20018 20018 20024 20025 20027 20027 20034 20035 20037 20037 20043 20043 20045 20047 20054 20054 20056 20057 20061 20063 20075 20075 20077 20077 20083 20083 20086 20087 20094 20094 20098 20098 20102 20102 20104 20104 20107 20108 20110 20110 20112 20114 20116 20117 20120 20120 20123 20123 20126 20126 20129 20130 20132 20134 20136 20136 20139 20142 20150 20150 20154 20154 20160 20161 20164 20164 20167 20167 20170 20171 20173 20173 20180 20185 20189 20189 20191 20191 20195 20197 20208 20208 20210 20210 20214 20215 20219 20219 20225 20225 20233 20235 20237 20241 20271 20271 20276 20276 20278 20278 20280 20280 20282 20282 20284 20285 20291 20291 20294 20296 20301 20305 20309 20309 20313 20316 20329 20329 20335 20336 20339 20339 20342 20342 20346 20346 20350 20351 20353 20353 20355 20356 20358 20358 20360 20360 20362 20363 20365 20365 20367 20367 20369 20369 20374 20374 20376 20376 20379 20379 20381 20381 20398 20399 20405 20406 20415 20415 20418 20420 20425 20426 20430 20430 20433 20433 20435 20436 20439 20439 20442 20442 20445 20445 20447 20449 20462 20463 20465 20465 20467 20467 20469 20469 20472 20472 20474 20474 20482 20482 20486 20486 20489 20489 20491 20491 20493 20493 20497 20498 20502 20502 20505 20506 20508 20508 20510 20511 20513 20513 20515 20516 20518 20520 20522 20525 20539 20539 20547 20547 20551 20553 20559 20559 20565 20565 20570 20570 20572 20572 20581 20581 20596 20598 20600 20600 20608 20608 20613 20613 20621 20621 20625 20625 20632 20633 20652 20653 20658 20659 20661 20661 20663 20663 20670 20670 20677 20677 20681 20682 20687 20687 20689 20689 20693 20694 20698 20698 20702 20702 20709 20709 20711 20711 20717 20717 20729 20729 20731 20731 20735 20737 20740 20740 20742 20742 20745 20745 20754 20754 20767 20767 20769 20769 20778 20778 20786 20786 20791 20791 20794 20794 20796 20796 20800 20801 20803 20809 20811 20814 20818 20818 20828 20828 20834 20834 20837 20837 20839 20846 20849 20849 20853 20856 20860 20860 20864 20864 20870 20870 20874 20874 20877 20877 20882 20882 20885 20885 20887 20887 20896 20896 20901 20901 20906 20906 20908 20908 20918 20919 20925 20925 20932 20932 20934 20934 20937 20937 20939 20941 20956 20958 20961 20961 20976 20977 20982 20982 20984 20986 20989 20989 20992 20992 20995 20995 20998 21000 21002 21002 21006 21006 21009 21009 21015 21015 21021 21021 21028 21029 21033 21034 21038 21038 21040 21040 21046 21051 21059 21059 21063 21063 21066 21069 21076 21076 21078 21078 21083 21083 21085 21085 21089 21089 21097 21098 21103 21103 21106 21106 21109 21109 21117 21117 21119 21119 21123 21123 21127 21129 21133 21133 21137 21138 21147 21147 21151 21152 21155 21156 21161 21163 21182 21182 21185 21185 21187 21187 21189 21189 21191 21191 21193 21193 21197 21197 21202 21202 21205 21206 21208 21209 21211 21211 21213 21215 21218 21220 21235 21235 21237 21237 21240 21240 21242 21243 21246 21247 21253 21253 21256 21256 21261 21261 21263 21264 21269 21271 21273 21273 21280 21281 21283 21283 21290 21290 21295 21295 21305 21305 21311 21313 21315 21316 21319 21322 21325 21325 21329 21332 21335 21335 21338 21338 21340 21340 21342 21342 21344 21344 21350 21350 21352 21352 21359 21361 21364 21365 21367 21367 21373 21373 21375 21375 21380 21380 21395 21395 21400 21400 21402 21402 21407 21408 21413 21414 21421 21421 21435 21435 21443 21443 21448 21451 21453 21453 21460 21460 21462 21463 21467 21467 21473 21477 21481 21485 21487 21491 21496 21496 21507 21508 21512 21514 21516 21521 21531 21531 21533 21533 21535 21536 21542 21542 21545 21545 21547 21547 21555 21555 21560 21561 21563 21564 21566 21566 21570 21570 21576 21576 21578 21578 21585 21585 21608 21608 21610 21610 21617 21617 21619 21619 21621 21621 21627 21629 21632 21632 21638 21638 21644 21644 21646 21646 21648 21648 21668 21668 21672 21672 21675 21676 21683 21683 21688 21688 21693 21693 21696 21697 21700 21700 21704 21705 21729 21729 21733 21733 21736 21736 21741 21742 21746 21746 21754 21754 21764 21764 21766 21767 21774 21774 21776 21776 21788 21788 21807 21807 21809 21809 21813 21813 21822 21822 21828 21828 21830 21830 21839 21839 21843 21843 21846 21846 21854 21854 21859 21859 21884 21884 21888 21888 21892 21892 21894 21895 21897 21898 21912 21914 21916 21917 21927 21927 21929 21932 21934 21934 21957 21957 21959 21959 21972 21972 21978 21978 21980 21980 21983 21983 21987 21988 22013 22014 22022 22022 22025 22025 22036 22036 22039 22039 22063 22063 22066 22066 22068 22068 22070 22070 22099 22099 22120 22120 22123 22123 22132 22132 22150 22150 22181 22181 22188 22188 22190 22190 22196 22196 22204 22204 22218 22218 22221 22221 22225 22225 22234 22235 22238 22238 22240 22240 22256 22256 22265 22266 22275 22276 22280 22280 22283 22283 22285 22285 22290 22291 22294 22294 22296 22296 22303 22303 22312 22312 22317 22317 22320 22320 22331 22331 22336 22336 22338 22338 22343 22343 22346 22346 22349 22350 22352 22353 22369 22369 22372 22372 22374 22374 22378 22378 22382 22382 22384 22384 22389 22389 22396 22396 22402 22402 22408 22408 22411 22411 22419 22419 22432 22432 22434 22435 22467 22467 22471 22472 22475 22475 22478 22478 22495 22496 22512 22512 22516 22516 22519 22519 22521 22522 22524 22524 22528 22528 22530 22530 22533 22534 22536 22538 22558 22558 22561 22561 22564 22564 22567 22567 22570 22570 22575 22577 22580 22581 22586 22586 22602 22603 22607 22607 22609 22609 22612 22612 22615 22616 22618 22618 22622 22622 22625 22626 22628 22628 22645 22645 22649 22649 22652 22652 22654 22654 22659 22659 22661 22661 22665 22665 22675 22675 22684 22684 22686 22687 22696 22697 22702 22702 22707 22707 22714 22715 22718 22718 22721 22721 22725 22725 22727 22727 22734 22734 22737 22737 22739 22739 22741 22741 22744 22745 22750 22751 22756 22756 22763 22764 22767 22767 22777 22779 22781 22781 22799 22799 22804 22806 22809 22810 22812 22812 22818 22818 22823 22823 22825 22827 22829 22830 22833 22833 22839 22839 22846 22846 22852 22852 22855 22857 22862 22865 22868 22869 22871 22871 22874 22874 22880 22880 22882 22882 22887 22887 22890 22894 22899 22900 22904 22904 22909 22909 22914 22916 22922 22922 22931 22931 22934 22935 22937 22937 22949 22949 22952 22952 22956 22956 22969 22969 22971 22971 22974 22974 22979 22979 22982 22982 22985 22985 22987 22987 22992 22993 22995 22996 23001 23002 23004 23005 23014 23014 23016 23016 23018 23018 23020 23020 23022 23022 23032 23032 23035 23035 23039 23039 23041 23041 23043 23043 23057 23057 23064 23064 23067 23068 23071 23072 23077 23077 23081 23081 23094 23094 23100 23100 23105 23105 23110 23110 23113 23113 23130 23130 23138 23138 23142 23142 23186 23186 23194 23195 23204 23204 23233 23234 23236 23236 23241 23241 23244 23244 23265 23265 23270 23270 23273 23273 23301 23301 23305 23305 23307 23308 23318 23318 23338 23338 23360 23360 23363 23363 23376 23377 23380 23381 23383 23384 23386 23386 23388 23389 23391 23391 23395 23396 23401 23401 23403 23403 23408 23409 23413 23413 23416 23416 23418 23418 23420 23420 23429 23429 23431 23433 23435 23436 23439 23439 23443 23443 23445 23452 23458 23462 23468 23468 23470 23470 23472 23472 23475 23478 23480 23481 23487 23488 23490 23495 23500 23500 23504 23504 23506 23508 23511 23511 23518 23519 23521 23522 23524 23529 23531 23532 23534 23535 23541 23542 23544 23544 23546 23546 23553 23553 23556 23556 23559 23563 23565 23567 23569 23569 23574 23574 23577 23577 23588 23588 23592 23592 23601 23601 23608 23612 23614 23616 23621 23622 23624 23624 23627 23627 23629 23630 23633 23633 23637 23637 23643 23643 23648 23648 23650 23650 23652 23653 23660 23660 23663 23663 23665 23665 23673 23673 23696 23697 23713 23713 23721 23721 23723 23724 23729 23729 23731 23731 23733 23733 23735 23736 23738 23738 23742 23742 23744 23744 23769 23769 23776 23776 23784 23784 23791 23792 23796 23796 23798 23798 23803 23803 23805 23805 23815 23815 23821 23822 23825 23825 23828 23828 23830 23831 23833 23833 23847 23847 23849 23849 23883 23884 23888 23888 23913 23913 23916 23916 23919 23919 23943 23943 23947 23947 23965 23965 23968 23968 23970 23970 23978 23978 23992 23992 23994 23994 23996 23997 24013 24013 24018 24018 24022 24022 24029 24030 24033 24034 24037 24040 24043 24043 24046 24046 24049 24052 24055 24055 24061 24062 24066 24067 24070 24070 24076 24076 24081 24081 24086 24086 24089 24089 24091 24091 24093 24093 24101 24101 24107 24107 24109 24109 24115 24115 24118 24118 24120 24120 24125 24125 24127 24128 24132 24133 24135 24135 24140 24140 24149 24149 24159 24159 24161 24163 24178 24180 24183 24185 24187 24190 24196 24196 24199 24199 24202 24202 24207 24207 24213 24213 24215 24215 24218 24218 24220 24220 24224 24224 24230 24231 24235 24235 24237 24237 24245 24248 24254 24254 24258 24258 24264 24266 24272 24272 24275 24275 24278 24278 24282 24283 24287 24288 24290 24291 24300 24300 24307 24307 24310 24311 24314 24315 24321 24321 24324 24324 24330 24330 24335 24335 24337 24337 24339 24341 24343 24344 24347 24347 24351 24351 24358 24359 24361 24361 24369 24369 24373 24373 24378 24378 24380 24380 24392 24392 24394 24394 24396 24396 24398 24398 24406 24407 24409 24409 24411 24411 24418 24418 24422 24423 24425 24429 24432 24433 24439 24439 24441 24441 24444 24444 24447 24449 24453 24453 24455 24455 24458 24460 24464 24466 24471 24473 24478 24478 24480 24481 24488 24490 24494 24494 24501 24501 24503 24503 24505 24505 24509 24509 24515 24515 24517 24517 24524 24525 24534 24537 24544 24544 24555 24555 24565 24565 24573 24573 24575 24575 24591 24591 24594 24594 24598 24598 24604 24605 24608 24609 24613 24613 24615 24616 24618 24618 24623 24623 24641 24643 24653 24653 24656 24656 24658 24658 24661 24661 24665 24665 24669 24669 24674 24677 24680 24682 24684 24685 24687 24688 24709 24709 24713 24713 24716 24717 24724 24724 24726 24726 24730 24731 24735 24736 24739 24740 24743 24743 24752 24752 24754 24756 24758 24758 24760 24760 24764 24765 24773 24773 24775 24775 24785 24785 24794 24794 24796 24796 24799 24801 24816 24817 24819 24819 24822 24822 24825 24827 24833 24833 24838 24838 24840 24841 24845 24847 24853 24853 24858 24859 24863 24863 24871 24871 24880 24880 24884 24884 24887 24887 24892 24892 24894 24895 24898 24898 24900 24900 24903 24904 24906 24908 24915 24915 24917 24917 24920 24921 24925 24925 24927 24927 24930 24932 24935 24936 24939 24939 24942 24942 24944 24944 24950 24951 24957 24958 24961 24962 24970 24970 24974 24974 24976 24977 24980 24980 24984 24986 24996 24996 24999 24999 25001 25001 25003 25004 25006 25006 25010 25010 25014 25014 25018 25018 25022 25022 25027 25027 25031 25035 25062 25062 25074 25074 25078 25080 25082 25082 25084 25084 25087 25088 25095 25096 25098 25098 25100 25102 25104 25106 25110 25110 25114 25114 25119 25119 25121 25121 25130 25130 25134 25134 25136 25137 25140 25140 25142 25142 25150 25153 25159 25161 25163 25163 25165 25165 25171 25171 25176 25176 25198 25198 25201 25201 25206 25206 25209 25209 25212 25212 25215 25216 25220 25220 25225 25226 25233 25234 25237 25237 25239 25240 25243 25243 25259 25259 25265 25265 25269 25269 25273 25273 25276 25277 25282 25282 25287 25289 25292 25293 25295 25296 25298 25300 25302 25305 25307 25308 25324 25327 25329 25329 25331 25331 25335 25335 25342 25343 25345 25345 25351 25351 25353 25353 25361 25361 25387 25387 25391 25391 25402 25403 25405 25406 25417 25417 25420 25420 25423 25424 25429 25429 25447 25448 25454 25454 25458 25458 25463 25463 25466 25467 25471 25471 25475 25475 25480 25481 25484 25484 25490 25490 25494 25494 25496 25496 25499 25499 25504 25506 25509 25509 25511 25514 25536 25536 25540 25540 25542 25542 25551 25552 25558 25558 25562 25563 25569 25569 25581 25582 25588 25588 25590 25591 25613 25613 25615 25615 25620 25620 25622 25623 25628 25628 25634 25634 25644 25645 25658 25658 25662 25662 25688 25688 25696 25696 25705 25705 25711 25711 25720 25722 25736 25736 25745 25747 25754 25754 25758 25758 25764 25765 25771 25771 25773 25774 25776 25776 25778 25778 25787 25787 25793 25793 25796 25797 25799 25799 25802 25802 25805 25806 25810 25810 25812 25812 25816 25816 25818 25818 25825 25826 25829 25831 25836 25836 25842 25842 25844 25844 25850 25850 25854 25854 25856 25856 25860 25860 25880 25880 25885 25885 25891 25891 25898 25900 25903 25903 25910 25913 25915 25915 25918 25919 25925 25925 25928 25928 25933 25935 25937 25937 25942 25943 25950 25950 25954 25955 25958 25958 25964 25965 25970 25970 25972 25973 25975 25976 25982 25982 25986 25987 25989 25989 25991 25991 25996 25996 26000 26001 26007 26007 26009 26009 26011 26012 26015 26015 26017 26017 26020 26021 26023 26023 26027 26028 26031 26032 26039 26039 26041 26041 26044 26045 26049 26049 26053 26053 26059 26060 26063 26063 26066 26066 26071 26071 26080 26080 26083 26083 26085 26086 26088 26089 26092 26093 26097 26097 26100 26100 26106 26109 26111 26111 26118 26119 26121 26122 26124 26124 26126 26129 26131 26133 26142 26144 26149 26149 26151 26152 26157 26157 26159 26161 26164 26164 26166 26166 26170 26171 26177 26180 26185 26185 26187 26187 26191 26191 26201 26201 26203 26203 26205 26207 26212 26217 26219 26219 26222 26223 26227 26228 26230 26232 26234 26234 26244 26244 26247 26249 26254 26254 26256 26257 26262 26264 26269 26269 26272 26272 26274 26274 26283 26283 26286 26286 26290 26292 26297 26297 26299 26299 26302 26302 26308 26308 26310 26311 26313 26313 26326 26326 26329 26329 26332 26333 26336 26336 26342 26342 26352 26352 26354 26356 26359 26362 26364 26364 26366 26368 26371 26371 26376 26377 26379 26379 26381 26381 26388 26389 26391 26391 26395 26395 26397 26399 26406 26408 26410 26414 26417 26417 26420 26420 26422 26422 26426 26426 26429 26429 26438 26438 26441 26441 26446 26449 26451 26451 26454 26454 26460 26460 26462 26463 26477 26477 26479 26481 26483 26483 26485 26485 26487 26487 26491 26491 26494 26495 26503 26503 26505 26505 26507 26507 26511 26512 26515 26515 26517 26517 26519 26519 26522 26522 26524 26525 26543 26544 26547 26547 26550 26552 26558 26558 26564 26564 26575 26580 26586 26586 26589 26589 26601 26601 26604 26604 26607 26609 26611 26614 26619 26619 26622 26622 26642 26643 26646 26647 26657 26658 26666 26666 26671 26671 26680 26681 26684 26685 26688 26691 26696 26696 26702 26702 26704 26705 26707 26708 26733 26733 26742 26742 26751 26751 26753 26753 26757 26757 26767 26767 26771 26772 26775 26775 26781 26781 26783 26783 26785 26786 26791 26792 26797 26797 26799 26801 26803 26803 26805 26806 26820 26821 26825 26825 26827 26827 26829 26829 26834 26834 26837 26837 26839 26840 26842 26842 26847 26848 26855 26856 26862 26862 26866 26866 26873 26874 26880 26880 26885 26885 26893 26894 26898 26898 26919 26919 26928 26928 26941 26941 26943 26943 26954 26954 26963 26965 26967 26967 26969 26970 26974 26974 26976 26979 26984 26984 26987 26987 26989 26991 26997 26997 26999 27001 27029 27029 27035 27036 27045 27045 27047 27047 27054 27054 27060 27060 27067 27067 27073 27073 27075 27075 27083 27085 27088 27088 27112 27112 27114 27114 27131 27131 27133 27133 27135 27135 27138 27138 27146 27146 27153 27153 27155 27155 27159 27159 27161 27161 27166 27167 27169 27169 27171 27171 27189 27189 27192 27194 27197 27197 27204 27204 27208 27208 27211 27211 27218 27219 27224 27225 27231 27231 27233 27233 27243 27243 27264 27264 27268 27268 27273 27273 27277 27278 27287 27287 27292 27292 27298 27299 27315 27315 27323 27323 27330 27331 27347 27347 27354 27355 27382 27382 27387 27387 27396 27396 27402 27402 27404 27404 27410 27410 27414 27414 27424 27425 27427 27427 27442 27442 27450 27450 27453 27454 27462 27463 27468 27468 27470 27470 27472 27472 27487 27487 27489 27494 27498 27498 27506 27506 27511 27512 27515 27515 27519 27519 27523 27524 27526 27526 27529 27530 27542 27542 27544 27544 27550 27550 27566 27567 27570 27570 27573 27573 27575 27575 27578 27578 27580 27580 27583 27583 27585 27585 27589 27590 27595 27595 27597 27597 27599 27599 27602 27604 27606 27608 27611 27611 27627 27628 27656 27656 27663 27663 27665 27665 27667 27667 27683 27683 27700 27700 27703 27704 27710 27710 27712 27714 27726 27726 27728 27728 27733 27733 27735 27735 27738 27738 27741 27744 27752 27752 27754 27754 27757 27757 27760 27760 27762 27762 27766 27766 27770 27770 27773 27774 27777 27779 27781 27784 27788 27788 27792 27792 27794 27798 27801 27803 27819 27819 27822 27822 27827 27827 27832 27833 27835 27839 27841 27842 27844 27844 27849 27850 27852 27852 27859 27859 27861 27861 27863 27863 27867 27867 27873 27875 27877 27877 27880 27880 27883 27883 27886 27888 27891 27891 27915 27916 27921 27921 27927 27927 27929 27929 27931 27931 27934 27934 27941 27941 27943 27943 27945 27946 27954 27954 27957 27958 27960 27961 27963 27963 27965 27966 27969 27969 27993 27994 27996 27996 28003 28003 28006 28006 28009 28010 28012 28012 28014 28014 28020 28020 28023 28025 28031 28031 28037 28037 28039 28041 28044 28046 28049 28049 28051 28051 28053 28053 28079 28079 28082 28082 28085 28085 28096 28096 28099 28103 28107 28107 28111 28111 28113 28113 28120 28122 28126 28126 28129 28129 28136 28136 28138 28139 28142 28142 28145 28145 28147 28147 28149 28149 28151 28155 28183 28183 28185 28187 28191 28193 28195 28198 28203 28205 28207 28207 28210 28210 28212 28212 28214 28214 28216 28216 28218 28218 28220 28222 28227 28228 28234 28234 28237 28237 28246 28246 28248 28248 28251 28252 28254 28255 28263 28263 28267 28267 28270 28271 28274 28275 28282 28282 28304 28304 28310 28310 28316 28317 28319 28319 28322 28322 28325 28325 28330 28331 28335 28335 28337 28337 28342 28342 28346 28346 28354 28354 28356 28357 28361 28361 28363 28364 28366 28366 28369 28369 28371 28372 28399 28399 28404 28404 28408 28408 28414 28415 28417 28418 28422 28422 28431 28431 28433 28433 28436 28437 28448 28448 28450 28451 28459 28460 28465 28466 28472 28472 28479 28479 28481 28481 28497 28497 28500 28500 28503 28504 28506 28507 28510 28511 28514 28514 28516 28516 28525 28526 28528 28528 28538 28538 28540 28542 28545 28545 28548 28548 28552 28552 28557 28558 28560 28560 28564 28564 28567 28567 28579 28580 28583 28583 28590 28591 28593 28593 28595 28595 28601 28601 28606 28606 28608 28611 28618 28618 28629 28629 28634 28634 28639 28641 28644 28644 28649 28649 28651 28652 28655 28655 28657 28657 28670 28670 28673 28673 28677 28678 28681 28681 28683 28683 28687 28687 28689 28689 28693 28693 28696 28696 28698 28703 28707 28707 28711 28712 28719 28719 28727 28727 28734 28734 28748 28748 28752 28753 28760 28760 28765 28765 28771 28771 28779 28779 28784 28784 28792 28792 28796 28797 28805 28805 28810 28810 28814 28814 28818 28818 28824 28826 28833 28833 28836 28836 28843 28845 28847 28847 28851 28851 28855 28857 28872 28872 28875 28875 28879 28879 28888 28889 28893 28893 28895 28895 28913 28913 28921 28921 28925 28925 28932 28932 28937 28937 28940 28940 28953 28954 28958 28958 28961 28961 28966 28966 28976 28976 28982 28982 28999 28999 29001 29002 29004 29004 29006 29006 29008 29008 29014 29014 29017 29017 29020 29020 29022 29022 29028 29031 29033 29033 29036 29036 29038 29038 29053 29053 29060 29060 29065 29066 29071 29071 29074 29074 29076 29076 29081 29081 29087 29087 29090 29090 29100 29100 29105 29105 29113 29114 29118 29118 29121 29121 29123 29123 29128 29129 29134 29134 29136 29136 29138 29138 29140 29141 29151 29151 29157 29159 29165 29166 29179 29180 29182 29184 29190 29190 29200 29200 29211 29211 29226 29226 29228 29229 29232 29232 29234 29234 29237 29238 29242 29243 29245 29246 29248 29248 29254 29256 29260 29260 29266 29266 29272 29273 29275 29275 29277 29277 29279 29279 29281 29282 29287 29287 29289 29289 29298 29298 29305 29305 29309 29309 29312 29313 29346 29346 29351 29351 29356 29356 29359 29359 29376 29376 29378 29378 29380 29380 29390 29390 29392 29392 29399 29399 29401 29401 29409 29409 29417 29417 29432 29433 29436 29437 29450 29450 29462 29462 29467 29469 29477 29477 29481 29483 29494 29495 29502 29503 29508 29509 29520 29520 29522 29522 29527 29527 29544 29544 29546 29546 29552 29552 29554 29554 29557 29557 29560 29560 29562 29563 29572 29572 29574 29575 29577 29577 29579 29579 29582 29582 29588 29588 29590 29592 29599 29599 29607 29607 29609 29609 29613 29613 29618 29619 29625 29625 29632 29632 29634 29634 29641 29642 29644 29645 29647 29647 29654 29654 29657 29657 29661 29662 29664 29664 29667 29670 29673 29674 29677 29677 29687 29687 29689 29689 29693 29694 29697 29697 29699 29699 29701 29703 29705 29705 29715 29715 29723 29723 29728 29730 29733 29734 29736 29736 29738 29740 29742 29744 29747 29750 29752 29752 29754 29754 29759 29761 29763 29764 29771 29771 29781 29781 29783 29783 29785 29788 29790 29792 29794 29794 29796 29797 29800 29802 29807 29807 29822 29822 29826 29827 29831 29831 29833 29833 29835 29835 29848 29848 29852 29852 29854 29855 29857 29857 29859 29859 29861 29861 29863 29864 29866 29866 29872 29872 29874 29874 29877 29877 29881 29881 29885 29885 29887 29887 29894 29894 29898 29898 29903 29903 29908 29908 29912 29912 29914 29914 29916 29916 29920 29920 29922 29923 29926 29926 29934 29934 29943 29943 29953 29953 29956 29956 29969 29969 29973 29973 29976 29976 29978 29979 29983 29983 29987 29987 29989 29990 29992 29992 29995 29996 30000 30003 30007 30008 30010 30010 30023 30023 30028 30028 30031 30031 30033 30033 30035 30036 30041 30041 30043 30045 30050 30050 30053 30054 30058 30058 30063 30064 30069 30070 30072 30072 30074 30074 30079 30079 30086 30087 30090 30091 30094 30095 30097 30097 30109 30109 30117 30117 30123 30123 30129 30131 30133 30133 30136 30137 30140 30142 30146 30146 30149 30149 30151 30151 30157 30157 30162 30162 30164 30165 30168 30169 30171 30171 30178 30178 30192 30192 30194 30194 30196 30196 30202 30202 30204 30204 30208 30208 30221 30221 30233 30233 30239 30242 30244 30244 30246 30246 30267 30267 30274 30274 30284 30284 30286 30286 30290 30290 30294 30294 30305 30305 30308 30308 30313 30313 30316 30316 30320 30320 30322 30322 30328 30328 30331 30334 30340 30340 30342 30343 30350 30350 30352 30352 30355 30355 30382 30382 30394 30394 30399 30399 30402 30403 30406 30406 30408 30408 30410 30410 30418 30418 30422 30422 30427 30428 30430 30431 30433 30433 30435 30436 30439 30439 30446 30446 30450 30450 30452 30452 30456 30456 30460 30460 30462 30462 30465 30465 30468 30468 30472 30473 30475 30475 30494 30494 30496 30496 30505 30505 30519 30520 30522 30522 30524 30524 30528 30528 30541 30541 30555 30555 30561 30561 30563 30563 30566 30566 30571 30571 30585 30585 30590 30591 30603 30603 30609 30609 30622 30622 30629 30629 30636 30637 30640 30640 30643 30643 30651 30652 30655 30655 30679 30679 30683 30684 30690 30691 30693 30693 30697 30697 30701 30703 30707 30707 30722 30722 30738 30738 30757 30759 30764 30764 30770 30770 30772 30772 30789 30789 30799 30799 30813 30813 30827 30828 30831 30831 30844 30844 30849 30849 30855 30855 30860 30862 30865 30865 30871 30871 30883 30883 30887 30887 30889 30889 30906 30908 30913 30913 30917 30917 30922 30923 30926 30926 30928 30928 30952 30952 30956 30956 30959 30959 30965 30965 30971 30971 30977 30977 30990 30990 30998 30998 31018 31020 31034 31034 31038 31038 31040 31041 31047 31049 31056 31056 31062 31063 31066 31070 31072 31072 31077 31077 31080 31080 31085 31085 31098 31098 31103 31103 31105 31105 31117 31119 31121 31121 31142 31143 31146 31146 31150 31150 31153 31153 31155 31155 31161 31161 31165 31169 31177 31179 31185 31186 31189 31189 31192 31192 31199 31199 31204 31204 31206 31207 31209 31209 31227 31227 31232 31232 31237 31237 31240 31240 31243 31243 31245 31245 31252 31252 31255 31255 31257 31258 31260 31260 31263 31264 31278 31278 31281 31281 31286 31287 31291 31293 31295 31296 31302 31302 31305 31305 31309 31310 31319 31319 31329 31330 31337 31337 31339 31339 31344 31344 31348 31348 31350 31350 31353 31354 31357 31357 31359 31359 31361 31361 31364 31364 31368 31368 31378 31379 31381 31381 31384 31384 31391 31391 31401 31402 31406 31407 31418 31418 31428 31429 31431 31431 31434 31435 31447 31447 31449 31449 31453 31453 31455 31456 31459 31459 31461 31461 31466 31466 31469 31469 31471 31471 31478 31478 31481 31482 31487 31487 31503 31503 31505 31505 31513 31513 31515 31515 31518 31518 31520 31520 31526 31526 31532 31533 31545 31545 31558 31558 31561 31561 31563 31565 31567 31570 31572 31572 31574 31574 31584 31584 31596 31596 31598 31598 31605 31605 31613 31613 31623 31623 31627 31627 31631 31631 31636 31637 31639 31639 31642 31642 31645 31645 31649 31649 31661 31661 31665 31665 31668 31668 31672 31672 31680 31681 31684 31684 31686 31687 31689 31689 31698 31698 31712 31712 31716 31716 31721 31721 31751 31751 31762 31762 31774 31774 31777 31777 31783 31783 31786 31787 31805 31807 31811 31811 31820 31821 31840 31840 31844 31844 31852 31852 31859 31859 31875 31875 31881 31881 31890 31890 31893 31893 31895 31896 31903 31903 31909 31909 31911 31911 31918 31918 31921 31923 31929 31929 31934 31934 31946 31946 31958 31958 31966 31968 31975 31975 31995 31995 31998 31998 32000 32000 32002 32002 32004 32008 32010 32011 32013 32013 32016 32016 32020 32020 32023 32027 32032 32034 32043 32044 32046 32048 32051 32051 32053 32053 32057 32058 32066 32070 32080 32080 32094 32094 32097 32098 32102 32102 32104 32104 32106 32106 32110 32110 32113 32115 32118 32118 32121 32121 32127 32127 32142 32143 32147 32147 32156 32156 32160 32160 32162 32162 32172 32173 32177 32178 32180 32181 32184 32184 32186 32187 32189 32191 32199 32199 32202 32203 32214 32214 32216 32216 32218 32218 32221 32222 32224 32225 32227 32227 32232 32233 32236 32236 32239 32239 32244 32244 32251 32251 32265 32266 32277 32277 32283 32283 32285 32287 32289 32289 32291 32291 32299 32299 32302 32303 32305 32305 32311 32311 32317 32318 32321 32321 32323 32323 32326 32327 32338 32338 32340 32341 32350 32350 32353 32353 32361 32363 32365 32365 32368 32368 32377 32377 32380 32380 32386 32386 32396 32396 32399 32399 32403 32403 32406 32406 32408 32408 32411 32412 32566 32566 32568 32568 32570 32570 32588 32588 32592 32592 32596 32597 32618 32619 32622 32622 32624 32624 32626 32626 32629 32629 32631 32631 32633 32633 32645 32645 32648 32648 32650 32650 32652 32652 32654 32654 32660 32660 32666 32666 32670 32670 32676 32676 32680 32681 32690 32690 32696 32697 32701 32701 32705 32705 32709 32709 32714 32714 32716 32716 32718 32718 32722 32722 32724 32725 32735 32737 32745 32745 32747 32747 32752 32752 32761 32761 32764 32764 32768 32769 32771 32771 32773 32774 32777 32777 32780 32780 32784 32784 32789 32789 32791 32792 32813 32813 32819 32819 32822 32822 32829 32829 32831 32831 32835 32835 32838 32838 32842 32842 32854 32854 32856 32856 32858 32858 32862 32862 32879 32880 32882 32883 32887 32887 32893 32895 32900 32903 32905 32905 32907 32908 32918 32918 32923 32923 32925 32925 32929 32930 32933 32933 32937 32938 32943 32943 32945 32946 32948 32948 32954 32954 32963 32964 32972 32972 32974 32974 32986 32987 32990 32990 32993 32993 32996 32997 33009 33009 33012 33012 33016 33016 33021 33021 33026 33026 33029 33032 33034 33034 33048 33048 33050 33051 33059 33059 33065 33065 33067 33067 33071 33071 33081 33081 33086 33086 33099 33099 33102 33102 33104 33105 33108 33109 33125 33126 33131 33131 33136 33137 33144 33146 33151 33152 33160 33160 33162 33162 33167 33167 33178 33178 33180 33181 33184 33184 33187 33187 33192 33192 33203 33203 33205 33205 33210 33210 33213 33216 33218 33218 33222 33222 33229 33229 33240 33240 33247 33247 33251 33251 33253 33253 33255 33256 33258 33258 33261 33261 33267 33268 33274 33276 33278 33278 33285 33285 33287 33288 33290 33290 33292 33293 33298 33298 33307 33308 33310 33311 33313 33313 33322 33324 33333 33335 33337 33337 33344 33344 33349 33349 33351 33351 33369 33369 33380 33380 33382 33382 33390 33391 33393 33394 33398 33398 33400 33400 33406 33406 33419 33419 33421 33422 33426 33426 33433 33434 33437 33437 33439 33439 33445 33446 33449 33449 33452 33455 33457 33457 33459 33459 33463 33465 33467 33469 33471 33471 33489 33490 33492 33493 33495 33495 33499 33499 33502 33503 33505 33505 33509 33511 33521 33521 33533 33534 33537 33541 33545 33545 33559 33559 33576 33576 33579 33579 33583 33583 33585 33585 33588 33590 33592 33593 33600 33600 33607 33607 33609 33610 33615 33615 33617 33618 33651 33651 33655 33655 33659 33659 33673 33674 33678 33678 33686 33686 33688 33688 33694 33694 33698 33698 33705 33707 33725 33725 33729 33729 33733 33733 33737 33738 33740 33740 33747 33747 33750 33750 33756 33756 33769 33769 33771 33771 33775 33778 33780 33780 33785 33785 33789 33789 33795 33796 33802 33802 33804 33806 33833 33833 33836 33836 33841 33841 33848 33848 33853 33853 33865 33865 33879 33879 33883 33883 33889 33889 33891 33891 33894 33894 33899 33900 33903 33903 33909 33909 33914 33914 33936 33936 33940 33940 33945 33945 33948 33948 33953 33953 33970 33970 33976 33976 33979 33980 33983 33984 33986 33986 33988 33988 33990 33990 33993 33993 33995 33995 33997 33997 34001 34001 34010 34010 34028 34028 34030 34030 34036 34036 34044 34044 34065 34065 34067 34068 34071 34072 34074 34074 34078 34078 34081 34081 34083 34083 34085 34085 34092 34093 34095 34095 34109 34109 34111 34111 34113 34113 34115 34115 34121 34121 34126 34126 34131 34131 34137 34137 34147 34147 34152 34154 34157 34157 34180 34180 34183 34183 34191 34191 34193 34193 34196 34196 34203 34203 34214 34214 34216 34218 34223 34224 34234 34234 34241 34241 34249 34249 34253 34255 34261 34261 34268 34269 34276 34277 34281 34282 34295 34295 34298 34299 34303 34303 34306 34306 34310 34311 34314 34314 34326 34327 34330 34330 34349 34349 34367 34367 34382 34382 34384 34384 34388 34389 34395 34396 34398 34399 34407 34407 34425 34425 34442 34442 34444 34444 34451 34451 34467 34468 34473 34473 34503 34503 34507 34507 34516 34516 34521 34521 34523 34523 34527 34527 34532 34532 34541 34541 34558 34558 34560 34560 34562 34563 34568 34568 34584 34584 34586 34586 34588 34588 34638 34638 34645 34645 34647 34647 34655 34655 34662 34662 34664 34664 34676 34676 34678 34678 34680 34680 34690 34690 34701 34701 34719 34719 34722 34722 34739 34739 34746 34746 34756 34756 34784 34784 34796 34796 34799 34799 34802 34802 34809 34809 34811 34811 34814 34814 34821 34821 34847 34847 34850 34851 34865 34865 34870 34870 34875 34875 34880 34880 34886 34886 34892 34893 34898 34899 34903 34903 34905 34905 34907 34907 34909 34909 34913 34915 34920 34920 34923 34923 34928 34928 34930 34930 34935 34935 34942 34943 34945 34946 34952 34952 34955 34955 34957 34957 34962 34962 34966 34967 34974 34974 34987 34987 34996 34996 35009 35010 35023 35023 35028 35029 35033 35033 35036 35037 35039 35039 35041 35041 35048 35048 35059 35061 35064 35064 35069 35069 35079 35079 35088 35088 35090 35091 35096 35097 35109 35109 35114 35114 35126 35126 35128 35128 35131 35131 35137 35137 35140 35140 35167 35167 35172 35172 35178 35178 35186 35186 35199 35199 35201 35201 35203 35203 35206 35207 35211 35211 35215 35215 35219 35219 35222 35222 35233 35233 35241 35242 35250 35250 35258 35258 35261 35261 35264 35264 35282 35282 35299 35299 35316 35316 35320 35320 35328 35328 35330 35331 35336 35336 35338 35338 35340 35340 35342 35342 35347 35347 35350 35352 35355 35355 35357 35357 35359 35359 35363 35363 35365 35365 35370 35370 35373 35373 35377 35377 35380 35380 35382 35382 35386 35387 35408 35408 35412 35413 35419 35419 35422 35422 35424 35424 35426 35427 35430 35430 35433 35433 35437 35438 35440 35443 35445 35445 35449 35449 35461 35461 35463 35463 35468 35469 35475 35475 35477 35477 35480 35480 35486 35486 35488 35489 35491 35494 35496 35496 35498 35498 35504 35504 35506 35506 35513 35513 35516 35516 35518 35519 35522 35522 35524 35524 35527 35527 35531 35531 35533 35533 35535 35535 35538 35538 35542 35542 35547 35548 35553 35553 35558 35559 35562 35563 35565 35566 35569 35569 35574 35576 35578 35578 35582 35582 35584 35586 35588 35588 35598 35598 35600 35600 35604 35604 35606 35607 35609 35611 35613 35613 35616 35616 35624 35624 35627 35628 35635 35635 35641 35641 35649 35649 35657 35657 35662 35663 35672 35672 35674 35674 35676 35676 35686 35686 35692 35692 35695 35696 35700 35700 35703 35703 35709 35709 35712 35712 35722 35722 35728 35728 35730 35731 35734 35734 35738 35738 35895 35895 35903 35903 35905 35905 35910 35910 35912 35912 35914 35914 35916 35916 35925 35925 35930 35930 35937 35937 35946 35947 35961 35962 35970 35970 35978 35978 35980 35980 35997 35998 36000 36002 36007 36012 36015 36016 36019 36020 36022 36024 36027 36029 36031 36036 36039 36040 36042 36042 36049 36049 36051 36051 36058 36058 36060 36060 36062 36062 36064 36064 36066 36068 36070 36070 36074 36074 36077 36077 36084 36084 36091 36093 36100 36101 36103 36104 36106 36106 36109 36109 36115 36115 36118 36118 36196 36196 36198 36198 36203 36203 36208 36208 36211 36212 36215 36215 36229 36229 36234 36234 36249 36249 36259 36259 36264 36264 36275 36275 36282 36282 36286 36286 36294 36294 36299 36300 36303 36303 36315 36315 36317 36317 36321 36321 36323 36323 36328 36328 36335 36335 36339 36339 36362 36362 36367 36368 36382 36382 36394 36394 36400 36400 36405 36405 36418 36418 36420 36420 36423 36426 36441 36441 36447 36448 36468 36468 36470 36470 36481 36481 36487 36487 36490 36490 36493 36493 36522 36524 36544 36544 36554 36557 36562 36562 36575 36575 36587 36587 36600 36600 36603 36603 36606 36606 36611 36611 36613 36613 36617 36617 36626 36629 36635 36639 36646 36647 36649 36650 36655 36655 36659 36659 36664 36665 36667 36667 36670 36671 36676 36677 36681 36681 36685 36686 36701 36701 36703 36703 36706 36706 36763 36764 36771 36771 36774 36774 36776 36776 36781 36781 36783 36786 36802 36802 36805 36805 36814 36814 36817 36817 36820 36820 36838 36838 36842 36843 36845 36845 36848 36848 36850 36850 36855 36855 36857 36857 36861 36861 36864 36867 36869 36870 36872 36872 36875 36875 36877 36877 36879 36881 36884 36885 36887 36887 36889 36890 36893 36899 36910 36910 36913 36914 36917 36917 36920 36920 36924 36924 36926 36926 36929 36930 36935 36935 36938 36939 36941 36942 36944 36945 36947 36949 36953 36953 36956 36958 36960 36961 36963 36963 36969 36969 36973 36975 36978 36978 36981 36981 36983 36984 36986 36986 36988 36989 36991 36996 36999 37000 37002 37002 37007 37007 37009 37009 37013 37013 37017 37017 37026 37027 37030 37030 37032 37032 37034 37034 37039 37041 37045 37045 37048 37048 37057 37057 37066 37066 37086 37086 37089 37089 37096 37096 37101 37101 37109 37109 37117 37117 37122 37122 37138 37138 37141 37141 37145 37145 37159 37159 37165 37165 37170 37170 37193 37198 37202 37202 37218 37218 37225 37226 37228 37228 37237 37237 37239 37240 37255 37255 37257 37257 37259 37259 37261 37261 37266 37266 37276 37276 37291 37292 37294 37295 37297 37297 37300 37301 37312 37312 37319 37319 37321 37321 37323 37329 37335 37336 37340 37341 37347 37347 37351 37351 37354 37354 37365 37365 37389 37389 37392 37394 37399 37399 37406 37406 37428 37428 37434 37434 37439 37440 37445 37445 37449 37449 37463 37463 37467 37467 37470 37470 37474 37474 37476 37478 37504 37504 37507 37507 37509 37509 37521 37521 37523 37523 37526 37526 37528 37528 37532 37532 37555 37555 37558 37559 37561 37561 37580 37580 37583 37583 37586 37586 37604 37604 37610 37610 37624 37624 37628 37628 37636 37636 37648 37648 37656 37656 37658 37658 37662 37666 37668 37668 37670 37670 37672 37672 37675 37675 37678 37679 37704 37704 37706 37707 37709 37709 37716 37716 37723 37723 37742 37742 37749 37749 37756 37756 37758 37758 37772 37772 37780 37780 37782 37782 37786 37786 37795 37795 37799 37799 37804 37805 37808 37808 37827 37827 37841 37841 37854 37854 37857 37857 37860 37860 37878 37878 37892 37892 37912 37912 37925 37925 37931 37931 37941 37941 37944 37944 37956 37956 37969 37970 37979 37979 38013 38013 38015 38015 38263 38263 38272 38272 38275 38275 38281 38281 38283 38283 38287 38287 38289 38292 38296 38296 38307 38309 38312 38312 38317 38317 38321 38321 38331 38332 38343 38343 38346 38346 38356 38358 38364 38364 38369 38370 38428 38428 38433 38433 38442 38442 38446 38446 38450 38450 38459 38459 38463 38464 38466 38466 38468 38468 38475 38477 38480 38480 38491 38495 38498 38500 38506 38506 38512 38512 38515 38515 38517 38520 38525 38525 38533 38534 38538 38539 38541 38542 38548 38549 38552 38553 38555 38556 38563 38563 38567 38568 38570 38570 38577 38577 38583 38583 38587 38587 38592 38593 38596 38599 38601 38601 38603 38606 38613 38614 38617 38617 38619 38620 38626 38627 38632 38634 38639 38640 38642 38642 38646 38647 38649 38649 38651 38651 38656 38656 38662 38663 38673 38673 38675 38675 38678 38678 38681 38681 38684 38684 38686 38686 38695 38695 38704 38704 38706 38706 38713 38713 38717 38717 38722 38722 38724 38724 38728 38728 38737 38737 38742 38742 38748 38748 38750 38750 38753 38754 38761 38761 38765 38765 38772 38772 38775 38775 38778 38778 38795 38795 38797 38797 38799 38799 38816 38816 38824 38824 38827 38827 38829 38829 38854 38854 38859 38859 38867 38867 38876 38876 38899 38899 38902 38902 38907 38907 38911 38915 38917 38918 38920 38920 38922 38922 38924 38924 38928 38931 38935 38936 38957 38957 38960 38960 38968 38969 38971 38971 38982 38982 38988 38990 38996 38996 39000 39000 39002 39002 39006 39006 39013 39013 39015 39015 39019 39019 39023 39023 39080 39080 39087 39087 39089 39089 39108 39108 39111 39111 39131 39132 39135 39135 39137 39138 39149 39151 39156 39156 39164 39166 39171 39171 39177 39178 39180 39180 39184 39184 39187 39187 39192 39192 39198 39198 39200 39200 39208 39208 39237 39237 39241 39241 39243 39245 39249 39250 39252 39252 39255 39255 39318 39318 39321 39321 39325 39325 39333 39333 39336 39336 39340 39342 39345 39345 39347 39348 39353 39353 39361 39361 39376 39378 39381 39381 39385 39385 39389 39389 39391 39391 39405 39405 39409 39409 39423 39423 39425 39425 39432 39432 39438 39439 39449 39449 39467 39467 39472 39472 39478 39479 39488 39488 39491 39491 39493 39493 39501 39501 39509 39509 39511 39511 39514 39515 39519 39519 39522 39522 39525 39525 39529 39530 39592 39592 39608 39608 39635 39636 39640 39640 39653 39653 39662 39662 39706 39706 39719 39719 39722 39722 39729 39729 39740 39740 39745 39749 39759 39759 39764 39764 39770 39770 39791 39791 39822 39822 39825 39825 39839 39839 39851 39851 39854 39854 39881 39881 39894 39894 39908 39908 39912 39912 39949 39949 39952 39952 39954 39954 39957 39957 39973 39973 39986 39986 39995 39995 40007 40007 40009 40009 40023 40023 40165 40165 40167 40167 40169 40169 40179 40180 40182 40182 40201 40201 40219 40219 40230 40230 40232 40232 40251 40251 40273 40273 40285 40285 40288 40289 40300 40300 40306 40306 40361 40361 40367 40367 40372 40372 40388 40388 40407 40407 40434 40434 40440 40442 40474 40474 40478 40478 40565 40565 40569 40569 40573 40573 40575 40575 40594 40595 40599 40599 40605 40605 40607 40607 40613 40613 40628 40629 40635 40635 40638 40638 40643 40643 40653 40654 40657 40657 40660 40660 40664 40664 40667 40668 40670 40670 40680 40680 40692 40692 40711 40712 40718 40718 40723 40723 40736 40736 40763 40763 40778 40779 40782 40782 40786 40786 40799 40799 40801 40801 40807 40807 40810 40810 40812 40812 40823 40823 40845 40845 40848 40848 40853 40853 40860 40860 44032 44033 44036 44036 44039 44042 44048 44055 44057 44061 44064 44064 44068 44068 44076 44077 44079 44081 44088 44089 44092 44092 44096 44096 44107 44107 44109 44109 44116 44116 44120 44120 44124 44124 44144 44145 44148 44148 44151 44152 44154 44154 44160 44161 44163 44166 44169 44172 44176 44176 44180 44180 44188 44189 44191 44193 44200 44202 44204 44204 44207 44208 44216 44217 44219 44221 44225 44225 44228 44228 44232 44232 44236 44236 44245 44245 44247 44247 44256 44257 44260 44260 44263 44264 44266 44266 44268 44268 44271 44273 44275 44275 44277 44278 44284 44285 44288 44288 44292 44292 44294 44294 44300 44301 44303 44303 44305 44305 44312 44312 44316 44316 44320 44320 44329 44329 44332 44333 44340 44341 44344 44344 44348 44348 44356 44357 44359 44359 44361 44361 44368 44368 44372 44372 44376 44376 44385 44385 44387 44387 44396 44397 44400 44400 44403 44406 44411 44413 44415 44415 44417 44418 44424 44425 44428 44428 44432 44432 44444 44445 44452 44452 44471 44471 44480 44481 44484 44484 44488 44488 44496 44497 44499 44499 44508 44508 44512 44512 44516 44516 44536 44537 44540 44540 44543 44545 44552 44553 44555 44555 44557 44557 44564 44564 44592 44593 44596 44596 44599 44600 44602 44602 44608 44609 44611 44611 44613 44614 44618 44618 44620 44622 44624 44624 44628 44628 44630 44630 44636 44637 44639 44641 44645 44645 44648 44649 44652 44652 44656 44656 44664 44665 44667 44669 44676 44677 44684 44684 44732 44734 44736 44736 44740 44740 44748 44749 44751 44753 44760 44761 44764 44764 44776 44776 44779 44779 44781 44781 44788 44788 44792 44792 44796 44796 44807 44808 44813 44813 44816 44816 44844 44845 44848 44848 44850 44850 44852 44852 44860 44861 44863 44863 44865 44867 44872 44873 44880 44880 44892 44893 44900 44901 44921 44921 44928 44928 44932 44932 44936 44936 44944 44945 44949 44949 44956 44956 44984 44985 44988 44988 44992 44992 44999 45001 45003 45003 45005 45006 45012 45012 45020 45020 45032 45033 45040 45041 45044 45044 45048 45048 45056 45057 45060 45060 45068 45068 45072 45072 45076 45076 45084 45085 45096 45096 45124 45125 45128 45128 45130 45130 45132 45132 45134 45134 45139 45141 45143 45143 45145 45145 45149 45149 45180 45181 45184 45184 45188 45188 45196 45197 45199 45199 45201 45201 45208 45210 45212 45212 45215 45218 45224 45225 45227 45231 45233 45233 45235 45237 45240 45240 45244 45244 45252 45253 45255 45257 45264 45265 45268 45268 45272 45272 45280 45280 45285 45285 45320 45321 45323 45324 45328 45328 45330 45331 45336 45337 45339 45341 45347 45349 45352 45352 45356 45356 45364 45365 45367 45369 45376 45377 45380 45380 45384 45384 45392 45393 45396 45397 45400 45400 45404 45404 45408 45408 45432 45433 45436 45436 45440 45440 45442 45442 45448 45449 45451 45451 45453 45453 45458 45460 45464 45464 45468 45468 45480 45480 45516 45516 45520 45520 45524 45524 45532 45533 45535 45535 45544 45545 45548 45548 45552 45552 45561 45561 45563 45563 45565 45565 45572 45573 45576 45576 45579 45580 45588 45589 45591 45591 45593 45593 45600 45600 45620 45620 45628 45628 45656 45656 45660 45660 45664 45664 45672 45673 45684 45685 45692 45692 45700 45701 45705 45705 45712 45713 45716 45716 45720 45722 45728 45729 45731 45731 45733 45734 45738 45738 45740 45740 45744 45744 45748 45748 45768 45769 45772 45772 45776 45776 45778 45778 45784 45785 45787 45787 45789 45789 45794 45794 45796 45798 45800 45800 45803 45807 45811 45813 45815 45819 45823 45825 45828 45828 45832 45832 45840 45841 45843 45845 45852 45852 45908 45910 45912 45912 45915 45916 45918 45919 45924 45925 45927 45927 45929 45929 45931 45931 45934 45934 45936 45937 45940 45940 45944 45944 45952 45953 45955 45957 45964 45964 45968 45968 45972 45972 45984 45985 45992 45992 45996 45996 46020 46021 46024 46024 46027 46028 46030 46030 46032 46032 46036 46037 46039 46039 46041 46041 46043 46043 46045 46045 46048 46048 46052 46052 46056 46056 46076 46076 46096 46096 46104 46104 46108 46108 46112 46112 46120 46121 46123 46123 46132 46132 46160 46161 46164 46164 46168 46168 46176 46177 46179 46179 46181 46181 46188 46188 46208 46208 46216 46216 46237 46237 46244 46244 46248 46248 46252 46252 46261 46261 46263 46263 46265 46265 46272 46272 46276 46276 46280 46280 46288 46288 46293 46293 46300 46301 46304 46304 46307 46308 46310 46310 46316 46317 46319 46319 46321 46321 46328 46328 46356 46357 46360 46360 46363 46364 46372 46373 46375 46378 46384 46385 46388 46388 46392 46392 46400 46401 46403 46405 46411 46413 46416 46416 46420 46420 46428 46429 46431 46433 46496 46497 46500 46500 46504 46504 46506 46507 46512 46513 46515 46517 46523 46525 46528 46528 46532 46532 46540 46541 46543 46545 46552 46552 46572 46572 46608 46609 46612 46612 46616 46616 46629 46629 46636 46636 46644 46644 46664 46664 46692 46692 46696 46696 46748 46749 46752 46752 46756 46756 46763 46764 46769 46769 46804 46804 46832 46832 46836 46836 46840 46840 46848 46849 46853 46853 46888 46889 46892 46892 46895 46896 46904 46905 46907 46907 46916 46916 46920 46920 46924 46924 46932 46933 46944 46944 46948 46948 46952 46952 46960 46961 46963 46963 46965 46965 46972 46973 46976 46976 46980 46980 46988 46989 46991 46994 46998 47001 47004 47004 47008 47008 47016 47017 47019 47021 47028 47029 47032 47032 47047 47047 47049 47049 47084 47085 47088 47088 47092 47092 47100 47101 47103 47105 47111 47113 47116 47116 47120 47120 47128 47129 47131 47131 47133 47133 47140 47141 47144 47144 47148 47148 47156 47157 47159 47161 47168 47168 47172 47172 47185 47185 47187 47187 47196 47197 47200 47200 47204 47204 47212 47213 47215 47215 47217 47217 47224 47224 47228 47228 47245 47245 47272 47272 47280 47280 47284 47284 47288 47288 47296 47297 47299 47299 47301 47301 47308 47308 47312 47312 47316 47316 47325 47325 47327 47327 47329 47329 47336 47337 47340 47340 47344 47344 47352 47353 47355 47355 47357 47357 47364 47364 47384 47384 47392 47392 47420 47421 47424 47424 47428 47428 47436 47436 47439 47439 47441 47441 47448 47449 47452 47452 47456 47456 47464 47465 47467 47467 47469 47469 47476 47477 47480 47480 47484 47484 47492 47493 47495 47495 47497 47498 47501 47502 47532 47533 47536 47536 47540 47540 47548 47549 47551 47551 47553 47553 47560 47561 47564 47564 47566 47570 47576 47577 47579 47579 47581 47582 47585 47585 47587 47589 47592 47592 47596 47596 47604 47605 47607 47610 47616 47617 47624 47624 47637 47637 47672 47673 47676 47676 47680 47680 47682 47682 47688 47689 47691 47691 47693 47694 47699 47701 47704 47704 47708 47708 47716 47717 47719 47721 47728 47729 47732 47732 47736 47736 47747 47749 47751 47751 47756 47756 47784 47785 47787 47788 47792 47792 47794 47794 47800 47801 47803 47803 47805 47805 47812 47812 47816 47816 47832 47833 47868 47868 47872 47872 47876 47876 47885 47885 47887 47887 47889 47889 47896 47896 47900 47900 47904 47904 47913 47913 47915 47915 47924 47926 47928 47928 47931 47934 47940 47941 47943 47943 47945 47945 47949 47949 47951 47952 47956 47956 47960 47960 47969 47969 47971 47971 47980 47980 48008 48008 48012 48012 48016 48016 48036 48036 48040 48040 48044 48044 48052 48052 48055 48055 48064 48064 48068 48068 48072 48072 48080 48080 48083 48083 48120 48121 48124 48124 48127 48128 48130 48130 48136 48137 48139 48141 48143 48143 48145 48145 48148 48152 48155 48159 48164 48165 48167 48167 48169 48169 48173 48173 48176 48177 48180 48180 48184 48184 48192 48193 48195 48197 48201 48201 48204 48205 48208 48208 48221 48221 48260 48261 48264 48264 48267 48268 48270 48270 48276 48277 48279 48279 48281 48282 48288 48289 48292 48292 48295 48296 48304 48305 48307 48309 48316 48317 48320 48320 48324 48324 48333 48333 48335 48337 48341 48341 48344 48344 48348 48348 48372 48374 48376 48376 48380 48380 48388 48389 48391 48391 48393 48393 48400 48400 48404 48404 48420 48420 48428 48428 48448 48448 48456 48457 48460 48460 48464 48464 48472 48473 48484 48484 48488 48488 48512 48513 48516 48516 48519 48522 48528 48529 48531 48531 48533 48533 48537 48538 48540 48540 48548 48548 48560 48560 48568 48568 48596 48597 48600 48600 48604 48604 48617 48617 48624 48624 48628 48628 48632 48632 48640 48640 48643 48643 48645 48645 48652 48653 48656 48656 48660 48660 48668 48669 48671 48671 48708 48709 48712 48712 48716 48716 48718 48718 48724 48725 48727 48727 48729 48731 48736 48737 48740 48740 48744 48744 48746 48746 48752 48753 48755 48757 48763 48765 48768 48768 48772 48772 48780 48781 48783 48785 48792 48793 48808 48808 48848 48849 48852 48852 48855 48856 48864 48864 48867 48869 48876 48876 48897 48897 48904 48905 48920 48921 48923 48925 48960 48961 48964 48964 48968 48968 48976 48977 48981 48981 49044 49044 49072 49072 49093 49093 49100 49101 49104 49104 49108 49108 49116 49116 49119 49119 49121 49121 49212 49212 49233 49233 49240 49240 49244 49244 49248 49248 49256 49257 49296 49297 49300 49300 49304 49304 49312 49313 49315 49315 49317 49317 49324 49325 49327 49328 49331 49334 49340 49341 49343 49345 49349 49349 49352 49353 49356 49356 49360 49360 49368 49369 49371 49373 49380 49381 49384 49384 49388 49388 49396 49397 49399 49399 49401 49401 49408 49408 49412 49412 49416 49416 49424 49424 49429 49429 49436 49440 49443 49444 49446 49447 49452 49453 49455 49457 49462 49462 49464 49465 49468 49468 49472 49472 49480 49481 49483 49485 49492 49493 49496 49496 49500 49500 49508 49509 49511 49513 49520 49520 49524 49524 49528 49528 49541 49541 49548 49550 49552 49552 49556 49556 49558 49558 49564 49565 49567 49567 49569 49569 49573 49573 49576 49577 49580 49580 49584 49584 49597 49597 49604 49604 49608 49608 49612 49612 49620 49620 49623 49624 49632 49632 49636 49636 49640 49640 49648 49649 49651 49651 49660 49661 49664 49664 49668 49668 49676 49677 49679 49679 49681 49681 49688 49689 49692 49692 49695 49696 49704 49705 49707 49707 49709 49709 49711 49711 49713 49714 49716 49716 49736 49736 49744 49745 49748 49748 49752 49752 49760 49760 49765 49765 49772 49773 49776 49776 49780 49780 49788 49789 49791 49791 49793 49793 49800 49801 49808 49808 49816 49816 49819 49819 49821 49821 49828 49829 49832 49832 49836 49837 49844 49845 49847 49847 49849 49849 49884 49885 49888 49888 49891 49892 49899 49901 49903 49903 49905 49905 49910 49910 49912 49913 49915 49916 49920 49920 49928 49929 49932 49933 49939 49941 49944 49944 49948 49948 49956 49957 49960 49961 49989 49989 50024 50025 50028 50028 50032 50032 50034 50034 50040 50041 50044 50045 50052 50052 50056 50056 50060 50060 50112 50112 50136 50137 50140 50140 50143 50144 50146 50146 50152 50153 50157 50157 50164 50165 50168 50168 50184 50184 50192 50192 50212 50212 50220 50220 50224 50224 50228 50228 50236 50237 50248 50248 50276 50277 50280 50280 50284 50284 50292 50293 50297 50297 50304 50304 50324 50324 50332 50332 50360 50360 50364 50364 50409 50409 50416 50417 50420 50420 50424 50424 50426 50426 50431 50433 50444 50444 50448 50448 50452 50452 50460 50460 50472 50473 50476 50476 50480 50480 50488 50489 50491 50491 50493 50493 50500 50501 50504 50506 50508 50510 50515 50517 50519 50521 50525 50526 50528 50529 50532 50532 50536 50536 50544 50545 50547 50549 50556 50557 50560 50560 50564 50564 50567 50567 50572 50573 50575 50575 50577 50577 50581 50581 50583 50584 50588 50588 50592 50592 50601 50601 50612 50613 50616 50617 50619 50622 50628 50634 50636 50636 50638 50638 50640 50641 50644 50644 50648 50648 50656 50657 50659 50659 50661 50661 50668 50670 50672 50672 50676 50676 50678 50679 50684 50689 50693 50696 50700 50700 50704 50704 50712 50713 50715 50716 50724 50725 50728 50728 50732 50734 50736 50736 50739 50741 50743 50743 50745 50745 50747 50747 50752 50753 50756 50756 50760 50760 50768 50769 50771 50773 50780 50781 50784 50784 50796 50796 50799 50799 50801 50801 50808 50809 50812 50812 50816 50816 50824 50825 50827 50827 50829 50829 50836 50837 50840 50840 50844 50844 50852 50853 50855 50855 50857 50857 50864 50865 50868 50868 50872 50874 50880 50881 50883 50883 50885 50885 50892 50893 50896 50896 50900 50900 50908 50909 50912 50913 50920 50921 50924 50924 50928 50928 50936 50937 50941 50941 50948 50949 50952 50952 50956 50956 50964 50965 50967 50967 50969 50969 50976 50977 50980 50980 50984 50984 50992 50993 50995 50995 50997 50997 50999 50999 51004 51005 51008 51008 51012 51012 51018 51018 51020 51021 51023 51023 51025 51032 51036 51036 51040 51040 51048 51048 51051 51051 51060 51061 51064 51064 51068 51070 51075 51077 51079 51082 51086 51086 51088 51089 51092 51092 51094 51096 51098 51098 51104 51105 51107 51110 51116 51117 51120 51120 51124 51124 51132 51133 51135 51137 51144 51145 51148 51148 51150 51150 51152 51152 51160 51160 51165 51165 51172 51172 51176 51176 51180 51180 51200 51201 51204 51204 51208 51208 51210 51210 51216 51217 51219 51219 51221 51222 51228 51229 51232 51232 51236 51236 51244 51245 51247 51247 51249 51249 51256 51256 51260 51260 51264 51264 51272 51273 51276 51277 51284 51284 51312 51313 51316 51316 51320 51320 51322 51322 51328 51329 51331 51331 51333 51335 51339 51341 51348 51348 51357 51357 51359 51359 51361 51361 51368 51368 51388 51389 51396 51396 51400 51400 51404 51404 51412 51413 51415 51415 51417 51417 51424 51425 51428 51428 51445 51445 51452 51453 51456 51456 51460 51462 51468 51469 51471 51471 51473 51473 51480 51480 51500 51500 51508 51508 51536 51537 51540 51540 51544 51544 51552 51553 51555 51555 51564 51564 51568 51568 51572 51572 51580 51580 51592 51593 51596 51596 51600 51600 51608 51609 51611 51611 51613 51613 51648 51649 51652 51652 51655 51656 51658 51658 51664 51665 51667 51667 51669 51670 51673 51674 51676 51677 51680 51680 51682 51682 51684 51684 51687 51687 51692 51693 51695 51697 51704 51705 51708 51708 51712 51712 51720 51721 51723 51725 51732 51732 51736 51736 51753 51753 51788 51789 51792 51792 51796 51796 51804 51805 51807 51809 51816 51816 51837 51837 51844 51844 51864 51864 51900 51901 51904 51904 51908 51908 51916 51917 51919 51919 51921 51921 51923 51923 51928 51929 51936 51936 51948 51948 51956 51956 51976 51976 51984 51984 51988 51988 51992 51992 52000 52001 52033 52033 52040 52041 52044 52044 52048 52048 52056 52057 52061 52061 52068 52068 52088 52089 52124 52124 52152 52152 52180 52180 52196 52196 52199 52199 52201 52201 52236 52237 52240 52240 52244 52244 52252 52253 52257 52258 52263 52265 52268 52268 52270 52270 52272 52272 52280 52281 52283 52286 52292 52293 52296 52296 52300 52300 52308 52309 52311 52313 52320 52320 52324 52324 52326 52326 52328 52328 52336 52336 52341 52341 52376 52377 52380 52380 52384 52384 52392 52393 52395 52397 52404 52405 52408 52408 52412 52412 52420 52421 52423 52423 52425 52425 52432 52432 52436 52436 52452 52452 52460 52460 52464 52464 52481 52481 52488 52489 52492 52492 52496 52496 52504 52505 52507 52507 52509 52509 52516 52516 52520 52520 52524 52524 52537 52537 52572 52572 52576 52576 52580 52580 52588 52589 52591 52591 52593 52593 52600 52600 52616 52616 52628 52629 52632 52632 52636 52636 52644 52645 52647 52647 52649 52649 52656 52656 52676 52676 52684 52684 52688 52688 52712 52712 52716 52716 52720 52720 52728 52729 52731 52731 52733 52733 52740 52740 52744 52744 52748 52748 52756 52756 52761 52761 52768 52769 52772 52772 52776 52776 52784 52785 52787 52787 52789 52789 52824 52825 52828 52828 52831 52833 52840 52841 52843 52843 52845 52845 52852 52853 52856 52856 52860 52860 52868 52869 52871 52871 52873 52873 52880 52881 52884 52884 52888 52888 52896 52897 52899 52901 52908 52909 52929 52929 52964 52965 52968 52968 52971 52972 52980 52981 52983 52985 52992 52993 52996 52996 53000 53000 53008 53009 53011 53011 53013 53013 53020 53020 53024 53024 53028 53028 53036 53037 53039 53041 53048 53048 53076 53077 53080 53080 53084 53084 53092 53093 53095 53095 53097 53097 53104 53105 53108 53108 53112 53112 53120 53120 53125 53125 53132 53132 53153 53153 53160 53160 53168 53168 53188 53188 53216 53217 53220 53220 53224 53224 53232 53233 53235 53235 53237 53237 53244 53244 53248 53248 53252 53252 53265 53265 53272 53272 53293 53293 53300 53301 53304 53304 53308 53308 53316 53317 53319 53319 53321 53321 53328 53328 53332 53332 53336 53336 53344 53344 53356 53357 53360 53360 53364 53364 53372 53373 53377 53377 53412 53413 53416 53416 53420 53420 53428 53429 53431 53431 53433 53433 53440 53441 53444 53444 53448 53449 53456 53457 53459 53461 53468 53469 53472 53472 53476 53476 53484 53485 53487 53489 53496 53496 53517 53517 53552 53553 53556 53556 53560 53560 53562 53562 53568 53569 53571 53573 53580 53581 53584 53584 53588 53588 53596 53597 53599 53599 53601 53601 53608 53608 53612 53612 53628 53628 53636 53636 53640 53640 53664 53665 53668 53668 53672 53672 53680 53681 53683 53683 53685 53685 53690 53690 53692 53692 53696 53696 53720 53720 53748 53748 53752 53752 53767 53767 53769 53769 53776 53776 53804 53805 53808 53808 53812 53812 53820 53821 53823 53823 53825 53825 53832 53832 53852 53852 53860 53860 53888 53889 53892 53892 53896 53896 53904 53905 53909 53909 53916 53916 53920 53920 53924 53924 53932 53932 53937 53937 53944 53945 53948 53948 53951 53952 53954 53954 53960 53961 53963 53963 53972 53972 53976 53976 53980 53980 53988 53989 54000 54001 54004 54004 54008 54008 54016 54017 54019 54019 54021 54021 54028 54030 54032 54032 54036 54036 54038 54038 54044 54045 54047 54049 54053 54053 54056 54057 54060 54060 54064 54064 54072 54073 54075 54077 54084 54085 54140 54141 54144 54144 54148 54148 54156 54157 54159 54161 54168 54169 54172 54172 54176 54176 54184 54185 54187 54187 54189 54189 54196 54196 54200 54200 54204 54204 54212 54213 54216 54217 54224 54224 54232 54232 54241 54241 54243 54243 54252 54253 54256 54256 54260 54260 54268 54269 54271 54271 54273 54273 54280 54280 54301 54301 54336 54336 54340 54340 54364 54364 54368 54368 54372 54372 54381 54381 54383 54383 54392 54393 54396 54396 54399 54400 54402 54402 54408 54409 54411 54411 54413 54413 54420 54420 54441 54441 54476 54476 54480 54480 54484 54484 54492 54492 54495 54495 54504 54504 54508 54508 54512 54512 54520 54520 54523 54523 54525 54525 54532 54532 54536 54536 54540 54540 54548 54549 54551 54551 54588 54589 54592 54592 54596 54596 54604 54605 54607 54607 54609 54609 54616 54617 54620 54620 54624 54624 54629 54629 54632 54633 54635 54635 54637 54637 54644 54645 54648 54648 54652 54652 54660 54661 54663 54665 54672 54672 54693 54693 54728 54729 54732 54732 54736 54736 54738 54738 54744 54745 54747 54747 54749 54749 54756 54757 54760 54760 54764 54764 54772 54773 54775 54775 54777 54777 54784 54785 54788 54788 54792 54792 54800 54801 54803 54805 54812 54812 54816 54816 54820 54820 54829 54829 54840 54841 54844 54844 54848 54848 54853 54853 54856 54857 54859 54859 54861 54861 54865 54865 54868 54869 54872 54872 54876 54876 54887 54887 54889 54889 54896 54897 54900 54900 54915 54915 54917 54917 54924 54925 54928 54928 54932 54932 54941 54941 54943 54943 54945 54945 54952 54952 54956 54956 54960 54960 54969 54969 54971 54971 54980 54981 54984 54984 54988 54988 54993 54993 54996 54996 54999 54999 55001 55001 55008 55008 55012 55012 55016 55016 55024 55024 55029 55029 55036 55037 55040 55040 55044 55044 55057 55057 55064 55065 55068 55068 55072 55072 55080 55081 55083 55083 55085 55085 55092 55093 55096 55096 55100 55100 55108 55108 55111 55111 55113 55113 55120 55121 55124 55124 55126 55129 55136 55137 55139 55139 55141 55141 55145 55145 55148 55148 55152 55152 55156 55156 55164 55165 55169 55169 55176 55177 55180 55180 55184 55184 55192 55193 55195 55195 55197 55197 63744 64011 65281 65374 65504 65507 65509 65510 917504 917631)) (make-character-set :mib-enum 2086 :name "IBM866" :aliases '("csIBM866" "866" "cp866") :mime-encoding 'nil :source '"IBM NLDG Volume 2 (SE09-8002-03) August 1994" :comments 'nil :references '("[Pond]") :ranges #(0 127 160 160 164 164 176 176 183 183 1025 1025 1028 1028 1031 1031 1038 1038 1040 1103 1105 1105 1108 1108 1111 1111 1118 1118 8470 8470 8729 8730 9472 9472 9474 9474 9484 9484 9488 9488 9492 9492 9496 9496 9500 9500 9508 9508 9516 9516 9524 9524 9532 9532 9552 9580 9600 9600 9604 9604 9608 9608 9612 9612 9616 9619 9632 9632)) (make-character-set :mib-enum 2088 :name "KOI8-U" :aliases 'nil :mime-encoding 'nil :source '"RFC 2319" :comments 'nil :references '("[RFC2319]") :ranges #(0 127 160 160 169 169 176 176 178 178 183 183 247 247 1025 1025 1028 1028 1030 1031 1040 1103 1105 1105 1108 1108 1110 1111 1168 1169 8729 8730 8776 8776 8804 8805 8992 8993 9472 9472 9474 9474 9484 9484 9488 9488 9492 9492 9496 9496 9500 9500 9508 9508 9516 9516 9524 9524 9532 9532 9552 9554 9556 9556 9559 9563 9565 9569 9571 9571 9574 9578 9580 9580 9600 9600 9604 9604 9608 9608 9612 9612 9616 9619 9632 9632)) (make-character-set :mib-enum 2083 :name "VIQR" :aliases '("csVIQR") :mime-encoding 'nil :source '"RFC 1456" :comments 'nil :references '("[RFC1456]") :ranges nil) (make-character-set :mib-enum 2103 :name "PTCP154" :aliases '("Cyrillic-Asian" "CP154" "PT154" "csPTCP154") :mime-encoding 'nil :source '"See (http://www.iana.org/assignments/charset-reg/PTCP154)" :comments 'nil :references '("[Uskov]") :ranges nil) (make-character-set :mib-enum 2045 :name "IBM851" :aliases '("csIBM851" "851" "cp851") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2085 :name "HZ-GB-2312" :aliases 'nil :mime-encoding 'nil :source '"RFC 1842, RFC 1843 [RFC1842, RFC1843]" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 2107 :name "TSCII" :aliases '("csTSCII") :mime-encoding 'nil :source '"See <http://www.iana.org/assignments/charset-reg/TSCII> [Kalyanasundaram]" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 2106 :name "BRF" :aliases '("csBRF") :mime-encoding 'nil :source '"See <http://www.iana.org/assignments/charset-reg/BRF> [Thibault]" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 2105 :name "KOI7-switched" :aliases 'nil :mime-encoding 'nil :source '"See <http://www.iana.org/assignments/charset-reg/KOI7-switched>" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 2104 :name "Amiga-1251" :aliases '("Ami-1251" "Amiga1251" "Ami1251") :mime-encoding 'nil :source '"See (http://www.amiga.ultranet.ru/Amiga-1251.html)" :comments '(" " "(Aliases are provided for historical reasons and should not be used) [Malyshev]") :references 'nil :ranges nil) (make-character-set :mib-enum 2102 :name "IBM1047" :aliases '("IBM-1047") :mime-encoding 'nil :source '"IBM1047 (EBCDIC Latin 1/Open Systems)" :comments '("http://www-1.ibm.com/servers/eserver/iseries/software/globalization/pdf/cp01047z.pdf") :references '("[Robrigado]") :ranges nil) (make-character-set :mib-enum 2100 :name "IBM01149" :aliases '("ebcdic-is-871+euro" "CP01149" "CCSID01149") :mime-encoding 'nil :source '"IBM See (http://www.iana.org/assignments/charset-reg/IBM01149) [Mahdi]" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 2099 :name "IBM01148" :aliases '("ebcdic-international-500+euro" "CP01148" "CCSID01148") :mime-encoding 'nil :source '"IBM See (http://www.iana.org/assignments/charset-reg/IBM01148) [Mahdi]" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 2098 :name "IBM01147" :aliases '("ebcdic-fr-297+euro" "CP01147" "CCSID01147") :mime-encoding 'nil :source '"IBM See (http://www.iana.org/assignments/charset-reg/IBM01147) [Mahdi]" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 2097 :name "IBM01146" :aliases '("ebcdic-gb-285+euro" "CP01146" "CCSID01146") :mime-encoding 'nil :source '"IBM See (http://www.iana.org/assignments/charset-reg/IBM01146) [Mahdi]" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 2096 :name "IBM01145" :aliases '("ebcdic-es-284+euro" "CP01145" "CCSID01145") :mime-encoding 'nil :source '"IBM See (http://www.iana.org/assignments/charset-reg/IBM01145) [Mahdi]" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 2095 :name "IBM01144" :aliases '("ebcdic-it-280+euro" "CP01144" "CCSID01144") :mime-encoding 'nil :source '"IBM See (http://www.iana.org/assignments/charset-reg/IBM01144) [Mahdi]" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 2094 :name "IBM01143" :aliases '("ebcdic-se-278+euro" "ebcdic-fi-278+euro" "CP01143" "CCSID01143") :mime-encoding 'nil :source '"IBM See (http://www.iana.org/assignments/charset-reg/IBM01143) [Mahdi]" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 2093 :name "IBM01142" :aliases '("ebcdic-no-277+euro" "ebcdic-dk-277+euro" "CP01142" "CCSID01142") :mime-encoding 'nil :source '"IBM See (http://www.iana.org/assignments/charset-reg/IBM01142) [Mahdi]" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 2092 :name "IBM01141" :aliases '("ebcdic-de-273+euro" "CP01141" "CCSID01141") :mime-encoding 'nil :source '"IBM See (http://www.iana.org/assignments/charset-reg/IBM01141) [Mahdi]" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 2091 :name "IBM01140" :aliases '("ebcdic-us-37+euro" "CP01140" "CCSID01140") :mime-encoding 'nil :source '"IBM See (http://www.iana.org/assignments/charset-reg/IBM01140) [Mahdi]" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 2090 :name "IBM00924" :aliases '("ebcdic-Latin9--euro" "CP00924" "CCSID00924") :mime-encoding 'nil :source '"IBM See (http://www.iana.org/assignments/charset-reg/IBM00924) [Mahdi]" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 2089 :name "IBM00858" :aliases '("PC-Multilingual-850+euro" "CP00858" "CCSID00858") :mime-encoding 'nil :source '"IBM See (http://www.iana.org/assignments/charset-reg/IBM00858) [Mahdi]" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 2081 :name "MNEM" :aliases '("csMnem") :mime-encoding 'nil :source '"RFC 1345, also known as \"mnemonic+ascii+8200\"" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2080 :name "MNEMONIC" :aliases '("csMnemonic") :mime-encoding 'nil :source '"RFC 1345, also known as \"mnemonic+ascii+38\"" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2079 :name "UNKNOWN-8BIT" :aliases '("csUnknown8BiT") :mime-encoding 'nil :source 'nil :comments 'nil :references '("[RFC1428]") :ranges nil) (make-character-set :mib-enum 2078 :name "EBCDIC-US" :aliases '("csEBCDICUS") :mime-encoding 'nil :source '"IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2077 :name "EBCDIC-UK" :aliases '("csEBCDICUK") :mime-encoding 'nil :source '"IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2076 :name "EBCDIC-ES-S" :aliases '("csEBCDICESS") :mime-encoding 'nil :source '"IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2075 :name "EBCDIC-ES-A" :aliases '("csEBCDICESA") :mime-encoding 'nil :source '"IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2074 :name "EBCDIC-ES" :aliases '("csEBCDICES") :mime-encoding 'nil :source '"IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2073 :name "EBCDIC-PT" :aliases '("csEBCDICPT") :mime-encoding 'nil :source '"IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2072 :name "EBCDIC-IT" :aliases '("csEBCDICIT") :mime-encoding 'nil :source '"IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2071 :name "EBCDIC-FR" :aliases '("csEBCDICFR") :mime-encoding 'nil :source '"IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2070 :name "EBCDIC-FI-SE-A" :aliases '("csEBCDICFISEA") :mime-encoding 'nil :source '"IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2069 :name "EBCDIC-FI-SE" :aliases '("csEBCDICFISE") :mime-encoding 'nil :source '"IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2068 :name "EBCDIC-DK-NO-A" :aliases '("csEBCDICDKNOA") :mime-encoding 'nil :source '"IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2067 :name "EBCDIC-DK-NO" :aliases '("csEBCDICDKNO") :mime-encoding 'nil :source '"IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2066 :name "EBCDIC-CA-FR" :aliases '("csEBCDICCAFR") :mime-encoding 'nil :source '"IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2065 :name "EBCDIC-AT-DE-A" :aliases '("csEBCDICATDEA") :mime-encoding 'nil :source '"IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2064 :name "EBCDIC-AT-DE" :aliases '("csIBMEBCDICATDE") :mime-encoding 'nil :source '"IBM 3270 Char Set Ref Ch 10, GA27-2837-9, April 1987" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2063 :name "IBM1026" :aliases '("csIBM1026" "CP1026") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2062 :name "IBM918" :aliases '("csIBM918" "ebcdic-cp-ar2" "CP918") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2061 :name "IBM905" :aliases '("csIBM905" "ebcdic-cp-tr" "CP905") :mime-encoding 'nil :source '"IBM 3174 Character Set Ref, GA27-3831-02, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2060 :name "IBM904" :aliases '("csIBBM904" "904" "cp904") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2059 :name "IBM903" :aliases '("csIBM903" "cp903") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2058 :name "IBM891" :aliases '("csIBM891" "cp891") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2057 :name "IBM880" :aliases '("csIBM880" "EBCDIC-Cyrillic" "cp880") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2056 :name "IBM871" :aliases '("csIBM871" "ebcdic-cp-is" "CP871") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2055 :name "IBM870" :aliases '("csIBM870" "ebcdic-cp-yu" "ebcdic-cp-roece" "CP870") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2053 :name "IBM868" :aliases '("csIBM868" "cp-ar" "CP868") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2044 :name "IBM500" :aliases '("csIBM500" "ebcdic-cp-ch" "ebcdic-cp-be" "CP500") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2043 :name "IBM424" :aliases '("csIBM424" "ebcdic-cp-he" "cp424") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2042 :name "IBM423" :aliases '("csIBM423" "ebcdic-cp-gr" "cp423") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2041 :name "IBM420" :aliases '("csIBM420" "ebcdic-cp-ar1" "cp420") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990, IBM NLS RM p 11-11" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2040 :name "IBM297" :aliases '("csIBM297" "ebcdic-cp-fr" "cp297") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2039 :name "IBM290" :aliases '("csIBM290" "EBCDIC-JP-kana" "cp290") :mime-encoding 'nil :source '"IBM 3174 Character Set Ref, GA27-3831-02, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2038 :name "IBM285" :aliases '("csIBM285" "ebcdic-cp-gb" "CP285") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2037 :name "IBM284" :aliases '("csIBM284" "ebcdic-cp-es" "CP284") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2036 :name "IBM281" :aliases '("csIBM281" "cp281" "EBCDIC-JP-E") :mime-encoding 'nil :source '"IBM 3174 Character Set Ref, GA27-3831-02, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2035 :name "IBM280" :aliases '("csIBM280" "ebcdic-cp-it" "CP280") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2034 :name "IBM278" :aliases '("csIBM278" "ebcdic-cp-se" "ebcdic-cp-fi" "CP278") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2033 :name "IBM277" :aliases '("csIBM277" "EBCDIC-CP-NO" "EBCDIC-CP-DK") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2032 :name "IBM275" :aliases '("csIBM275" "cp275" "EBCDIC-BR") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2031 :name "IBM274" :aliases '("csIBM274" "CP274" "EBCDIC-BE") :mime-encoding 'nil :source '"IBM 3174 Character Set Ref, GA27-3831-02, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2030 :name "IBM273" :aliases '("csIBM273" "CP273") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2029 :name "IBM038" :aliases '("csIBM038" "cp038" "EBCDIC-INT") :mime-encoding 'nil :source '"IBM 3174 Character Set Ref, GA27-3831-02, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2028 :name "IBM037" :aliases '("csIBM037" "ebcdic-cp-nl" "ebcdic-cp-wt" "ebcdic-cp-ca" "ebcdic-cp-us" "cp037") :mime-encoding 'nil :source '"IBM NLS RM Vol2 SE09-8002-01, March 1990" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2024 :name "Windows-31J" :aliases '("csWindows31J") :mime-encoding 'nil :source '"Windows Japanese. A further extension of Shift_JIS to include NEC special characters (Row 13), NEC selection of IBM extensions (Rows 89 to 92), and IBM extensions (Rows 115 to 119). The CCS's are JIS X0201:1997, JIS X0208:1997, and these extensions. This charset can be used for the top-level media type \"text\", but it is of limited or specialized use (see RFC2278). PCL Symbol Set id: 19K" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 2023 :name "Microsoft-Publishing" :aliases '("csMicrosoftPublishing") :mime-encoding 'nil :source '"PCL 5 Comparison Guide, Hewlett-Packard, HP part number 5961-0510, October 1992 PCL Symbol Set id: 6J" :comments 'nil :references '("[HP-PCL5]") :ranges nil) (make-character-set :mib-enum 2022 :name "Ventura-Math" :aliases '("csVenturaMath") :mime-encoding 'nil :source '"PCL 5 Comparison Guide, Hewlett-Packard, HP part number 5961-0510, October 1992 PCL Symbol Set id: 6M" :comments 'nil :references '("[HP-PCL5]") :ranges nil) (make-character-set :mib-enum 2021 :name "HP-DeskTop" :aliases '("csHPDesktop") :mime-encoding 'nil :source '"PCL 5 Comparison Guide, Hewlett-Packard, HP part number 5961-0510, October 1992 PCL Symbol Set id: 7J" :comments 'nil :references '("[HP-PCL5]") :ranges nil) (make-character-set :mib-enum 2020 :name "Adobe-Symbol-Encoding" :aliases '("csHPPSMath") :mime-encoding 'nil :source '"PostScript Language Reference Manual PCL Symbol Set id: 5M" :comments 'nil :references '("[Adobe]") :ranges nil) (make-character-set :mib-enum 2019 :name "HP-Math8" :aliases '("csHPMath8") :mime-encoding 'nil :source '"PCL 5 Comparison Guide, Hewlett-Packard, HP part number 5961-0510, October 1992 PCL Symbol Set id: 8M" :comments 'nil :references '("[HP-PCL5]") :ranges nil) (make-character-set :mib-enum 2018 :name "HP-Pi-font" :aliases '("csHPPiFont") :mime-encoding 'nil :source '"PCL 5 Comparison Guide, Hewlett-Packard, HP part number 5961-0510, October 1992 PCL Symbol Set id: 15U" :comments 'nil :references '("[HP-PCL5]") :ranges nil) (make-character-set :mib-enum 2017 :name "HP-Legal" :aliases '("csHPLegal") :mime-encoding 'nil :source '"PCL 5 Comparison Guide, Hewlett-Packard, HP part number 5961-0510, October 1992 PCL Symbol Set id: 1U" :comments 'nil :references '("[HP-PCL5]") :ranges nil) (make-character-set :mib-enum 2016 :name "IBM-Thai" :aliases '("csIBMThai") :mime-encoding 'nil :source '"Presentation Set, CPGID: 838" :comments 'nil :references '("[IBM-CIDT]") :ranges nil) (make-character-set :mib-enum 2015 :name "IBM-Symbols" :aliases '("csIBMSymbols") :mime-encoding 'nil :source '"Presentation Set, CPGID: 259" :comments 'nil :references '("[IBM-CIDT]") :ranges nil) (make-character-set :mib-enum 2014 :name "PC8-Turkish" :aliases '("csPC8Turkish") :mime-encoding 'nil :source '"PC Latin Turkish. PCL Symbol Set id: 9T" :comments 'nil :references '("[HP-PCL5]") :ranges nil) (make-character-set :mib-enum 2012 :name "PC8-Danish-Norwegian" :aliases '("csPC8DanishNorwegian") :mime-encoding 'nil :source '"PC Danish Norwegian 8-bit PC set for Danish Norwegian PCL Symbol Set id: 11U" :comments 'nil :references '("[HP-PCL5]") :ranges nil) (make-character-set :mib-enum 2008 :name "DEC-MCS" :aliases '("csDECMCS" "dec") :mime-encoding 'nil :source '"VAX/VMS User's Manual, Order Number: AI-Y517A-TE, April 1986." :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 2007 :name "Ventura-International" :aliases '("csVenturaInternational") :mime-encoding 'nil :source '"Ventura International. ASCII plus coded characters similar to Roman8. PCL Symbol Set id: 13J" :comments 'nil :references '("[HP-PCL5]") :ranges nil) (make-character-set :mib-enum 2006 :name "Ventura-US" :aliases '("csVenturaUS") :mime-encoding 'nil :source '"Ventura US. ASCII plus characters typically used in publishing, like pilcrow, copyright, registered, trade mark, section, dagger, and double dagger in the range A0 (hex) to FF (hex). PCL Symbol Set id: 14J" :comments 'nil :references '("[HP-PCL5]") :ranges nil) (make-character-set :mib-enum 2005 :name "Adobe-Standard-Encoding" :aliases '("csAdobeStandardEncoding") :mime-encoding 'nil :source '"PostScript Language Reference Manual PCL Symbol Set id: 10J" :comments 'nil :references '("[Adobe]") :ranges nil) (make-character-set :mib-enum 2003 :name "ISO-8859-9-Windows-Latin-5" :aliases '("csWindows31Latin5") :mime-encoding 'nil :source '"Extended ISO 8859-9. Latin-5 for Windows 3.1 PCL Symbol Set id: 5T" :comments 'nil :references '("[HP-PCL5]") :ranges nil) (make-character-set :mib-enum 2002 :name "ISO-8859-2-Windows-Latin-2" :aliases '("csWindows31Latin2") :mime-encoding 'nil :source '"Extended ISO 8859-2. Latin-2 for Windows 3.1. PCL Symbol Set id: 9E" :comments 'nil :references '("[HP-PCL5]") :ranges nil) (make-character-set :mib-enum 2001 :name "ISO-8859-1-Windows-3.1-Latin-1" :aliases '("csWindows31Latin1") :mime-encoding 'nil :source '"Extended ISO 8859-1 Latin-1 for Windows 3.1. PCL Symbol Set id: 19U" :comments 'nil :references '("[HP-PCL5]") :ranges nil) (make-character-set :mib-enum 2000 :name "ISO-8859-1-Windows-3.0-Latin-1" :aliases '("csWindows30Latin1") :mime-encoding 'nil :source '"Extended ISO 8859-1 Latin-1 for Windows 3.0. PCL Symbol Set id: 9U" :comments 'nil :references '("[HP-PCL5]") :ranges nil) (make-character-set :mib-enum 1020 :name "BOCU-1" :aliases '("csBOCU-1") :mime-encoding 'nil :source '"http://www.unicode.org/notes/tn6/" :comments 'nil :references '("[Scherer]") :ranges nil) (make-character-set :mib-enum 1018 :name "UTF-32BE" :aliases 'nil :mime-encoding 'nil :source '"<http://www.unicode.org/unicode/reports/tr19/>" :comments 'nil :references '("[Davis]") :ranges nil) (make-character-set :mib-enum 1017 :name "UTF-32" :aliases 'nil :mime-encoding 'nil :source '"<http://www.unicode.org/unicode/reports/tr19/>" :comments 'nil :references '("[Davis]") :ranges nil) (make-character-set :mib-enum 1016 :name "CESU-8" :aliases '("csCESU-8") :mime-encoding 'nil :source '"<http://www.unicode.org/unicode/reports/tr26>" :comments 'nil :references '("[Phipps]") :ranges nil) (make-character-set :mib-enum 1011 :name "SCSU" :aliases 'nil :mime-encoding 'nil :source '"SCSU See (http://www.iana.org/assignments/charset-reg/SCSU) [Scherer]" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 1010 :name "UNICODE-1-1" :aliases '("csUnicode11") :mime-encoding 'nil :source '"RFC 1641" :comments 'nil :references '("[RFC1641]") :ranges nil) (make-character-set :mib-enum 1009 :name "ISO-Unicode-IBM-1265" :aliases '("csUnicodeIBM1265") :mime-encoding 'nil :source '"IBM Hebrew Presentation Set, GCSGID: 1265" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 1008 :name "ISO-Unicode-IBM-1264" :aliases '("csUnicodeIBM1264") :mime-encoding 'nil :source '"IBM Arabic Presentation Set, GCSGID: 1264" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 1007 :name "ISO-Unicode-IBM-1276" :aliases '("csUnicodeIBM1276") :mime-encoding 'nil :source '"IBM Cyrillic Greek Extended Presentation Set, GCSGID: 1276" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 1006 :name "ISO-Unicode-IBM-1268" :aliases '("csUnicodeIBM1268") :mime-encoding 'nil :source '"IBM Latin-4 Extended Presentation Set, GCSGID: 1268" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 1005 :name "ISO-Unicode-IBM-1261" :aliases '("csUnicodeIBM1261") :mime-encoding 'nil :source '"IBM Latin-2, -3, -5, Extended Presentation Set, GCSGID: 1261" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum nil :name "ISO-10646-J-1" :aliases 'nil :mime-encoding 'nil :source '"ISO 10646 Japanese, see RFC 1815." :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 1003 :name "ISO-10646-Unicode-Latin1" :aliases '("ISO-10646" "csUnicodeLatin1") :mime-encoding 'nil :source '"ISO Latin-1 subset of Unicode. Basic Latin and Latin-1 Supplement = collections 1 and 2. See ISO 10646, Appendix A. See RFC 1815." :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 1002 :name "ISO-10646-UCS-Basic" :aliases '("csUnicodeASCII") :mime-encoding 'nil :source '"ASCII subset of Unicode. Basic Latin = collection 1 See ISO 10646, Appendix A" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 1000 :name "ISO-10646-UCS-2" :aliases '("csUnicode") :mime-encoding 'nil :source '"the 2-octet Basic Multilingual Plane, aka Unicode this needs to specify network byte order: the standard does not specify (it is a 16-bit integer space)" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 119 :name "KZ-1048" :aliases '("csKZ1048" "RK1048" "STRK1048-2002") :mime-encoding 'nil :source '"See <http://www.iana.org/assignments/charset-reg/KZ-1048> [Veremeev, Kikkarin]" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 118 :name "ISO-11548-1" :aliases '("csISO115481" "ISO_TR_11548-1" "ISO_11548-1") :mime-encoding 'nil :source '"See <http://www.iana.org/assignments/charset-reg/ISO-11548-1> [Thibault]" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 117 :name "OSD_EBCDIC_DF04_1" :aliases 'nil :mime-encoding 'nil :source '"Fujitsu-Siemens standard mainframe EBCDIC encoding Please see: <http://www.iana.org/assignments/charset-reg/OSD-EBCDIC-DF04-1>" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 116 :name "OSD_EBCDIC_DF03_IRV" :aliases 'nil :mime-encoding 'nil :source '"Fujitsu-Siemens standard mainframe EBCDIC encoding Please see: <http://www.iana.org/assignments/charset-reg/OSD-EBCDIC-DF03-IRV>" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 115 :name "OSD_EBCDIC_DF04_15" :aliases 'nil :mime-encoding 'nil :source '"Fujitsu-Siemens standard mainframe EBCDIC encoding Please see: <http://www.iana.org/assignments/charset-reg/OSD-EBCDIC-DF04-15>" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 103 :name "UNICODE-1-1-UTF-7" :aliases '("csUnicode11UTF7") :mime-encoding 'nil :source '"RFC 1642" :comments 'nil :references '("[RFC1642]") :ranges nil) (make-character-set :mib-enum 102 :name "KSC5636" :aliases '("csKSC5636" "ISO646-KR") :mime-encoding 'nil :source 'nil :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 101 :name "dk-us" :aliases '("csDKUS") :mime-encoding 'nil :source 'nil :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 100 :name "us-dk" :aliases '("csUSDK") :mime-encoding 'nil :source 'nil :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 99 :name "DS_2089" :aliases '("csISO646Danish" "dk" "ISO646-DK" "DS2089") :mime-encoding 'nil :source '"Danish Standard, DS 2089, February 1974" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 98 :name "JIS_X0212-1990" :aliases '("csISO159JISX02121990" "iso-ir-159" "x0212") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 97 :name "latin-lap" :aliases '("csISO158Lap" "iso-ir-158" "lap") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 96 :name "ISO_10367-box" :aliases '("csISO10367Box" "iso-ir-155") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 95 :name "ISO_8859-supp" :aliases '("csISO8859Supp" "latin1-2-5" "iso-ir-154") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 94 :name "GOST_19768-74" :aliases '("csISO153GOST1976874" "iso-ir-153" "ST_SEV_358-88") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 93 :name "ISO_6937-2-25" :aliases '("csISO6937Add" "iso-ir-152") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 92 :name "NC_NC00-10:81" :aliases '("csISO151Cuba" "ISO646-CU" "iso-ir-151" "cuba") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 91 :name "greek-ccitt" :aliases '("csISO150GreekCCITT" "csISO150" "iso-ir-150") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 90 :name "JUS_I.B1.003-mac" :aliases '("csISO147Macedonian" "iso-ir-147" "macedonian") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 89 :name "JUS_I.B1.003-serb" :aliases '("csISO146Serbian" "serbian" "iso-ir-146") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 88 :name "IEC_P27-1" :aliases '("csISO143IECP271" "iso-ir-143") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 87 :name "JUS_I.B1.002" :aliases '("csISO141JUSIB1002" "yu" "js" "ISO646-YU" "iso-ir-141") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 86 :name "CSN_369103" :aliases '("csISO139CSN369103" "iso-ir-139") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 85 :name "ISO_8859-8-I" :aliases '(#21="ISO-8859-8-I" "csISO88598I") :mime-encoding '#21# :source '"RFC1556" :comments '("Alias: ISO-8859-8-I (preferred MIME name)") :references '("[RFC1556,Nussbacher]") :ranges nil) (make-character-set :mib-enum 84 :name "ISO_8859-8-E" :aliases '(#22="ISO-8859-8-E" "csISO88598E") :mime-encoding '#22# :source '"RFC1556" :comments '("Alias: ISO-8859-8-E (preferred MIME name)") :references '("[RFC1556,Nussbacher]") :ranges nil) (make-character-set :mib-enum 83 :name "T.101-G2" :aliases '("csISO128T101G2" "iso-ir-128") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 82 :name "ISO_8859-6-I" :aliases '(#23="ISO-8859-6-I" "csISO88596I") :mime-encoding '#23# :source '"RFC1556" :comments '("Alias: ISO-8859-6-I (preferred MIME name)") :references '("[RFC1556,IANA]") :ranges nil) (make-character-set :mib-enum 81 :name "ISO_8859-6-E" :aliases '(#24="ISO-8859-6-E" "csISO88596E") :mime-encoding '#24# :source '"RFC1556" :comments '("Alias: ISO-8859-6-E (preferred MIME name)") :references '("[RFC1556,IANA]") :ranges nil) (make-character-set :mib-enum 80 :name "CSA_Z243.4-1985-gr" :aliases '("csISO123CSAZ24341985gr" "iso-ir-123") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 79 :name "CSA_Z243.4-1985-2" :aliases '("csISO122Canadian2" "csa7-2" "ISO646-CA2" "iso-ir-122") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 78 :name "CSA_Z243.4-1985-1" :aliases '("csISO121Canadian1" "ca" "csa7-1" "ISO646-CA" "iso-ir-121") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 77 :name "ECMA-cyrillic" :aliases '("csISO111ECMACyrillic" "KOI8-E" "iso-ir-111") :mime-encoding 'nil :source '"ISO registry (formerly ECMA registry) http://www.itscj.ipsj.jp/ISO-IR/111.pdf" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 76 :name "T.61-8bit" :aliases '("csISO103T618bit" "iso-ir-103" "T.61") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 75 :name "T.61-7bit" :aliases '("csISO102T617bit" "iso-ir-102") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 74 :name "ANSI_X3.110-1983" :aliases '("csISO99NAPLPS" "NAPLPS" "CSA_T500-1983" "iso-ir-99") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 73 :name "ISO_2033-1983" :aliases '("csISO2033" "e13b" "iso-ir-98") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 72 :name "JIS_C6229-1984-kana" :aliases '("csISO96JISC62291984kana" "iso-ir-96") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 71 :name "JIS_C6229-1984-hand-add" :aliases '("csISO95JIS62291984handadd" "jp-ocr-hand-add" "iso-ir-95") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 70 :name "JIS_C6229-1984-hand" :aliases '("csISO94JIS62291984hand" "jp-ocr-hand" "iso-ir-94") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 69 :name "JIS_C6229-1984-b-add" :aliases '("csISO93JIS62291984badd" "jp-ocr-b-add" "iso-ir-93") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 68 :name "JIS_C6229-1984-b" :aliases '("csISO92JISC62991984b" "jp-ocr-b" "ISO646-JP-OCR-B" "iso-ir-92") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 67 :name "JIS_C6229-1984-a" :aliases '("csISO91JISC62291984a" "jp-ocr-a" "iso-ir-91") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 66 :name "iso-ir-90" :aliases '("csISO90") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 65 :name "ASMO_449" :aliases '("csISO89ASMO449" "iso-ir-89" "arabic7" "ISO_9036") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 64 :name "greek7" :aliases '("csISO88Greek7" "iso-ir-88") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 63 :name "JIS_C6226-1983" :aliases '("csISO87JISX0208" "JIS_X0208-1983" "x0208" "iso-ir-87") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 62 :name "MSZ_7795.3" :aliases '("csISO86Hungarian" "hu" "ISO646-HU" "iso-ir-86") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 61 :name "ES2" :aliases '("csISO85Spanish2" "ISO646-ES2" "iso-ir-85") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 60 :name "PT2" :aliases '("csISO84Portuguese2" "ISO646-PT2" "iso-ir-84") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 59 :name "videotex-suppl" :aliases '("csISO70VideotexSupp1" "iso-ir-70") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 58 :name "NS_4551-2" :aliases '("csISO61Norwegian2" "no2" "iso-ir-61" "ISO646-NO2") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 57 :name "GB_2312-80" :aliases '("csISO58GB231280" "chinese" "iso-ir-58") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 56 :name "GB_1988-80" :aliases '("csISO57GB1988" "ISO646-CN" "cn" "iso-ir-57") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 55 :name "ISO_5428:1980" :aliases '("csISO5428Greek" "iso-ir-55") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 54 :name "ISO_5427:1981" :aliases '("ISO5427Cyrillic1981" "iso-ir-54") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 53 :name "INIS-cyrillic" :aliases '("csISO51INISCyrillic" "iso-ir-51") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 52 :name "INIS-8" :aliases '("csISO50INIS8" "iso-ir-50") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 51 :name "INIS" :aliases '("csISO49INIS" "iso-ir-49") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 50 :name "BS_viewdata" :aliases '("csISO47BSViewdata" "iso-ir-47") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 49 :name "JIS_C6226-1978" :aliases '("csISO42JISC62261978" "iso-ir-42") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 48 :name "ISO_5427" :aliases '("csISO5427Cyrillic" "iso-ir-37") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 47 :name "Latin-greek-1" :aliases '("csISO27LatinGreek1" "iso-ir-27") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 46 :name "NF_Z_62-010_(1973)" :aliases '("csISO25French" "ISO646-FR1" "iso-ir-25") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 45 :name "latin-greek" :aliases '("csISO19LatinGreek" "iso-ir-19") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 44 :name "greek7-old" :aliases '("csISO18Greek7Old" "iso-ir-18") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 43 :name "PT" :aliases '("csISO16Portuguese" "ISO646-PT" "iso-ir-16") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 42 :name "JIS_C6220-1969-ro" :aliases '("csISO14JISC6220ro" "ISO646-JP" "jp" "iso-ir-14") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 41 :name "JIS_C6220-1969-jp" :aliases '("csISO13JISC6220jp" "x0201-7" "katakana" "iso-ir-13" "JIS_C6220-1969") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 36 :name "KS_C_5601-1987" :aliases '("csKSC56011987" "korean" "KSC_5601" "KS_C_5601-1989" "iso-ir-149") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 35 :name "SEN_850200_B" :aliases '("csISO10Swedish" "se" "ISO646-SE" "ISO646-FI" "FI" "iso-ir-10") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 34 :name "NATS-DANO-ADD" :aliases '("csNATSDANOADD" "iso-ir-9-2") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 33 :name "NATS-DANO" :aliases '("csNATSDANO" "iso-ir-9-1") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 32 :name "NATS-SEFI-ADD" :aliases '("csNATSSEFIADD" "iso-ir-8-2") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 31 :name "NATS-SEFI" :aliases '("csNATSSEFI" "iso-ir-8-1") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 30 :name "ISO_646.irv:1983" :aliases '("csISO2IntlRefVersion" "irv" "iso-ir-2") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 29 :name "INVARIANT" :aliases '("csINVARIANT") :mime-encoding 'nil :source 'nil :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 28 :name "ISO_646.basic:1983" :aliases '("csISO646basic1983" "ref") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 27 :name "ISO-10646-UTF-1" :aliases '("csISO10646UTF1") :mime-encoding 'nil :source '"Universal Transfer Format (1), this is the multibyte encoding, that subsets ASCII-7. It does not have byte ordering issues." :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 26 :name "NF_Z_62-010" :aliases '("csISO69French" "fr" "ISO646-FR" "iso-ir-69") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 25 :name "NS_4551-1" :aliases '("csISO60Norwegian1" "csISO60DanishNorwegian" "no" "ISO646-NO" "iso-ir-60") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 24 :name "DIN_66003" :aliases '("csISO21German" "ISO646-DE" "de" "iso-ir-21") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 23 :name "ES" :aliases '("csISO17Spanish" "ISO646-ES" "iso-ir-17") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 22 :name "IT" :aliases '("csISO15Italian" "ISO646-IT" "iso-ir-15") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 21 :name "SEN_850200_C" :aliases '("csISO11SwedishForNames" "se2" "ISO646-SE2" "iso-ir-11") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 20 :name "BS_4730" :aliases '("csISO4UnitedKingdom" "uk" "gb" "ISO646-GB" "iso-ir-4") :mime-encoding 'nil :source '"ECMA registry" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil) (make-character-set :mib-enum 19 :name "Extended_UNIX_Code_Fixed_Width_for_Japanese" :aliases '("csEUCFixWidJapanese") :mime-encoding 'nil :source '"Used in Japan. Each character is 2 octets. code set 0: US-ASCII (a single 7-bit byte set) 1st byte = 00 2nd byte = 20-7E code set 1: JIS X0208-1990 (a double 7-bit byte set) restricted to A0-FF in both bytes code set 2: Half Width Katakana (a single 7-bit byte set) 1st byte = 00 2nd byte = A0-FF code set 3: JIS X0212-1990 (a double 7-bit byte set) restricted to A0-FF in the first byte and 21-7E in the second byte" :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 16 :name "JIS_Encoding" :aliases '("csJISEncoding") :mime-encoding 'nil :source '"JIS X 0202-1991. Uses ISO 2022 escape sequences to shift code sets as documented in JIS X 0202-1991." :comments 'nil :references 'nil :ranges nil) (make-character-set :mib-enum 14 :name "ISO_6937-2-add" :aliases '("csISOTextComm" "iso-ir-142") :mime-encoding 'nil :source '"ECMA registry and ISO 6937-2:1983" :comments 'nil :references '("[RFC1345,KXS2]") :ranges nil))) ;;;; THE END ;;;;
747,309
Common Lisp
.lisp
10,882
62.766219
471
0.773812
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
72af57dec4fde5122b59a759719efe142de495e6ad6ac3bccad50b0c75e3544d
5,081
[ -1 ]
5,082
utility-test.lisp
informatimago_lisp/common-lisp/cesarum/utility-test.lisp
(in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY") (defun test/hash-table-projection () (let ((table (make-hash-table :test 'eql :rehash-size 1.640315 :rehash-threshold 0.640315))) (loop :for (key value) :in '((a 1) (b 2) (c 3) (d 4) (e 5)) :do (setf (gethash key table) value)) (let ((projection (hash-table-projection '() table))) (assert (eql 'eql (hash-table-test projection))) (assert (zerop (hash-table-count projection))) (assert (= 1.640315 (hash-table-rehash-size projection))) (assert (= 0.640315 (hash-table-rehash-threshold projection)))) (let ((projection (hash-table-projection '(a c e) table))) (assert (eql 'eql (hash-table-test projection))) (assert (= 3 (hash-table-count projection))) (assert (= 1.640315 (hash-table-rehash-size projection))) (assert (= 0.640315 (hash-table-rehash-threshold projection))) (assert (= 1 (gethash 'a projection))) (assert (= 3 (gethash 'c projection))) (assert (= 5 (gethash 'e projection)))) (let ((projection (hash-table-projection '(a d c b e) table))) (assert (eql 'eql (hash-table-test projection))) (assert (= 5 (hash-table-count projection))) (assert (= 1.640315 (hash-table-rehash-size projection))) (assert (= 0.640315 (hash-table-rehash-threshold projection))) (assert (= 1 (gethash 'a projection))) (assert (= 2 (gethash 'b projection))) (assert (= 3 (gethash 'c projection))) (assert (= 4 (gethash 'd projection))) (assert (= 5 (gethash 'e projection)))) (let ((projection (hash-table-projection (lambda (key value) (declare (ignore key)) (oddp value)) table))) (assert (eql 'eql (hash-table-test projection))) (assert (= 3 (hash-table-count projection))) (assert (= 1.640315 (hash-table-rehash-size projection))) (assert (= 0.640315 (hash-table-rehash-threshold projection))) (assert (= 1 (gethash 'a projection))) (assert (= 3 (gethash 'c projection))) (assert (= 5 (gethash 'e projection)))) (let ((projection (hash-table-projection (constantly t) table))) (assert (eql 'eql (hash-table-test projection))) (assert (= 5 (hash-table-count projection))) (assert (= 1.640315 (hash-table-rehash-size projection))) (assert (= 0.640315 (hash-table-rehash-threshold projection))) (assert (= 1 (gethash 'a projection))) (assert (= 2 (gethash 'b projection))) (assert (= 3 (gethash 'c projection))) (assert (= 4 (gethash 'd projection))) (assert (= 5 (gethash 'e projection))))) :success) (defun test/get-option () (mapc (lambda (expected-arguments) (destructuring-bind (expected arguments) expected-arguments (handler-case (let ((result (apply (function get-option) arguments))) (if (equal expected result) result (error "For ~S, expected ~S, got ~S" (cons 'get-option arguments) expected result))) (error (err) (if (eql expected 'error) err (error "For ~S, expected ~S, got ~S" (cons 'get-option arguments) expected err)))))) '((nil (:foo (:bar (:quux)))) (nil (:foo (:bar (:quux)) :list)) (:symbol (:foo (:bar :foo (:quux)))) (error (:foo (:bar :foo (:quux) :foo))) (:singleton (:foo (:bar (:foo) (:quux)))) ((nil) (:foo (:bar (:foo nil) (:quux)))) ((foo) (:foo (:bar (:foo foo) (:quux)))) ((foo bar baz) (:foo (:bar (:foo foo bar baz) (:quux)))) ((:foo) (:foo (:bar :foo (:quux)) :list)) ((:foo :foo) (:foo (:bar :foo (:quux) :foo) :list)) (((:foo) :foo (:foo foo)) (:foo (:bar (:foo) (:quux) :foo (:foo foo)) :list)))) :success) (defun test/all () (test/get-option) (test/hash-table-projection)) (mapcar (lambda (expected-arguments) (destructuring-bind (expected arguments) expected-arguments (handler-case (let ((results (multiple-value-list (apply (function parse-structure-name-and-options) arguments)))) results #-(and) (if (equal expected results) results (error "For ~S, expected ~S, got ~S" (cons 'parse-structure-name-and-options arguments) expected results))) (error (err) (if (eql expected 'error) err (error "For ~S, expected ~S, got ~S" (cons 'parse-structure-name-and-options arguments) expected err)))))) '( (() (point)) )) (assert (equalp (mapcar (lambda (arguments) (print (mapcan (function list) '(:name :conc-name :constructors :copier :include :initial-offset :predicate :print-function :print-object :structure-type-p :structure-type) (multiple-value-list (apply (function parse-structure-name-and-options) arguments))))) '((point) ((point)) ((point :conc-name)) ((point (:conc-name))) ((point (:conc-name nil))) ((point (:conc-name pt-))) ((point :copier)) ((point (:copier))) ((point (:copier nil))) ((point (:copier copy-pt))) ((point :conc-name :copier)) ((point (:conc-name) (:copier))) ((point (:conc-name nil) (:copier nil))) ((point (:conc-name pt-) (:copy copy-pt))) ((point :constructor)) ((point (:constructor))) ((point (:constructor nil))) ((point (:constructor %make-pt))) ((point :constructor (:constructor %make-pt) (:constructor %make-a-pt (x y)))) ((point (:print-function))) ((point (:print-function nil))) ((point (:print-function print-pt))) ((point :print-object)) ((point (:print-object))) ((point (:print-object nil))) ((point (:print-object print-pt))) )) '((:name point :conc-name point- :constructors (make-point) :copier copy-point :include nil :initial-offset nil :predicate point-p :print-function nil :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name point- :constructors (make-point) :copier copy-point :include nil :initial-offset nil :predicate point-p :print-function nil :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name || :constructors (make-point) :copier copy-point :include nil :initial-offset nil :predicate point-p :print-function nil :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name || :constructors (make-point) :copier copy-point :include nil :initial-offset nil :predicate point-p :print-function nil :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name || :constructors (make-point) :copier copy-point :include nil :initial-offset nil :predicate point-p :print-function nil :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name pt- :constructors (make-point) :copier copy-point :include nil :initial-offset nil :predicate point-p :print-function nil :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name point- :constructors (make-point) :copier copy-point :include nil :initial-offset nil :predicate point-p :print-function nil :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name point- :constructors (make-point) :copier copy-point :include nil :initial-offset nil :predicate point-p :print-function nil :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name point- :constructors (make-point) :copier nil :include nil :initial-offset nil :predicate point-p :print-function nil :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name point- :constructors (make-point) :copier copy-pt :include nil :initial-offset nil :predicate point-p :print-function nil :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name || :constructors (make-point) :copier copy-point :include nil :initial-offset nil :predicate point-p :print-function nil :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name || :constructors (make-point) :copier copy-point :include nil :initial-offset nil :predicate point-p :print-function nil :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name || :constructors (make-point) :copier nil :include nil :initial-offset nil :predicate point-p :print-function nil :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name pt- :constructors (make-point) :copier copy-point :include nil :initial-offset nil :predicate point-p :print-function nil :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name point- :constructors (make-point) :copier copy-point :include nil :initial-offset nil :predicate point-p :print-function nil :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name point- :constructors (make-point) :copier copy-point :include nil :initial-offset nil :predicate point-p :print-function nil :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name point- :constructors nil :copier copy-point :include nil :initial-offset nil :predicate point-p :print-function nil :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name point- :constructors (%make-pt) :copier copy-point :include nil :initial-offset nil :predicate point-p :print-function nil :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name point- :constructors (make-point %make-pt (%make-a-pt (x y))) :copier copy-point :include nil :initial-offset nil :predicate point-p :print-function nil :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name point- :constructors (make-point) :copier copy-point :include nil :initial-offset nil :predicate point-p :print-function nil :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name point- :constructors (make-point) :copier copy-point :include nil :initial-offset nil :predicate point-p :print-function nil :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name point- :constructors (make-point) :copier copy-point :include nil :initial-offset nil :predicate point-p :print-function print-pt :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name point- :constructors (make-point) :copier copy-point :include nil :initial-offset nil :predicate point-p :print-function nil :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name point- :constructors (make-point) :copier copy-point :include nil :initial-offset nil :predicate point-p :print-function nil :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name point- :constructors (make-point) :copier copy-point :include nil :initial-offset nil :predicate point-p :print-function nil :print-object nil :structure-type-p nil :structure-type nil) (:name point :conc-name point- :constructors (make-point) :copier copy-point :include nil :initial-offset nil :predicate point-p :print-function nil :print-object print-pt :structure-type-p nil :structure-type nil)))) #-(and) (progn (pprint (macroexpand-1 '(define-structure-class point x y))) (pprint (macroexpand-1 '(define-structure-class (point :conc-name) x y))) (pprint (macroexpand-1 '(define-structure-class (point (:conc-name)) x y))) (pprint (macroexpand-1 '(define-structure-class (point (:conc-name nil)) x y))) (pprint (macroexpand-1 '(define-structure-class (point (:conc-name pt-)) x y))) (pprint (macroexpand-1 '(define-structure-class (point :predicate) x y))) (pprint (macroexpand-1 '(define-structure-class (point (:predicate)) x y))) (pprint (macroexpand-1 '(define-structure-class (point (:predicate nil)) x y))) (pprint (macroexpand-1 '(define-structure-class (point (:predicate ptp)) x y))) )
12,929
Common Lisp
.lisp
173
64.710983
241
0.628542
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
1099d2e4cbb52bc02ffdb69feb5849cb03e268c956ac2458b72c780823aec206
5,082
[ -1 ]
5,083
package.lisp
informatimago_lisp/common-lisp/cesarum/package.lisp
;;;; -*- coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: package.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: None ;;;;DESCRIPTION ;;;; ;;;; ;;;; Note: the DEFINE-PACKAGE macro is obsolete. Instead, ;;;; use a CL-USER::ALSO-USE-PACKAGES declaration and a normal DEFPACKAGE form. ;;;; For example: ;;;; ;;;; (in-package "COMMON-LISP-USER") ;;;; (declaim (declaration also-use-packages)) ;;;; (declaim (also-use-packages "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.ISO3166")) ;;;; (defpackage "COM.INFORMATIMAGO.EXAMPLE" ;;;; (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.LIST") ;;;; (:export "EXAMPLE")) ;;;; (in-package "COM.INFORMATIMAGO.EXAMPLE") ;;;; ... (com.informatimago.common-lisp.cesarum.iso3166:get-country 4) ;;;; ;;;; This declaration is used by make-depends to build the ASD files, ;;;; and generate other stuff. It's better to split declaims, IIRC some ;;;; implementation like it better like this. ;;;; ;;;; ;;;; Obsolete: ;;;; ;;;; Exports a DEFINE-PACKAGE macro and LOAD-PACKAGE function ;;;; (amongst others) that map packages names (styled as: ;;;; COM.INFORMATIMAGO.COMMON-LISP.CESARUM.PACKAGE to logical pathnames in ;;;; the "PACKAGES" virtual host: ;;;; ;;;; "PACKAGES:COM;INFORMATIMAGO;COMMON-LISP;PACKAGE.LISP" ;;;; ;;;; The object files are mapped to: ;;;; ;;;; "PACKAGES:COM;INFORMATIMAGO;COMMON-LISP;~ ;;;; OBJ-${IMPL_TYPE}-${IMPL_VERS}-${MACH_TYPE} ;PACKAGE.${OBJECT-TYPE}" ;;;; ;;;; Improvements over DEFPACKAGE include: ;;;; ;;;; - allow to specify packages refered to (used) while not ;;;; importing ("inheriting") any of it symbols; (:USE package) ;;;; ;;;; - allow to do it while renaming (nicknaming) the package; ;;;; (:USE package :AS nickname) ;;;; ;;;; - allow to specify that all symbols exported by a given package ;;;; are to be imported. (:FROM package :IMPORT :ALL) ;;;; ;;;; The first and second points help declare package dependencies without ;;;; using the deprecated REQUIRE, PROVIDE and *MODULES*. This is done ;;;; by implementing a systematic way to load packages (from a PACKAGE: ;;;; logical host with logical pathname translations). ;;;; This allows MAKE-DEPENDS to build automatically the dependency graph, ;;;; and LOAD-PACKAGE to load automatically the dependencies without ;;;; the need to write an ASDF or DEFSYSTEM file. ;;;; ;;;; The last point, along with the (:FROM package :IMPORT symbol...) form ;;;; correct the naming of the :USE clause of DEFPACKAGE. ;;;; ;;;; Other more obscure clauses of DEFPACKAGE (:SHADOW, ;;;; :SHADOWING-IMPORT-FROM, :INTERN) have no equivalent ;;;; to provide a more controled package management. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2011-12-27 <PJB> Added double-RENAME-PACKAGE to ADD-NICKNAME. ;;;; 2005-03-17 <PJB> Added LIST-ALL-SYMBOLS LIST-EXTERNAL-SYMBOLS ;;;; COPY-PACKAGE ;;;; 2005-01-13 <PJB> Renamed *VERBOSE* to *PACKAGE-VERBOSE*. ;;;; Note: LOAD-PACKAGE uses *LOAD-VERBOSE*. ;;;; 2004-12-19 <PJB> LOAD-PACKAGE won't load a package found by FIND-PACKAGE. ;;;; 2003-05-06 <PJB> Created. ;;;;BUGS ;;;; Nicknames assigned with (:USE package :AS nickname) are created in ;;;; the global package name space. They ought to be created in a ;;;; package name space local to the package being defined... ;;;; ;;;; We should probably implement a hierarchical package system like Franz's. ;;;; ;;;; ADD-NICKNAME: RENAME-PACKAGE cannot not change the name, (undefined consequences) ;;;; so we'd have to go thru a temporary name. ;;;; ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2003 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.PACKAGE" (:documentation " Some package utilities. License: AGPL3 Copyright Pascal J. Bourguignon 2003 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ") (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY") #+mocl (:shadowing-import-from "COM.INFORMATIMAGO.MOCL.KLUDGES.MISSING" "*TRACE-OUTPUT*" "*LOAD-VERBOSE*" "*LOAD-PRINT*" "ARRAY-DISPLACEMENT" "CHANGE-CLASS" "COMPILE" "COMPLEX" "ENSURE-DIRECTORIES-EXIST" "FILE-WRITE-DATE" "INVOKE-DEBUGGER" "*DEBUGGER-HOOK*" "LOAD" "LOGICAL-PATHNAME-TRANSLATIONS" "MACHINE-INSTANCE" "MACHINE-VERSION" "NSET-DIFFERENCE" "RENAME-FILE" "SUBSTITUTE-IF" "TRANSLATE-LOGICAL-PATHNAME") (:export "PACKAGE-EXPORTS" ;; missing from CL or not? "*PACKAGES*" "PACKAGE-PATHNAME" "LOAD-PACKAGE" "PACKAGE-SYSTEM-DEFINITION" "ADD-TRANSLATIONS" "ADD-NICKNAME" "*PACKAGE-VERBOSE*" ;; utility: "COPY-PACKAGE" "LIST-SYMBOLS" "LIST-ALL-SYMBOLS" "LIST-EXTERNAL-SYMBOLS" "SEXP-FOR-PACKAGE" "STRING-PREPARE-TOKEN" "UNINTERNED-PREPARE-TOKEN" "KEYWORD-PREPARE-TOKEN" ;; debugging help: "CRACK-OPEN-PACKAGE" "DELETE-PACKAGES")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.PACKAGE") (defun all-users (package-designator) (transitive-closure (lambda (package-designator) (package-used-by-list package-designator)) (list (find-package package-designator)))) (defun delete-packages (root-package) "Delete the package designated by the package designator ROOT-PACKAGE, and all the packages that depend on it (but CL-USER)." (let ((packages (topological-sort (all-users root-package) (lambda (p q) (not (member (find-package q) (all-users p))))))) (let ((cl-user (find-package "COMMON-LISP-USER"))) (when (or (member (find-package "COMMON-LISP") packages) (member (find-package "KEYWORD") packages)) (error "COMMON-LISP or KEYWORD should not use ~A or a package that uses ~:*~A" (package-name root-package))) (if (member cl-user packages) (let ((packages (remove cl-user packages))) (loop :for package :in packages :do (ignore-errors (unuse-package package cl-user))) (prog1 (mapcar (function package-name) packages) (map nil 'delete-package packages))) (prog1 (mapcar (function package-name) packages) (map nil 'delete-package packages)))))) (defun list-symbols (package &key (sorted t) (homely nil) (exported nil) (shadowing nil) (all nil)) " PACKAGE: A package designator. SORTED: (boolean) Whether the resulting list is sorted on symbol-names. HOMELY: (boolean) selects the symbols whose home package is PACKAGE. EXPORTED: (boolean) selects the exported symbols. SHADOWING: (boolean) selects the symbols on the shadowing list. ALL: (boolean) selects all the symbols interned in the PACKAGE. RETURN: A list of the selected symbols. By default, only the HOMELY symbols. " (setf homely (or homely (not (or exported shadowing all)))) (let ((pack (find-package package))) (if pack (let ((sl '())) (when exported (do-external-symbols (s pack) (push s sl))) (do-symbols (s pack) (when (or all (and homely (eq pack (symbol-package s))) (and shadowing (member s (package-shadowing-symbols pack)))) (pushnew s sl))) (if sorted (sort sl (function string<)) sl)) (error "No package ~S" package)))) (defun list-all-symbols (package &key (sorted t)) " RETURN: A list of all the symbols present in the PACKAGE. PACKAGE: A package designator. SORTED: Whether the result list is sorted (default T). " (list-symbols package :sorted sorted :all t)) (defun list-external-symbols (package &key (sorted t)) " RETURN: A list of all the symbols exported from the PACKAGE. PACKAGE: A package designator. SORTED: Whether the result list is sorted (default T). " (list-symbols package :sorted sorted :exported t)) (defun copy-package (old-package new-name) " RETURN: A new package that exports all the external symbols of the OLD-PACKAGE. OLD-PACKAGE: A package designator. NEW-NAME: A package name (string designator) " (let ((new-package (make-package new-name)) (symbols (list-external-symbols old-package :sorted nil))) (import symbols new-package) (export symbols new-package) new-package)) (defun crack-open-package (package) " NOTE: USE-PACKAGE only imports exported symbols. This function imports into the current package all the symbols present in the PACKAGE. " (do-symbols (sym package) (shadowing-import sym)) ) ;;---------------------------------------------------------------------- (defvar *package-verbose* nil "Whether some package operation defined in this package shall issue some verbosity. SEE ALSO: REGISTER, LOAD-PACKAGE, ADD-NICKNAME. ") (defparameter *vout* t "Verbose output stream.") (defmacro verbose (fctrl &rest args) `(when *package-verbose* (format *vout* ,fctrl ,@args))) (defun package-exports (package) " RETURN: A new list of exported symbols from PACKAGE. " (let ((result nil)) (do-external-symbols (sym package result) (push sym result)))) (defun package-pathname (package) " RETURN: The logical pathname to the given package. NOTE: If a nickname is given, then a nickname pathname is returned. " (cond ((simple-string-p package) (#+(or allegro ccl) (lambda (designator) ;; Allegro logical pathnames must be written in lowcase ;; to produce lowcase physical pathnames. ;; TODO: Copy the files to an implementation specific LFS. (if (stringp designator) (let ((colon (position #\: designator))) (format nil "~:@(~A~)~(~A~)" (subseq designator 0 colon) (subseq designator colon))) designator)) #-(or allegro ccl) identity (concatenate 'string "PACKAGES:" (substitute (character ";") (character ".") package) ".LISP"))) ((stringp package) (package-pathname (copy-seq package))) ((symbolp package) (package-pathname (string package))) ((packagep package) (package-pathname (package-name package))) (t (error "~S is not a package designator." package)))) (defun package-system-definition (system) " This is a system definition search function for ASDF. It will map a system such as :com.informatimago.common-lisp to the package path: PACKAGE:COM;INFORMATIMAGO;COMMON-LISP;SYSTEM.ASD " ;; (print `(package-system-definition ,system)) ;; (values-list (print (multiple-value-list))) (let ((name (typecase system (symbol (string-downcase (symbol-name system))) (string system) (t nil)))) (when (and name (position (character ".") name)) ;; otherwise process with the normal functions (let ((file (make-pathname :type "asd" ;; :case :common ;; strange stuff in allegro... :defaults (package-pathname (concatenate 'string name ".system"))))) (values (when (probe-file file) file) file))))) (defvar *built-in-package-names* '("COMMON-LISP" "CL" "COMMON-LISP-USER" "CL-USER" "KEYWORD")) (defun built-in-p (package) #-(and) (unless *built-in-package-names* (setf *built-in-package-names* (mapcan (lambda (pname) (let ((pack (find-package pname))) (when pack (cons (package-name pack) (copy-list (package-nicknames pack)))))) '("COMMON-LISP" "COMMON-LISP-USER" "KEYWORD")))) (member (etypecase package (string package) (package (package-name package))) *built-in-package-names* :test (function string=))) (defvar *packages* nil " We cannot use COMMON-LISP:*MODULES* since it's deprecated, so here is our own. This is an a-list (file-pathname . (package-name)). Note: the main data item is the file-pathname; the package-name is kept as a human readable item; caveat: packages can be renamed! ") (defun close-path (package) " RETURN: Closure of the translation of the package pathname of PACKAGE. " (do* ((path (package-pathname package) next) (next (translate-logical-pathname path) (translate-logical-pathname path)) (count 0 (1+ count))) ((string= (namestring path) (namestring next)) path) (when (< 100 count) (error "Cannot close the logical path for package ~S in less ~ than 100 steps: probably a loop!~%" package)))) (declaim (inline registeredp)) (defun registeredp (package) " RETURN: Whether the PACKAGE is already registered. " (let ((path (namestring (close-path package)))) (member path *packages* :key (function car) :test (function string=)))) (defun register (package) " DO: Force registering the PACKAGE into the loaded *PACKAGES*. " (let ((path (namestring (close-path package)))) (verbose "~&# PACKAGE:REGISTER PACKAGE = ~S~%~ ~&# PATH = ~S~%~:[~ ~&# IS NEW!~%~;~]" package path (registeredp package)) (pushnew (list path (if (stringp package) package (package-name package))) *packages* :key (function car) :test (function string=)))) (defun implementation-id () (flet ((first-word (text) (let ((pos (position (character " ") text))) (remove (character ".") (if pos (subseq text 0 pos) text))))) (format nil "~A-~A-~A" (first-word (lisp-implementation-type)) (first-word (lisp-implementation-version)) (first-word (machine-type))))) (defun implementation-object-type () (pathname-type (compile-file-pathname (merge-pathnames "TEST.LSP" (user-homedir-pathname))))) #|| (handler-case (let ((source (merge-pathnames "TEST.LSP" (user-homedir-pathname)))) (unwind-protect (progn (with-open-file (out source :direction :output :if-does-not-exist :create :if-exists :error) (print '(defun test (&rest args) args) out)) (let ((object (compile-file source :verbose nil :print nil))) (delete-file object) (pathname-type object))) (delete-file source))) (error () (error "What's the file type for a compiled file?")))) ||# (defun object-dir (path) (merge-pathnames (make-pathname :directory (list :relative (format nil "OBJ-~:@(~A~)" (implementation-id))) :type (implementation-object-type) :defaults path) path)) (defun load-package (package-name &key (verbose *load-verbose*) (print *load-print*) (if-does-not-exist :error) (external-format :default)) " DO: Unless it's already loaded (listed in *PACKAGES* or found by FIND-PACKAGE), loads the package named PACKAGE-NAME. NOTE: We both use REGISTER in DEFINE-PACKAGE and in PACKAGE::LOAD because we may be loading a nickname. RETURN: The package named PACKAGE-NAME if found, or NIL. " (or (find-package package-name) (let ((path (close-path (string package-name)))) (verbose "~&# LOADING PACKAGE NAME ~S FROM ~S~%~:[~ ~&# NEW PACKAGE.~% ~&# PACKAGE ALREADY KNOWN.~%~;~]" package-name path (registeredp package-name)) (unless (registeredp package-name) (prog1 (or (#+mocl COM.INFORMATIMAGO.MOCL.KLUDGES.MISSING:load #-mocl common-lisp:load (object-dir path) :verbose verbose :print print :if-does-not-exist nil :external-format external-format) (#+mocl COM.INFORMATIMAGO.MOCL.KLUDGES.MISSING:load #-mocl common-lisp:load path :verbose verbose :print print :if-does-not-exist if-does-not-exist :external-format external-format)) (register package-name) (verbose "~&# LOAD-PACKAGE ~S DONE~%~ ~&# *PACKAGES*= ~S~%" package-name *packages*)))))) (defun add-translations (&rest translations) " DO: Prepend the TRANSLATIONS to the list of logical pathname translations of the PACKAGES: logical host. These translations may concern either the long names of package: the package COM.INFORMATIMAGO.COMMON-LIST.CESARUM.UTILITY is loaded from PACKAGES:COM;INFORMATIMAGO;COMMON-LISP;CESARUM;UTILITY which could be translated to: /usr/share/lisp/packages/com/informatimago/common-lisp/cesarum/utility.lisp or abstract, short nicknames: the package nicknamed DICTIONARY would be loaded from PACKAGES:DICTIONARY which could be translated to: PACKAGES:COM;INFORMATIMAGO;COMMON-LISP;HASH-DICT or to: PACKAGES:COM;INFORMATIMAGO;COMMON-LISP;BIN-TREE-DICT " (setf (logical-pathname-translations "PACKAGES") (nconc (mapcar (lambda (item) (list ;; TODO: This is most certainly not portable; check it: (merge-pathnames (first item) (make-pathname :host "PACKAGES") nil) (second item))) translations) (handler-case (logical-pathname-translations "PACKAGES") (error nil))))) ;; (DEFINE-PACKAGE COM.INFORMATIMAGO.COMMON-LISP.MAKE-DEPENDS.MAKE-DEPENDS ;; (:NICKNAMES NAME1 NAM2) ; use (:USE pack :AS nick) in client rather! ;; (:DOCUMENTATION "BLAH BLAH") ;; (:FROM COM.INFORMATIMAGO.COMMON-LISP.CESARUM.LIST :IMPORT :ALL) ;; (:FROM COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STRING :IMPORT SYM1 SYM2 SYM3) ;; (:USE COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY :AS UTIL) ;; (:USE COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DICTIONARY) ;; (:EXPORT EXP1 EXP2 EXP3)) ;; ;; ;; package should be the long name package, that may be converted to a ;; package logical pathname. ;; ;; But users may want to use a nickname, to allow for late (compilation) ;; time selection of the exact package to be used. ;; ;; So, given a package, either we can find it in the PACKAGES: logical ;; volume, or we can find it under this nickname and we load it under its ;; long name. ;; ;; We can find it under this nickname only if it's already loaded, so for ;; compilation file by file, we may need additional directive to make the ;; correspondance: ;; ;; (DEFNICKNAME nickname longname) ;; --> load longname and rename to nickname (in case it had not already ;; that nickname) ;; ;; longnames are converted to package paths as follow: ;; ;; - the dots in the long name are replaced by semicolons; ;; - a type of "LISP" is appended; ;; - the "PACKAGE:" logical host name is prefixed. ;; ;; for all packages in :FROM and in :USE, do ;; find and load the package. ;; (we must load it for the macro it may contain) ;; if the package is :USE :AS, then rename it. ;; done ;; :NICNAMES --> DEFPACKAGE :NICNAMES ;; :DOCUMENTATION --> DEFPACKAGE :DOCUMENTATION ;; :FROM package :IMPORT :ALL --> DEFPACKAGE :USE package ;; :FROM package :IMPORT symbol... --> DEFPACKAGE :IMPORT-FROM package sym... ;; :USE package :AS nickname --> LOAD "PACKAGES:package" / rename ;; :USE package --> LOAD "PACKAGES:package" ;; :EXPORT symbol... --> DEFPACKAGE :EXPORT symbol... ;; --> IN-PACKAGE package (defun stringify (items) " ITEMS: A list of symbol, keyword or string. RETURN: A new list of strings, the symbol-names or the strings given in ITEMS. " (do* ((items items (cdr items)) (item (car items) (car items)) (result nil)) ((null items) result) (cond ((stringp item) (push item result)) ((symbolp item) (push (symbol-name item) result)) (t (error "~S is not a symbol, keyword or string!~%" item))))) (defun parse-package-declarations (declarations) " DO: Parses and check somewhat the syntax of DECLARATIONS. RETURN: a list of dependencies (package names); a list of renames (package . nickname); arguments for DEFPACKAGE. " (do* ((declarations declarations (cdr declarations)) (decl (car declarations) (car declarations)) (dependencies nil) (renames nil) (nicknames nil) (uses nil) (result nil)) ((null declarations) (progn (when uses (push (cons :use uses) result)) (when nicknames (push (cons :nicknames nicknames) result)) (values dependencies renames result))) (case (car decl) (:nicknames (setq nicknames (nconc (stringify (cdr decl)) nicknames))) (:documentation (push decl result)) (:shadow (push (cons :shadow (stringify (cdr decl))) result)) (:size (push decl result)) (:from (let* ((from-pkg-name (string (nth 1 decl)))) (push from-pkg-name dependencies) (unless (eq :import (nth 2 decl)) (error "Missing :IMPORT after :FROM ~S.~%" from-pkg-name)) (if (eq :all (nth 3 decl)) (if (< 4 (length decl)) (error "Unexpected ~S after :ALL." (nth 4 decl)) (push from-pkg-name uses)) (push (cons :import-from (cons from-pkg-name (stringify (cdddr decl)))) result)) )) (:use (let* ((from-pkg-name (string (nth 1 decl)))) (push from-pkg-name dependencies) (when (< 2 (length decl)) (unless (eq :as (nth 2 decl)) (error "Expected :AS in :USE clause, not ~S." (nth 2 decl))) (unless (= 4 (length decl)) (error "Unexpected ~S after :AS ~A." (nth 4 decl) (nth 3 decl))) (push (cons from-pkg-name (string (nth 3 decl))) renames)) )) (:export (push (cons :export (stringify (cdr decl))) result)) (otherwise (error "Unexpected clause ~S." decl))))) (defun remove-nickname (package nickname) " DO: Remove the NICKNAME from the list of nicknames of the package designated by PACKAGE. RETURN: The package designated by PACKAGE. " (let ((package (find-package package))) (rename-package package (package-name package) (remove nickname (package-nicknames package) :test (function string=))))) (defun gen-old-name (packname) (let* ((dash (position #\- packname :from-end t)) (packname (if (and (< 4 (length packname)) (string= "OLD-" packname :end2 4) (every (function digit-char-p) (subseq packname (1+ dash)))) (subseq packname 4 (position #\- packname :from-end t)) packname))) (loop :for i :from 0 :for name = (format nil "OLD-~A-~D" packname i) :while (find-package name) :finally (return name)))) (defun add-nickname (package nickname &key steal force) " DO: Add the NICKNAME to the PACKAGE. STEAL: If another package has already this nickname, then steal it. FORCE: If another package has this nickname as package name, then steal it. RETURN: The package designated by PACKAGE. " (verbose "~&# ADDING TO PACKAGE ~S~%~ ~&# THE NICKNAME ~S~%" package nickname) (let* ((pack (find-package package)) (packname (if pack (package-name pack) (error "~S: There is no package named \"~A\"." 'add-nickname package))) (nickpack (find-package nickname)) (cnt 0)) (flet ((temp-name () (loop :for name = (format nil "TEMP-~A-~A" packname (incf cnt)) :while (find-package name) :finally (return name)))) (cond ((eq nickpack pack) (verbose "~&# ALREADY GOT IT~%")) ((null nickpack) ;; The consequences are undefined if new-name or any ;; new-nickname conflicts with any existing package names. ;; Therefore we use a temp name. (let ((temp (temp-name)) (nicks (cons nickname (copy-seq (package-nicknames pack))))) (rename-package pack temp nicks) (rename-package pack packname nicks)) (when (built-in-p packname) (pushnew nickname *built-in-package-names* :test (function string=)))) ((and force (string= nickname (package-name nickpack))) (let ((nicks (or (package-nicknames nickpack) (list (gen-old-name nickname))))) (rename-package nickpack (first nicks) (rest nicks)) (add-nickname pack nickname))) ((and (or steal force) (string/= nickname (package-name nickpack))) (remove-nickname nickpack nickname) (add-nickname pack nickname)) (force (error "~S is already a nickname of the package ~S" nickname nickpack)) (t (error "~S is the name of an existing package." nickname))) pack))) (defun insert-sharp (string) (declare (string string)) (do ((result '()) (start 0) (end 0)) ((>= end (length string)) (progn (when (<= start end) (push (subseq string start end) result)) (apply (function concatenate) 'string (if (cdr result) "# " "") (nreverse result)))) (when (prog1 (char= #\NEWLINE (char string end)) (incf end)) (push (subseq string start end) result) (setq start end) (push "# " result)))) (defmacro define-package (name &rest declarations) " DO: Declares a package. This includes loading the packages depended on, adding nicknames to the packages used under these nicknames, defining the package, and going into it (with IN-PACKAGE). " (setq name (string name)) (multiple-value-bind (dependencies renames defpack-args) (parse-package-declarations declarations) (setq name (string name)) (verbose "~3%# DECLARING PACKAGE ~S~%~ ~&# -----DEFPACK-ARGS ~A~%~ ~&# -----RENAMES ~A~%~ ~&# -----DEPENDENCIES ~A~%" name (insert-sharp (format nil "~S" defpack-args)) (insert-sharp (format nil "~S" renames)) (insert-sharp (format nil "~S" dependencies))) `(eval-when (:compile-toplevel :load-toplevel :execute) (register ,name) ,@(unless (null dependencies) `((dolist (pack ',dependencies) (unless (built-in-p pack) (load-package pack))))) ,@(unless (null renames) `((dolist (rename ',renames) (add-nickname (car rename) (cdr rename))))) ;; If we try to delete it while it's used, ;; we get interned uninterned symbols... ;; (ignore-errors (delete-package ,name)) (defpackage ,name ,@defpack-args) (in-package ,name)))) (defun string-prepare-token (kind name) (declare (ignore kind)) (string name)) (defun uninterned-prepare-token (kind name) (declare (ignore kind)) (make-symbol (string name))) (defun keyword-prepare-token (kind name) (declare (ignore kind)) (intern (string name) (load-time-value (find-package "KEYWORD")))) (defun sexp-for-package (package-designator &optional (prepare-token (function string-prepare-token))) " RETURN: A defpackage form corresponding to the package given by PACKAGE-DESIGNATOR. PREPARE-TOKEN: A function taking a kind (member :package :symbol) and a package name or symbol, and returning a string designator corresponding to that name. The functions STRING-PREPARE-TOKEN, UNINTERNED-PREPARE-TOKEN or KEYWORD-PREPARE-TOKEN may be used, or other custom functions if different kind of string designators are required for package names than for symbol names. " (let ((package (find-package package-designator))) (assert package) (let* ((used-packages (package-use-list package)) (used-symbols (mapcan (function com.informatimago.common-lisp.cesarum.package:package-exports) used-packages)) (shadows '()) (shadowing-imports (make-hash-table)) (exports (com.informatimago.common-lisp.cesarum.package:package-exports package)) (shadowed-symbols (package-shadowing-symbols package)) (imports (make-hash-table))) (do-symbols (sym package) (unless (member sym exports) (let ((home (symbol-package sym))) (unless (or (eq home package) (member sym shadowed-symbols) (member sym used-symbols) (member home used-packages)) (push sym (gethash home imports '())))))) (dolist (sym shadowed-symbols) (let ((home (symbol-package sym))) (if (eq home package) (push sym shadows) (push sym (gethash home shadowing-imports '()))))) (flet ((pname (x) (funcall prepare-token :package x)) (sname (x) (funcall prepare-token :symbol x))) `(defpackage ,(pname (package-name package)) ,@(when (package-nicknames package) `((:nicknames ,@(mapcar (function pname) (package-nicknames package))))) (:use ,@(mapcar (lambda (p) (pname (package-name p))) used-packages)) ,@(when shadows `((:shadow ,@(mapcar (function sname) shadows)))) ,@(when exports `((:export ,@(mapcar (function sname) exports)))) ,@(when (plusp (hash-table-count shadowing-imports)) (let ((forms '())) (maphash (lambda (pack syms) (push `(:shadowing-import-from ,(pname (package-name pack)) ,@(mapcar (function sname) syms)) forms)) shadowing-imports) forms)) ,@(when (plusp (hash-table-count imports)) (let ((forms '())) (maphash (lambda (pack syms) (push `(:import-from ,(pname (package-name pack)) ,@(mapcar (function sname) syms)) forms)) imports) forms))))))) ;;;; THE END ;;;;
34,316
Common Lisp
.lisp
760
36.243421
110
0.584255
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
1bc9e2a0fca85b1d263a4806595b1847edbad46d25ee3c7e5568d44798fa78f4
5,083
[ -1 ]
5,084
raiden.lisp
informatimago_lisp/common-lisp/cesarum/raiden.lisp
;;;; -*- coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: raiden.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Implements the Raiden block cipher. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2006-10-20 <PJB> Created. ;;;; 2024-01-38 <PJB> Tuned type declarations for sbcl. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2006 - 2024 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.RAIDEN" (:use "COMMON-LISP") (:export "RAIDEN-DECIPHER" "RAIDEN-ENCIPHER") (:documentation " This package imlements the RAIDEN block cipher. http://raiden-cipher.sourceforge.net/ License: AGPL3 Copyright Pascal J. Bourguignon 2006 - 2024 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.RAIDEN") ;; void raiden(unsigned long *data,unsigned long *result,unsigned long ;; *key) ;; { ;; ;; unsigned long b0=data[0], ;; b1=data[1],i,k[4]={key[0],key[1],key[2],key[3]}, sk; ;; for(i=0; i< 16; i++) ;; { ;; sk=k[i%4]=((k[0]+k[1])+((k[2]+k[3])^(k[0]<<k[2]))); ;; b0 +=((sk+b1)<<9)^((sk-b1)^((sk+b1)>>14)); ;; b1 +=((sk+b0)<<9)^((sk-b0)^((sk+b0)>>14)); ;; } ;; result[0]=b0; ;; result[1]=b1; ;; } (defun raiden-encipher (v w k) " V: (vector (unsigned-byte 32) 2), the clear text W: (vector (unsigned-byte 32) 2), the result encrypted text K: (vector (unsigned-byte 32) 4), the key " (declare (type (vector (unsigned-byte 32) 2) v) (type (vector (unsigned-byte 32) 2) w) (type (vector (unsigned-byte 32) 4) k)) (macrolet ((ref (vector index) `(the (unsigned-byte 32) (aref ,vector ,index)))) (flet ((32bit (x) (logand #xffffffff x))) #-(or abcl eclxxx) (declare (inline 32bit)) (loop :with b0 :of-type (unsigned-byte 32) = (ref v 0) :with b1 :of-type (unsigned-byte 32) = (ref v 1) :with k :of-type (vector (unsigned-byte 32) 4) = (copy-seq k) :for i :of-type fixnum :from 0 :below 16 :for sk :of-type (unsigned-byte 32) = (32bit (+ (ref k 0) (ref k 1) (logxor (+ (ref k 2) (ref k 3)) (32bit (ash (ref k 0) (mod (ref k 2) 32)))))) :do (setf (ref k (mod i 4)) sk b0 (32bit (+ b0 (logxor (32bit (ash (+ sk b1) 9)) (32bit (- sk b1)) (32bit (ash (+ sk b1) -14))))) b1 (32bit (+ b1 (logxor (32bit (ash (+ sk b0) 9)) (32bit (- sk b0)) (32bit (ash (+ sk b0) -14)))))) :finally (setf (ref w 0) b0 (ref w 1) b1))))) ;; void decode_raiden(unsigned long *data,unsigned long *result,unsigned ;; long *key) ;; { ;; ;; unsigned long b0=data[0], ;; b1=data[1],i,k[4]={key[0],key[1],key[2],key[3]}, ;; subkeys[16]; ;; for(i=0;i< 16;i++){ ;; //Subkeys are calculated ;; k[i%4]=((k[0]+k[1])+((k[2]+k[3])^(k[0]<<k[2]))); ;; subkeys[i]=k[i%4]; ;; } ;; for(i=15; i!=-1; i--) ;; { ;; //Process is applied in the inverse order ;; b1 -= ((subkeys[i]+b0)<<9)^((subkeys[i]-b0)^ ;; ((subkeys[i]+b0)>>14)); ;; b0 -= ((subkeys[i]+b1)<<9)^((subkeys[i]-b1)^ ;; ((subkeys[i]+b1)>>14)); ;; } ;; result[0]=b0; ;; result[1]=b1; ;; } (defun raiden-decipher (v w k) " V: (vector (unsigned-byte 32) 2), the clear text W: (vector (unsigned-byte 32) 2), the result encrypted text K: (vector (unsigned-byte 32) 4), the key " #-eclxxx (declare (type (vector (unsigned-byte 32) 2) v) (type (vector (unsigned-byte 32) 2) w) (type (vector (unsigned-byte 32) 4) k)) (flet ((32bit (x) (logand #xffffffff x))) #-(or abcl eclxxx) (declare (inline 32bit)) (loop :with b0 :of-type (unsigned-byte 32) = (aref v 0) :with b1 :of-type (unsigned-byte 32) = (aref v 1) :with k :of-type (vector (unsigned-byte 32) 4) = (copy-seq k) :with sks :of-type (vector (unsigned-byte 32) 32) = (make-array 32 :element-type '(unsigned-byte 32) :initial-element 0) :for i #-eclxxx :of-type #-eclxxx fixnum :from 0 :below 16 :for newval #-eclxxx :of-type #-eclxxx (unsigned-byte 32) = (32bit (+ (aref k 0) (aref k 1) (logxor (+ (aref k 2) (aref k 3)) (32bit (ash (aref k 0) (mod (aref k 2) 32)))))) :do (setf (aref k (mod i 4)) newval (aref sks i) newval) :finally (loop :for i :of-type fixnum :from 15 :downto 0 :for sk :of-type (unsigned-byte 32) = (aref sks i) :do (setf b1 (32bit (- b1 (logxor (32bit (ash (+ sk b0) 9)) (32bit (- sk b0)) (32bit (ash (+ sk b0) -14))))) b0 (32bit (- b0 (logxor (32bit (ash (+ sk b1) 9)) (32bit (- sk b1)) (32bit (ash (+ sk b1) -14)))))) :finally (setf (aref w 0) b0 (aref w 1) b1))))) (defun word (a b c d) (dpb a (byte 8 24) (dpb b (byte 8 16) (dpb c (byte 8 8) d)))) (defun read-words (bits what) (loop :for bytes = (progn (format t "Please enter ~D bits of ~A: " bits what) (let ((buffer (read-line *standard-input* nil nil))) (when buffer (map '(vector (unsigned-byte 32)) (function char-code) buffer)))) :while (and bytes (< (* 8 (length bytes)) bits)) :finally (return (and bytes (loop for i from 0 by 4 below (truncate (+ 7 bits) 8) collect (word (aref bytes (+ i 0)) (aref bytes (+ i 1)) (aref bytes (+ i 2)) (aref bytes (+ i 3))) into words finally (return (coerce words '(vector (unsigned-byte 32))))))))) (defun test () (loop with code = (make-array 2 :element-type '(unsigned-byte 32) :initial-element 0) with decr = (make-array 2 :element-type '(unsigned-byte 32) :initial-element 0) for clear = (prog1 (read-words 64 "clear text") (terpri)) for key = (prog1 (read-words 128 "key") (terpri)) while (and clear key) do (raiden-encipher clear code key) (format t "(encipher ~S ~S)~% --> ~S~%" clear key code) (raiden-decipher code decr key) (format t "(decipher ~S ~S)~% --> ~S~%" code key decr) (assert (equalp clear decr)))) (defun auto-test () (with-input-from-string (*standard-input* "Hello World! John McCarthy invented LISP. Big Unknown Secret. Very very secret key. Forget it! ") (test) :success)) ;; From: "Julio C. Hernandez Castro" <[email protected]> ;; Subject: New lightweight block cipher algorithm ;; Newsgroups: comp.programming, comp.lang.c++, de.comp.security.misc, ;; comp.lang.perl.misc, comp.lang.java.security ;; Date: 20 Oct 2006 06:49:35 -0700 ;; Organization: http://groups.google.com ;; Message-ID: <[email protected]> ;; ;; Dear all, ;; ;; We have just developped a new block cipher called Raiden, following a ;; Feistel Network structure by means of genetic programming. Our ;; intention now consists on getting as much feedback as possible from ;; users, so we encourage you to test the algorithm and send us your ;; opinion. We would also like to receive enhancements and new versions of ;; the algorithm, developed in other source languages and platforms. ;; ;; Our idea on developing this cipher is to propose it as an alternative ;; to TEA block cipher. TEA is a very interesting cipher with lots of real ;; applications. It is very simple and fast, and it reaches an acceptable ;; level of security by the application of a lot of cycles. ;; ;; Nowadays TEA has been broken, and several weaknesses of the algorithm ;; have been discovered. Since most of these weaknesses are related to its ;; Key Shedule routine, the authors, Roger Needham and David Wheeler ;; proposed an extended version of the algorithm with a more complex one. ;; This new version, which they called XTEA, did not have the expected ;; success of its antecessor, in part because it is slower. ;; ;; The algorithm known weaknesses, as well as its popularity, have made us ;; to think it was the time to develop an alternative to TEA. This ;; alternative, presented in this page, must have the next features: ;; ;; * It must be as quick as TEA, to be used in the same real world ;; applications ;; * It must be stronger, to avoid TEA weaknesses ;; ;; To develop this new block cipher we have used a genetic ;; programming-based technique. More on this to follow in a coming ;; scientific paper. ;; ;; Description of Raiden ;; ---------------------------- ;; ;; Raiden is a very small and compact cipher. It works with blocks of 64 ;; bits and keys of 128. As it can be seen below, the algorithm has the ;; same main structure as TEA: it is structured in cycles, where one cycle ;; contains two feistel rounds, and for both of them, the same round key ;; is used. In each round, the output of the round function on a sub block ;; is used to feed the other one. The round function of the algorithm has ;; the same size as TEA's one, but, as commented in section Raiden ;; Strength, it seems to be stronger. ;; ;; The Key Schedule routine is more complex than TEA's, but it is simple ;; enough to not overload the cipher execution time. To maximize the ;; entropy introduced by this function, in each round, its output feeds ;; the position i%4 of the key array. This makes the key array passed to ;; the function to evolve as the algorithm is executed, and thus ;; generating new round keys for each cycle with that 128 bit array. This ;; also makes that function to behave much as a PRNG. After analyzing the ;; algorithm, as commented in it homepage ;; (http://raiden-cipher.sourceforge.net/ in the Results section), we ;; propose the execution of sixteen cycles. Below, the code of Raiden ;; encoding routine is shown. ;; ;; ;; void raiden(unsigned long *data,unsigned long *result,unsigned long ;; *key) ;; { ;; ;; unsigned long b0=data[0], ;; b1=data[1],i,k[4]={key[0],key[1],key[2],key[3]}, sk; ;; for(i=0; i< 16; i++) ;; { ;; sk=k[i%4]=((k[0]+k[1])+((k[2]+k[3])^(k[0]<<k[2]))); ;; b0 +=((sk+b1)<<9)^((sk-b1)^((sk+b1)>>14)); ;; b1 +=((sk+b0)<<9)^((sk-b0)^((sk+b0)>>14)); ;; } ;; result[0]=b0; ;; result[1]=b1; ;; } ;; ;; The cipher receives the plain text in 'data' parameter, and puts the ;; cipher text in the 'result'. Key contains the 128 bit cipher key. ;; The cipher follows a Feistel structure, so the decoding is made in the ;; same way than the encoding but applying the round keys in the inverse ;; order. This is the Raiden decoding routine. ;; ;; void decode_raiden(unsigned long *data,unsigned long *result,unsigned ;; long *key) ;; { ;; ;; unsigned long b0=data[0], ;; b1=data[1],i,k[4]={key[0],key[1],key[2],key[3]}, ;; subkeys[16]; ;; for(i=0;i< 16;i++){ ;; //Subkeys are calculated ;; k[i%4]=((k[0]+k[1])+((k[2]+k[3])^(k[0]<<k[2]))); ;; subkeys[i]=k[i%4]; ;; } ;; for(i=15; i!=-1; i--) ;; { ;; //Process is applied in the inverse order ;; b1 -= ((subkeys[i]+b0)<<9)^((subkeys[i]-b0)^ ;; ((subkeys[i]+b0)>>14)); ;; b0 -= ((subkeys[i]+b1)<<9)^((subkeys[i]-b1)^ ;; ((subkeys[i]+b1)>>14)); ;; } ;; result[0]=b0; ;; result[1]=b1; ;; } ;; ;; In this case, the function receives the ciphertext in the 'data' ;; parameter and puts the plain text in the 'result'. The round keys are ;; calculated at the beginning of the function, and then they are applied ;; in the inverse order as they were when ciphering. ;; ;; The algorithm is free to anyone, and has been developed in ANSI C ;; source code under Linux. ;; We propose you to develop new versions of it using other programming ;; languages and platforms. ;; ;; Raiden Strength ;; --------------------- ;; ;; The main weaknesses of TEA, such as the Related Key Cryptanalysis, or ;; the equivalent keys, are related with its Key Shedule routine. Thus, ;; one of the main objectives when developing this new cipher has been to ;; develop an stronger Key Shedule function than TEA's. ;; ;; The function developed is also very simple, but not as much as TEA's. ;; TEA Key Shedule function consists only on adding a constant ;; (0x9e3779b9) to a variable. Thus, it is very simple to, knowing the ;; round key of cycle i, obtain the keys corresponding to the previous and ;; the following cycles. This is not the case in our algorithm, in which ;; doing so it is not a trivial problem. ;; ;; Therefore, the Key Shedule function behaves more as a Hash Function or ;; pseudorandom number generator, and does not have the same weaknesses as ;; TEA Key Schedule. Raiden's Round Function provided much better results ;; in the statistical tests than TEA's one, so we can conclude it is also ;; stronger, and, therefore, that the whole algorithm is also stronger. ;; ;; When we analyzed the algorithm using the statistical tests ENT, ;; Diehard, NIST and Sexton, we realized that Raiden results when applied ;; 16 cycles were, in many ocassions better, and at least comparable, to ;; TEA results when applied 32. This made us to conclude Raiden is ;; stronger than TEA and that 16 cycles would be an enough security margin ;; for the algorithm to be applied. The mentioned results can be consulted ;; in the Results of statistical tests on Raiden section at ;; http://raiden-cipher.sourceforge.net/ ;; ;; About the Authors ;; ------------------------ ;; ;; Raiden has been developed by: ;; ;; Julio Cesar Hernandez Castro, e-mail: jcesar_at_inf_dot_uc3m_dot_es ;; Javier Polimon Olabarrieta, jpolimon_at_gmail_dot_com ;; ;; Don't hesitate to contact the authors with your feedback. ;;;; THE END ;;;;
16,817
Common Lisp
.lisp
369
39.818428
126
0.581217
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
574174112f5110b9d27b1149589fef596c14b7df4f12ea055cdcc098465c119b
5,084
[ -1 ]
5,085
iso3166.lisp
informatimago_lisp/common-lisp/cesarum/iso3166.lisp
;;;; -*- mode:lisp; coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: iso3166.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; This package exports functions and data to process ;;;; iso3166 country codes. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2004-10-14 <PJB> Converted Alpha code symbols to strings. ;;;; 2004-03-16 <PJB> Added alpha-3 and numeric codes. ;;;; 2003-10-14 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2003 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.ISO3166" (:use "COMMON-LISP") (:export "GET-COUNTRIES") (:documentation " This package exports functions and data to process iso3166 country codes. License: AGPL3 Copyright Pascal J. Bourguignon 2003 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.ISO3166") (defmacro c-code-n (c) `(first ,c)) (defmacro c-code-3 (c) `(second ,c)) (defmacro c-code-2 (c) `(third ,c)) (defmacro c-exists (c) `(fourth ,c)) (defmacro c-fr-name (c) `(fifth ,c)) (defmacro c-en-name (c) `(sixth ,c)) ;; https://online.correos.es/ayuda/codigoiso.asp (defvar +countries+ '( ( 180 "COD" "CD" nil "La République Démocratique Du Congo" "The Democratic Republic Of Congo") ( 807 "MKD" "MK" nil "L'Ex-République Yougoslave De Macédoine" "The Former Yugoslav Republic Of Macedonia") ( 275 "PSE" "PS" nil "Territoire Palestinien Occupé" "Occupied Palestinian Territory") ( 626 "TLS" "TL" nil "Timor-Leste" "Timor-Leste") ( 020 "AND" "AD" t "Andorre" "Andorra") ( 784 "ARE" "AE" t "Émirats Arabes Unis" "United Arab Emirates") ( 004 "AFG" "AF" t "Afghanistan" "Afghanistan") ( 028 "ATG" "AG" t "Antigua et Barbuda" "Antigua and Barbuda") ( 660 "AIA" "AI" t "Anguilla" "Anguilla") ( 008 "ALB" "AL" t "Albanie" "Albania") ( 051 "ARM" "AM" t "Arménie" "Armenia") ( 530 "ANT" "AN" t "Antilles Néerlandaises" "Netherlands Antilles") ( 024 "AGO" "AO" t "Angola" "Angola") ( 010 "ATA" "AQ" t "Antarctique" "Antarctica") ( 032 "ARG" "AR" t "Argentine" "Argentina") ( 016 "ASM" "AS" t "Samoa Américaines" "American Samoa") ( 040 "AUT" "AT" t "Autriche" "Austria") ( 036 "AUS" "AU" t "Australie" "Australia") ( 533 "ABW" "AW" t "Aruba" "Aruba") ( 031 "AZE" "AZ" t "Azerbaïdjan" "Azerbaijan") ( 070 "BIH" "BA" t "Bosnie-Herzégovine" "Bosnia and Herzegovina") ( 052 "BRB" "BB" t "Barbade" "Barbados") ( 050 "BGD" "BD" t "Bangladesh" "Bangladesh") ( 056 "BEL" "BE" t "Belgique" "Belgium") ( 854 "BFA" "BF" t "Burkina Faso" "Burkina Faso") ( 100 "BGR" "BG" t "Bulgarie" "Bulgaria") ( 048 "BHR" "BH" t "Bahreïn" "Bahrain") ( 108 "BDI" "BI" t "Burundi" "Burundi") ( 204 "BEN" "BJ" t "Bénin" "Benin") ( 060 "BMU" "BM" t "Bermudes" "Bermuda") ( 096 "BRN" "BN" t "Brunéi Darussalam" "Brunei Darussalam") ( 068 "BOL" "BO" t "Bolivie" "Bolivia") ( 076 "BRA" "BR" t "Brésil" "Brazil") ( 044 "BHS" "BS" t "Bahamas" "Bahamas") ( 064 "BTN" "BT" t "Bhoutan" "Bhutan") ( 000 "NIL" "BU" nil "Burma" "Burma") ( 074 "BVT" "BV" t "Île Bouvet" "Bouvet Island") ( 072 "BWA" "BW" t "Botswana" "Botswana") ( 112 "BLR" "BY" t "Bélarus" "Belarus") ( 084 "BLZ" "BZ" t "Belize" "Belize") ( 124 "CAN" "CA" t "Canada" "Canada") ( 166 "CCK" "CC" t "Îles Cocos (Keeling)" "Cocos (Keeling) Islands") ( 140 "CAF" "CF" t "République Centrafricaine" "Central African Republic") ( 178 "COG" "CG" t "Congo" "Republic of the Congo") ( 756 "CHE" "CH" t "Suisse" "Switzerland") ( 384 "CIV" "CI" t "Côte d'Ivoire" "Ivory Coast") ( 184 "COK" "CK" t "Îles Cook" "Cook Islands") ( 152 "CHL" "CL" t "Chili" "Chile") ( 120 "CMR" "CM" t "Cameroun" "Cameroon") ( 156 "CHN" "CN" t "Chine" "China") ( 170 "COL" "CO" t "Colombie" "Colombia") ( 188 "CRI" "CR" t "Costa Rica" "Costa Rica") ( 891 "SCG" "CS" t "Serbie et Monténégro" "Serbia and Montenegro") ( 192 "CUB" "CU" t "Cuba" "Cuba") ( 132 "CPV" "CV" t "Cap-Vert" "Cape Verde") ( 162 "CXR" "CX" t "Île Christmas" "Christmas Island") ( 196 "CYP" "CY" t "Chypre" "Cyprus") ( 203 "CZE" "CZ" t "République Tchèque" "Czech Republic") ( 000 "NIL" "DD" nil "République Démocratique d'Allemagne" "German Democratic Republic") ( 276 "DEU" "DE" t "Allemagne" "Germany") ( 262 "DJI" "DJ" t "Djibouti" "Djibouti") ( 208 "DNK" "DK" t "Danemark" "Denmark") ( 212 "DMA" "DM" t "Dominique" "Dominica") ( 214 "DOM" "DO" t "République Dominicaine" "Dominican Republic") ( 012 "DZA" "DZ" t "Algérie" "Algeria") ( 218 "ECU" "EC" t "Équateur" "Ecuador") ( 233 "EST" "EE" t "Estonie" "Estonia") ( 818 "EGY" "EG" t "Égypte" "Egypt") ( 732 "ESH" "EH" t "Sahara Occidental" "Western Sahara") ( 232 "ERI" "ER" t "Érythrée" "Eritrea") ( 724 "ESP" "ES" t "Espagne" "Spain") ( 231 "ETH" "ET" t "Éthiopie" "Ethiopia") ( 246 "FIN" "FI" t "Finlande" "Finland") ( 242 "FJI" "FJ" t "Fidji" "Fiji") ( 238 "FLK" "FK" t "Îles Malouines" "Falkland Islands") ( 583 "FSM" "FM" t "États Fédérés De Micronésie" "Federated States Of Micronesia") ( 234 "FRO" "FO" t "Îles Féroé" "Faroe Islands") ( 250 "FRA" "FR" t "France" "France") ( 000 "NIL" "FX" t "France Métropolitaine" "Metropolitan France") ( 266 "GAB" "GA" t "Gabon" "Gabon") ( 826 "GBR" "GB" t "Royaume-Uni" "United Kingdom") ( 308 "GRD" "GD" t "Grenade" "Grenada") ( 268 "GEO" "GE" t "Géorgie" "Georgia") ( 254 "GUF" "GF" t "Guyane Française" "French Guiana") ( 288 "GHA" "GH" t "Ghana" "Ghana") ( 292 "GIB" "GI" t "Gibraltar" "Gibraltar") ( 304 "GRL" "GL" t "Groenland" "Greenland") ( 270 "GMB" "GM" t "Gambie" "Gambia") ( 324 "GIN" "GN" t "Guinée" "Guinea") ( 312 "GLP" "GP" t "Guadeloupe" "Guadeloupe") ( 226 "GNQ" "GQ" t "Guinée Équatoriale" "Equatorial Guinea") ( 300 "GRC" "GR" t "Grèce" "Greece") ( 239 "SGS" "GS" t "Géorgie Du Sud et Les Îles Sandwich Du Sud" "South Georgia and the South Sandwich Islands") ( 320 "GTM" "GT" t "Guatemala" "Guatemala") ( 316 "GUM" "GU" t "Guam" "Guam") ( 624 "GNB" "GW" t "Guinée-Bissau" "Guinea-Bissau") ( 328 "GUY" "GY" t "Guyana" "Guyana") ( 344 "HKG" "HK" t "Hong-Kong" "Hong Kong") ( 334 "HMD" "HM" t "Île Mcdonald et îles Heard" "Heard Island and Mcdonald Islands") ( 340 "HND" "HN" t "Honduras" "Honduras") ( 191 "HRV" "HR" t "Croatie" "Croatia") ( 332 "HTI" "HT" t "Haïti" "Haiti") ( 348 "HUN" "HU" t "Hongrie" "Hungary") ( 360 "IDN" "ID" t "Indonésie" "Indonesia") ( 372 "IRL" "IE" t "Irlande" "Republic of Ireland") ( 376 "ISR" "IL" t "Israël" "Israel") ( 356 "IND" "IN" t "Inde" "India") ( 092 "IOT" "IO" t "Territoire Britannique de l'Océan Indien" "British Indian Ocean Territory") ( 368 "IRQ" "IQ" t "Iraq" "Iraq") ( 364 "IRN" "IR" t "République Islamique d'Iran" "Islamic Republic of Iran") ( 352 "ISL" "IS" t "Islande" "Iceland") ( 380 "ITA" "IT" t "Italie" "Italy") ( 388 "JAM" "JM" t "Jamaïque" "Jamaica") ( 400 "JOR" "JO" t "Jordanie" "Jordan") ( 392 "JPN" "JP" t "Japon" "Japan") ( 404 "KEN" "KE" t "Kenya" "Kenya") ( 417 "KGZ" "KG" t "Kirghizistan" "Kyrgyzstan") ( 116 "KHM" "KH" t "Cambodge" "Cambodia") ( 296 "KIR" "KI" t "Kiribati" "Kiribati") ( 174 "COM" "KM" t "Comores" "Comoros") ( 659 "KNA" "KN" t "Saint-Kitts et Nevis" "Saint Kitts and Nevis") ( 408 "PRK" "KP" t "République Populaire Démocratique De Corée" "Democratic People's Republic of Korea") ( 410 "KOR" "KR" t "République De Corée" "Republic of Korea") ( 414 "KWT" "KW" t "Koweït" "Kuwait") ( 136 "CYM" "KY" t "Îles Caïmanes" "Cayman Islands") ( 398 "KAZ" "KZ" t "Kazakhstan" "Kazakhstan") ( 418 "LAO" "LA" t "République Démocratique Populaire Lao" "Lao People's Democratic Republic") ( 422 "LBN" "LB" t "Liban" "Lebanon") ( 662 "LCA" "LC" t "Sainte-Lucie" "Saint Lucia") ( 438 "LIE" "LI" t "Liechtenstein" "Liechtenstein") ( 144 "LKA" "LK" t "Sri Lanka" "Sri Lanka") ( 430 "LBR" "LR" t "Libéria" "Liberia") ( 426 "LSO" "LS" t "Lesotho" "Lesotho") ( 440 "LTU" "LT" t "Lituanie" "Lithuania") ( 442 "LUX" "LU" t "Luxembourg" "Luxembourg") ( 428 "LVA" "LV" t "Lettonie" "Latvia") ( 434 "LBY" "LY" t "Jamahiriya Arabe Libyenne" "Libyan Arab Jamahiriya") ( 504 "MAR" "MA" t "Maroc" "Morocco") ( 492 "MCO" "MC" t "Monaco" "Monaco") ( 498 "MDA" "MD" t "République De Moldova" "Republic of Moldova") ( 450 "MDG" "MG" t "Madagascar" "Madagascar") ( 584 "MHL" "MH" t "Îles Marshall" "Marshall Islands") ( 466 "MLI" "ML" t "Mali" "Mali") ( 104 "MMR" "MM" t "Myanmar" "Myanmar") ( 496 "MNG" "MN" t "Mongolie" "Mongolia") ( 446 "MAC" "MO" t "Macao" "Macao") ( 580 "MNP" "MP" t "Îles Mariannes Du Nord" "Northern Mariana Islands") ( 474 "MTQ" "MQ" t "Martinique" "Martinique") ( 478 "MRT" "MR" t "Mauritanie" "Mauritania") ( 500 "MSR" "MS" t "Montserrat" "Montserrat") ( 470 "MLT" "MT" t "Malte" "Malta") ( 480 "MUS" "MU" t "Maurice" "Mauritius") ( 462 "MDV" "MV" t "Maldives" "Maldives") ( 454 "MWI" "MW" t "Malawi" "Malawi") ( 484 "MEX" "MX" t "Mexique" "Mexico") ( 458 "MYS" "MY" t "Malaisie" "Malaysia") ( 508 "MOZ" "MZ" t "Mozambique" "Mozambique") ( 516 "NAM" "NA" t "Namibie" "Namibia") ( 540 "NCL" "NC" t "Nouvelle-Calédonie" "New Caledonia") ( 562 "NER" "NE" t "Niger" "Niger") ( 574 "NFK" "NF" t "Île Norfolk" "Norfolk Island") ( 566 "NGA" "NG" t "Nigéria" "Nigeria") ( 558 "NIC" "NI" t "Nicaragua" "Nicaragua") ( 528 "NLD" "NL" t "Pays-Bas" "Netherlands") ( 578 "NOR" "NO" t "Norvège" "Norway") ( 524 "NPL" "NP" t "Népal" "Nepal") ( 520 "NRU" "NR" t "Nauru" "Nauru") ( 000 "NIL" "NT" nil "Nil" "Nil") ( 570 "NIU" "NU" t "Niué" "Niue") ( 554 "NZL" "NZ" t "Nouvelle-Zélande" "New Zealand") ( 512 "OMN" "OM" t "Oman" "Oman") ( 591 "PAN" "PA" t "Panama" "Panama") ( 604 "PER" "PE" t "Pérou" "Peru") ( 258 "PYF" "PF" t "Polynésie Française" "French Polynesia") ( 598 "PNG" "PG" t "Papouasie-Nouvelle-Guinée" "Papua New Guinea") ( 608 "PHL" "PH" t "Philippines" "Philippines") ( 586 "PAK" "PK" t "Pakistan" "Pakistan") ( 616 "POL" "PL" t "Pologne" "Poland") ( 666 "SPM" "PM" t "Saint-Pierre et Miquelon" "Saint Pierre and Miquelon") ( 612 "PCN" "PN" t "Pitcairn" "Pitcairn") ( 630 "PRI" "PR" t "Porto Rico" "Puerto Rico") ( 620 "PRT" "PT" t "Portugal" "Portugal") ( 585 "PLW" "PW" t "Palaos" "Palau") ( 600 "PRY" "PY" t "Paraguay" "Paraguay") ( 634 "QAT" "QA" t "Qatar" "Qatar") ( 638 "REU" "RE" t "Réunion" "Reunion") ( 642 "ROU" "RO" t "Roumanie" "Romania") ( 643 "RUS" "RU" t "Fédération De Russie" "Russian Federation") ( 646 "RWA" "RW" t "Rwanda" "Rwanda") ( 682 "SAU" "SA" t "Arabie Saoudite" "Saudi Arabia") ( 090 "SLB" "SB" t "Îles Salomon" "Solomon Islands") ( 690 "SYC" "SC" t "Seychelles" "Seychelles") ( 736 "SDN" "SD" t "Soudan" "Sudan") ( 752 "SWE" "SE" t "Suède" "Sweden") ( 702 "SGP" "SG" t "Singapour" "Singapore") ( 654 "SHN" "SH" t "Sainte-Hélène" "Saint Helena") ( 705 "SVN" "SI" t "Slovénie" "Slovenia") ( 744 "SJM" "SJ" t "Svalbard et île Jan Mayen" "Svalbard and Jan Mayen Islands") ( 703 "SVK" "SK" t "Slovaquie" "Slovakia") ( 694 "SLE" "SL" t "Sierra Leone" "Sierra Leone") ( 674 "SMR" "SM" t "Saint-Marin" "San Marino") ( 686 "SEN" "SN" t "Sénégal" "Senegal") ( 706 "SOM" "SO" t "Somalie" "Somalia") ( 740 "SUR" "SR" t "Suriname" "Suriname") ( 678 "STP" "ST" t "Sáo Tomé et Principe" "Sao Tome and Principe") ( 000 "NIL" "SU" nil "Union des Républiques Socialistes Soviétiques" "Union of Soviet Socialist Republics") ( 222 "SLV" "SV" t "El Salvador" "El Salvador") ( 760 "SYR" "SY" t "République Arabe Syrienne" "Syrian Arab Republic") ( 748 "SWZ" "SZ" t "Swaziland" "Swaziland") ( 796 "TCA" "TC" t "Îles Turks et Caïques" "Turks and Caicos Islands") ( 148 "TCD" "TD" t "Tchad" "Chad") ( 260 "ATF" "TF" t "Terres Australes Françaises" "French Southern Territories") ( 768 "TGO" "TG" t "Togo" "Togo") ( 764 "THA" "TH" t "Thaïlande" "Thailand") ( 762 "TJK" "TJ" t "Tadjikistan" "Tajikistan") ( 772 "TKL" "TK" t "Tokelau" "Tokelau") ( 795 "TKM" "TM" t "Turkménistan" "Turkmenistan") ( 788 "TUN" "TN" t "Tunisie" "Tunisia") ( 776 "TON" "TO" t "Tonga" "Tonga") ( 000 "NIL" "TP" t "Timor Oriental" "East Timor") ( 792 "TUR" "TR" t "Turquie" "Turkey") ( 780 "TTO" "TT" t "Trinité et Tobago" "Trinidad and Tobago") ( 798 "TUV" "TV" t "Tuvalu" "Tuvalu") ( 158 "TWN" "TW" t "Province de Chine Taïwan" "Province of China Taiwan") ( 834 "TZA" "TZ" t "République-Unie de Tanzanie" "United Republic of Tanzania") ( 804 "UKR" "UA" t "Ukraine" "Ukraine") ( 800 "UGA" "UG" t "Ouganda" "Uganda") ( 581 "UMI" "UM" t "Îles Mineures Éloignées des États-Unis" "United States Minor Outlying Islands") ( 840 "USA" "US" t "États-Unis" "United States of America") ( 858 "URY" "UY" t "Uruguay" "Uruguay") ( 860 "UZB" "UZ" t "Ouzbékistan" "Uzbekistan") ( 336 "VAT" "VA" t "Saint-Siège (État de La Cité Du Vatican)" "Holy See (Vatican City State)") ( 670 "VCT" "VC" t "Saint-Vincent et Les Grenadines" "Saint Vincent and The Grenadines") ( 862 "VEN" "VE" t "Venezuela" "Venezuela") ( 092 "VGB" "VG" t "Îles Vierges Britanniques" "British Virgin Islands") ( 850 "VIR" "VI" t "Îles Vierges Des États-Unis" "United States Virgin Islands") ( 704 "VNM" "VN" t "Viet Nam" "Viet Nam") ( 548 "VUT" "VU" t "Vanuatu" "Vanuatu") ( 876 "WLF" "WF" t "Wallis Et Futuna" "Wallis and Futuna Islands") ( 882 "WSM" "WS" t "Samoa" "Samoa") ( 000 "NIL" "YD" nil "Yemen Démocratique" "Democratic Yemen") ( 887 "YEM" "YE" t "Yémen" "Yemen") ( 175 "MYT" "YT" t "Mayotte" "Mayotte") ( 000 "NIL" "YU" t "Yougoslavie" "Yugoslavia") ( 710 "ZAF" "ZA" t "Afrique Du Sud" "South Africa") ( 894 "ZMB" "ZM" t "Zambie" "Zambia") ( 000 "NIL" "ZR" t "Zaïre" "Zaire") ( 716 "ZWE" "ZW" t "Zimbabwe" "Zimbabwe") ( 000 "NIL" "ZZ" t "Pays inconnu ou non spécifié" "Unknown or unspecified country") ( 248 "ALA" "AX" t "Îles Aland" "Áland Islands") )) ;;+COUNTRIES+ (defun get-countries (&key only-existing (language "EN") order) " only-existing: T <=> filter out codes for countries that don't exist anymore. language: EN or FR (case insensitive string or symbol whose name is EN or FR) order: :NAME or :CODE; if not specified, no ordering is done. RETURN: A list of (code name). " (let* ((include-all (not only-existing)) (result (mapcan (lambda (c) (when (or include-all (c-exists c)) (list (list (c-code-2 c) (if (string-equal "EN" language) (c-en-name c) (c-fr-name c)))))) +countries+))) (when order (setq result (sort result (if (eq :code order) (lambda (a b) (string-lessp (first a) (first b))) (lambda (a b) (string-lessp (second a) (second b))))))) result)) ;;;; iso3166.lisp -- -- ;;;;
19,994
Common Lisp
.lisp
844
17.893365
83
0.527947
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
23c3b2c927c8d916bb940ae571403ffea5ac9b9610e95ed71e0c8126c1924e4c
5,085
[ -1 ]
5,086
graph.lisp
informatimago_lisp/common-lisp/cesarum/graph.lisp
;;;; -*- coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: graph.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: None ;;;;DESCRIPTION ;;;; ;;;; Graph class. ;;;; ;;;; This is a CLOS based implementation of graphs. ;;;; It comes from an emacs/eieio implementation used to analyze ;;;; CVS versioning graph. ;;;; ;;;; Subclasses exist to generate dot files, and Diagram! files. ;;;; ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2004-08-06 <PJB> Added defgeneric. ;;;; 2003-05-16 <PJB> Converted to Common-Lisp. ;;;; 2003-05-14 <PJB> Extracted from pjb-cvs.el ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2003 - 2018 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.GRAPH" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.LIST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SET") (:shadowing-import-from "COMMON-LISP" "UNION" "INTERSECTION" "MERGE") (:export "EDGE-CLASS" "EDGES" "NODES" "TO" "FROM" "WEIGHT" "INDEX" "ELEMENTS" "PROPERTIES" "IDENT" "SHOW-GRAPH" "FIND-NODES-WITH-PROPERTY" "COPY" "WALK-EDGES-FROM-NODE" "WALK-FROM-NODE" "FLOW-DISTANCE-FROM-NODE" "ADJACENT-NODES" "SUCCESSOR-NODES" "DIRECTED-EDGES-FROM-NODE" "DIRECTED-EDGES-BETWEEN-NODES" "EDGES-BETWEEN-NODES" "REMOVE-EDGES-BETWEEN-NODES" "REMOVE-EDGES" "REMOVE-EDGE" "ADD-EDGE-BETWEEN-NODES" "ADD-EDGE" "REMOVE-NODES" "REMOVE-NODE" "ADD-NODES" "ADD-NODE" "DESCRIPTION" "GRAPH-CLASS" "SUBCLASS-OF-EDGE-P" "WEIGHTED-DIRECTED-EDGE-CLASS" "SET-NODES" "SUCCESSOR-OF" "IS-BETWEEN-NODES" "DIRECTED-EDGE-CLASS" "WEIGHTED-UNDIRECTED-EDGE-CLASS" "IDENTICAL-NODES" "UNDIRECTED-EDGE-CLASS" "NODE-CONS-P" "SET-WEIGHT" "WEIGHT-MIXIN-CLASS" "EDGE-CLASS" "ADD-ELEMENT" "CONTAINS-ELEMENT" "HASHED-SET-CLASS" "FIND-ELEMENTS-WITH-PROPERTY" "ELEMENT-LIST" "SELECT-ELEMENTS" "MAP-ELEMENTS" "PERFORM-WITH-ELEMENTS" "REMOVE-ELEMENT" "ADD-ELEMENTS" "CARDINAL" "SET-CLASS" "DELETE-PROPERTY" "GET-PROPERTY" "SET-PROPERTY" "PROPERTY-NAMES" "ELEMENT-CLASS") (:documentation " This package exports classes for elements, sets and graphs. Graph class. This is a CLOS based implementation of graphs. It comes from an emacs/eieio implementation used to analyze CVS versioning graph. Subclasses exist to generate dot files, and Diagram! files. See also: License: AGPL3 Copyright Pascal J. Bourguignon 2003 - 2018 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.GRAPH") ;;; cat graph.lisp | sed -n -e '/^(DEF/s/^(DEF/;; /p' -e 's/;; UN/;; FUN/' ;; CLASS ELEMENT-CLASS () ;; METHOD INITIALIZE-INSTANCE ((SELF ELEMENT-CLASS) FIELDS) ;; METHOD DESCRIPTION ((SELF ELEMENT-CLASS)) ;; METHOD PROPERTY-NAMES ((SELF ELEMENT-CLASS)) ;; METHOD SET-PROPERTY ((SELF ELEMENT-CLASS) (PROP-NAME SYMBOL) PROP-VALUE) ;; METHOD GET-PROPERTY ((SELF ELEMENT-CLASS) (PROP-NAME SYMBOL)) ;; METHOD DELETE-PROPERTY ((SELF ELEMENT-CLASS) (PROP-NAME SYMBOL)) ;; CLASS SET-CLASS (ELEMENT-CLASS) ;; METHOD DESCRIPTION ((SELF SET-CLASS)) ;; METHOD CARDINAL ((SELF SET-CLASS)) ;; METHOD CONTAINS-ELEMENT ((SELF SET-CLASS) (ANELEMENT ELEMENT-CLASS)) ;; METHOD ADD-ELEMENT ((SELF SET-CLASS) (NEWELEMENT ELEMENT-CLASS)) ;; METHOD ADD-ELEMENTS ((SELF SET-CLASS) NEWELEMENTLIST) ;; METHOD REMOVE-ELEMENT ((SELF SET-CLASS) (OLDELEMENT ELEMENT-CLASS)) ;; METHOD PERFORM-WITH-ELEMENTS ((SELF SET-CLASS) LAMBDA-BODY) ;; METHOD MAP-ELEMENTS (result-type (SELF SET-CLASS) LAMBDA-BODY) ;; METHOD SELECT-ELEMENTS ((SELF SET-CLASS) SELECT-LAMBDA) ;; METHOD ELEMENT-LIST ((SELF SET-CLASS)) ;; METHOD FIND-ELEMENTS-WITH-PROPERTY ;; CLASS HASHED-SET-CLASS (SET-CLASS) ;; METHOD CONTAINS-ELEMENT ((SELF HASHED-SET-CLASS) (ANELEMENT ELEMENT-CLASS)) ;; METHOD ADD-ELEMENT ((SELF HASHED-SET-CLASS) (NEWELEMENT ELEMENT-CLASS)) ;; CLASS EDGE-CLASS (ELEMENT-CLASS) ;; METHOD DESCRIPTION ((SELF EDGE-CLASS)) ;; GENERIC COPY ((SELF EDGE-CLASS)) ;; GENERIC NODES ((SELF EDGE-CLASS)) ;; GENERIC IS-BETWEEN-NODES ((SELF EDGE-CLASS) ;; GENERIC SUCCESSOR-OF ((SELF EDGE-CLASS) (NODE ELEMENT-CLASS)) ;; CLASS WEIGHT-MIXIN-CLASS () ;; METHOD SET-WEIGHT ((SELF WEIGHT-MIXIN-CLASS) (NEWWEIGHT INTEGER)) ;; FUN NODE-CONS-P (ITEM) ;; CLASS UNDIRECTED-EDGE-CLASS (EDGE-CLASS) ;; METHOD COPY ((SELF UNDIRECTED-EDGE-CLASS)) ;; FUN IDENTICAL-NODES (NODES-CONS-A NODES-CONS-B) ;; METHOD IS-BETWEEN-NODES ((SELF EDGE-CLASS) ;; METHOD SUCCESSOR-OF ((SELF UNDIRECTED-EDGE-CLASS) (NODE ELEMENT-CLASS)) ;; METHOD SET-NODES ((SELF UNDIRECTED-EDGE-CLASS) ;; CLASS WEIGHTED-UNDIRECTED-EDGE-CLASS ;; METHOD DESCRIPTION ((SELF WEIGHTED-UNDIRECTED-EDGE-CLASS)) ;; CLASS DIRECTED-EDGE-CLASS (EDGE-CLASS) ;; METHOD COPY ((SELF DIRECTED-EDGE-CLASS)) ;; METHOD NODES ((SELF DIRECTED-EDGE-CLASS)) ;; METHOD IS-BETWEEN-NODES ((SELF EDGE-CLASS) ;; METHOD SUCCESSOR-OF ((SELF DIRECTED-EDGE-CLASS) (NODE ELEMENT-CLASS)) ;; METHOD SET-NODES ((SELF DIRECTED-EDGE-CLASS) ;; CLASS WEIGHTED-DIRECTED-EDGE-CLASS (DIRECTED-EDGE-CLASS WEIGHT-MIXIN-CLASS) ;; METHOD DESCRIPTION ((SELF WEIGHTED-DIRECTED-EDGE-CLASS)) ;; METHOD COPY ((SELF WEIGHTED-DIRECTED-EDGE-CLASS)) ;; FUN SUBCLASS-OF-EDGE-P (ITEM) ;; CLASS GRAPH-CLASS (ELEMENT-CLASS) ;; METHOD DESCRIPTION ((SELF GRAPH-CLASS)) ;; METHOD ADD-NODE ((SELF GRAPH-CLASS) (NEWNODE ELEMENT-CLASS)) ;; METHOD ADD-NODES ((SELF GRAPH-CLASS) NEWNODELIST) ;; METHOD REMOVE-NODE ((SELF GRAPH-CLASS) (OLDNODE ELEMENT-CLASS)) ;; METHOD REMOVE-NODES ((SELF GRAPH-CLASS) OLDNODELIST) ;; METHOD ADD-EDGE ((SELF GRAPH-CLASS) (NEWEDGE EDGE-CLASS)) ;; METHOD ADD-EDGE-BETWEEN-NODES ((SELF GRAPH-CLASS) ;; METHOD REMOVE-EDGE ((SELF GRAPH-CLASS) (OLDEDGE EDGE-CLASS)) ;; METHOD REMOVE-EDGES ((SELF GRAPH-CLASS) EDGE-LIST) ;; METHOD REMOVE-EDGES-BETWEEN-NODES ((SELF GRAPH-CLASS) ;; METHOD EDGES-BETWEEN-NODES ((SELF GRAPH-CLASS) ;; METHOD DIRECTED-EDGES-BETWEEN-NODES ((SELF GRAPH-CLASS) ;; METHOD DIRECTED-EDGES-FROM-NODE ((SELF GRAPH-CLASS) ;; METHOD SUCCESSOR-NODES ((SELF GRAPH-CLASS) (NODE ELEMENT-CLASS)) ;; METHOD ADJACENT-NODES ((SELF GRAPH-CLASS) (NODE ELEMENT-CLASS)) ;; METHOD FLOW-DISTANCE-FROM-NODE ((SELF GRAPH-CLASS) ;; METHOD WALK-FROM-NODE ((SELF GRAPH-CLASS) (STARTNODE ELEMENT-CLASS) ;; METHOD WALK-EDGES-FROM-NODE ((SELF GRAPH-CLASS) ;; METHOD COPY ((SELF GRAPH-CLASS) &REST KEYS) ;; METHOD FIND-NODES-WITH-PROPERTY ((SELF GRAPH-CLASS) ;; METHOD SHOW-GRAPH ((SELF GRAPH-CLASS)) (defgeneric property-names (self) (:documentation " RETURN: The list of property names (keys) of properties of this element. ")) (defgeneric set-property (self prop-name prop-value) (:documentation " POST: (eql (GET-PROPERTY self prop-name) prop-value) ")) (defgeneric get-property (self prop-name) (:documentation " RETURN: the property `prop-name' of this element. ")) (defgeneric delete-property (self prop-name) (:documentation " DO: Remove the property named `prop-name' from the property list of this element. ")) (defgeneric add-elements (self newelementlist) (:documentation " DO: Add each element of the newElementList to this set. ")) (defgeneric remove-element (self oldelement) (:documentation " PRE: already_in = (CONTAINS-ELEMENT self newElement), old_CARDINAL = (CARDINAL self) POST: already_in ==> (CARDINAL self) == (1- old_CARDINAL), (not (CONTAINS-ELEMENT self oldElement)) (not already_in) ==> (CARDINAL self) == old_CARDINAL ")) (defgeneric perform-with-elements (self lambda-body) (:documentation " DO: calls lambda-body with each element in the set. NOTE: lambda-body must not change this set. ")) (defgeneric select-elements (self select-lambda) (:documentation " RETURN: A list of elements for which select-lambda returned true. ")) (defgeneric element-list (self) (:documentation " RETURN: A new list of the elements in self. ")) (defgeneric find-elements-with-property (self property value) (:documentation " RETURN: A list of elements that have as property PROPERTY the value VALUE. ")) (defgeneric contains-element (self anelement) (:documentation " RETURN: Whether this set contains anElement. ")) (defgeneric add-element (self newelement) (:documentation " PRE: already_in = (CONTAINS-ELEMENT self newElement), old_CARDINAL = (CARDINAL self) POST: already_in ==> (CARDINAL self) == old_CARDINAL (not already_in) ==> (CARDINAL self) == (1+ old_CARDINAL) (CONTAINS-ELEMENT self newElement) ")) (defgeneric set-weight (self newweight) (:documentation " POST: (equal (weight self) newWeight) ")) (defgeneric set-nodes (self newfrom newto) (:documentation " DO: set the NODES of this edge. ")) (defgeneric description (self) (:documentation " RETURN: A string describing this element. ")) (defgeneric add-node (self newnode) (:documentation " DO: Add newNode to the set of NODES of this graph. ")) (defgeneric add-nodes (self newnodelist) (:documentation " DO: Add a list of new NODES to the set of NODES of this graph. ")) (defgeneric remove-node (self oldnode) (:documentation " DO: Remove the oldNode from the graph. This implies removing all the edges adjacent to the node too. ")) (defgeneric remove-nodes (self oldnodelist) (:documentation " DO: Remove all the NODES of the oldNodeList from this graph. ")) (defgeneric add-edge (self newedge) (:documentation " PRE: (and (CONTAINS-ELEMENT (NODES self) (nth 0 (NODES newEdge))) (CONTAINS-ELEMENT (NODES self) (nth 1 (NODES newEdge)))) DO: Add a new edge to this graph. ")) (defgeneric add-edge-between-nodes (self nodea nodeb) (:documentation " DO: Create a new edge (of class edge-class) between `nodeA' and `nodeB'. and add it to this graph. If the edge is directed, then `nodeA' is the `from' node and `nodeB' the `to' node. ")) (defgeneric remove-edge (self oldedge) (:documentation " DO: Remove the `oldEdge' from this graph. ")) (defgeneric remove-edges (self edge-list) (:documentation " DO: Remove all the edges in edge-list from this graph. ")) (defgeneric remove-edges-between-nodes (self nodea nodeb) (:documentation " DO: Remove all edges between `nodeA' and `nodeB'. ")) (defgeneric edges-between-nodes (self nodea nodeb) (:documentation " RETURN: A list of edges existing between the `nodeA' and `nodeB'. If the graph is directed then `nodeA' corresponds to the from node and `nodeB' corresponds to the to node. ")) (defgeneric directed-edges-between-nodes (self fromnode tonode) (:documentation " RETURN: A list of edges existing from the `fromNode' and to the `toNode'. ")) (defgeneric directed-edges-from-node (self fromnode) (:documentation " PRE: edge-class is-subclass-of DIRECTED-EDGE-CLASS or edge-class eq DIRECTED-EDGE-CLASS. RETURN: A list of edges existing from the `fromNode'. ")) (defgeneric successor-nodes (self node) (:documentation " RETURN: The list of successors NODES of the given node in this graph. NOTE: For undirected graphs, it's the same as ADJACENT-NODES. ")) (defgeneric adjacent-nodes (self node) (:documentation " RETURN: The list of NODES adjacent to the given node in this graph. NOTE: For directed graphs, an adjacent node is either a predecessor or a successors of the node. ")) (defgeneric flow-distance-from-node (self startnode prop-name) (:documentation " DO: Compute for each node in this graph the distance from the startNode, and store it as a property named prop-name. NOTE: If the graph is not connex, then some distances will be nil, meaning infinity. ")) (defgeneric walk-from-node (self startnode lambda-body) (:documentation " DO: Walk the graph starting form startNode, calling lambda-body with each node as argument. ")) (defgeneric walk-edges-from-node (self startnode lambda-body) (:documentation " DO: Walk the graph starting form startNode, calling lambda-body with each edges as argument. Since it's the edges that are passed to lambda-body, one node can be \"walked\" several times either as `from' or `to' node or different edges. ")) (defgeneric find-nodes-with-property (self property value) (:documentation " RETURN: A list of NODES that have as property PROPERTY the value VALUE. ")) (defgeneric show-graph (self) (:documentation " DO: Prints a description of the graph on the *STANDARD-OUTPUT*. ")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defgeneric ident (element) (:documentation "A unique symbol identifying this element.")) (defgeneric properties (element) (:documentation "A plist of properties for this elements. It can be used to store markers while walking sets or graphs containing them.")) (defclass element-class () ((ident :reader ident :type symbol :documentation "A unique symbol identifying this element.") (properties :initform nil :initarg :properties :accessor properties :type list :documentation "A plist of properties for this elements. It can be used to store markers while walking sets or graphs containing them.")) (:documentation "An element of a SET-CLASS.")) (defmethod initialize-instance :after ((self element-class) &rest initargs &key &allow-other-keys) " DO: Initalize the instance id. " (declare (ignore initargs)) (setf (slot-value self 'ident) (gensym (format nil "~A-" (string-upcase (class-name (class-of self)))))) self) (defmethod description ((self element-class)) " RETURN: A string describing this element. " (format nil "<An instance of ~A>" (class-name (class-of self)))) ;; (defmethod identicalTo ((self ELEMENT-CLASS) (other ELEMENT-CLASS)) ;; " ;; RETURN: Whether self and other are the same element. (eq self other) ;; " ;; (eq self other) ;; ) (defmethod property-names ((self element-class)) " RETURN: The list of property names (keys) of properties of this element. " (do ((ps (properties self) (cddr ps)) (res '())) ((null ps) res) (push (car ps) res))) (defmethod set-property ((self element-class) (prop-name symbol) prop-value) " POST: (eql (GET-PROPERTY self prop-name) prop-value) " (setf (slot-value self 'properties) (plist-put (properties self) prop-name prop-value))) (defmethod get-property ((self element-class) (prop-name symbol)) " RETURN: the property `prop-name' of this element. " (plist-get (properties self) prop-name)) (defmethod delete-property ((self element-class) (prop-name symbol)) " DO: Remove the property named `prop-name' from the property list of this element. " (setf (slot-value self 'properties) (plist-remove (properties self) prop-name))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defclass set-class (element-class) ((elements :initform nil :initarg :elements :accessor elements :type list :documentation "The list of elements in this set.")) (:documentation "A set of elements.")) (defmethod description ((self set-class)) " RETURN: A string describing this element. " (format nil "<An instance of ~A with ~D elements>" (class-name (class-of self)) (cardinal self))) (defmethod cardinal ((self set-class)) " RETURN: The number of elements in this set. " (length (elements self))) (defmethod contains-element ((self set-class) (anelement element-class)) " RETURN: Whether this set contains anElement. " ;; (let ((elem-list (elements self)) ;; (result nil)) ;; (loop :while elem-list :do ;; (when (eq anElement (car elem-list)) ;; (setq result t) ;; (setq elem-list nil)) ;; (setq elem-list (cdr elem-list))) ;; result) (member anelement (elements self))) (defmethod add-element ((self set-class) (newelement element-class)) " PRE: already_in = (CONTAINS-ELEMENT self newElement), old_CARDINAL = (CARDINAL self) POST: already_in ==> (CARDINAL self) == old_CARDINAL (not already_in) ==> (CARDINAL self) == (1+ old_CARDINAL) (CONTAINS-ELEMENT self newElement) " (when (not (contains-element self newelement)) (setf (slot-value self 'elements) (cons newelement (elements self))))) (defmethod add-elements ((self set-class) newelementlist) " DO: Add each element of the newElementList to this set. " (dolist (newelement newelementlist) (add-element self newelement))) (defmethod remove-element ((self set-class) (oldelement element-class)) " PRE: already_in = (CONTAINS-ELEMENT self newElement), old_CARDINAL = (CARDINAL self) POST: already_in ==> (CARDINAL self) == (1- old_CARDINAL), (not (CONTAINS-ELEMENT self oldElement)) (not already_in) ==> (CARDINAL self) == old_CARDINAL " (setf (slot-value self 'elements) (delete oldelement (elements self)))) (defmethod perform-with-elements ((self set-class) lambda-body) " DO: calls lambda-body with each element in the set. NOTE: lambda-body must not change this set. " (mapc lambda-body (elements self))) (defmethod map-elements (result-type (self set-class) lambda-body) " RETURN: the list of results returned by lambda-body called with each element. NOTE: lambda-body must not change this set. " (map result-type lambda-body (elements self))) (defmethod select-elements ((self set-class) select-lambda) " RETURN: A list of elements for which select-lambda returned true. " (let ((result nil)) (mapc (lambda (elem) (when (funcall select-lambda elem) (push elem result))) (elements self)) result)) (defmethod element-list ((self set-class)) " RETURN: A new list of the elements in self. " (map 'list (function identity) (elements self))) (defmethod find-elements-with-property ((self set-class) (property symbol) value) " RETURN: A list of elements that have as property PROPERTY the value VALUE. " (select-elements self (lambda (elem) (let ((pval (get-property elem property))) (and pval (equal pval value)))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defgeneric index (set) (:documentation "A hashtable used to index the elements in this set.")) (defclass hashed-set-class (set-class) ((index :initform (lambda () (make-hash-table :test 'eq)) :initarg :index :accessor index :type hash-table :documentation "A hashtable used to index the elements in this set.")) (:documentation "This is a specialized kind of set that maintains a hashtable index of its elements to be able to retrieve them rapidly.")) (defmethod contains-element ((self hashed-set-class) (anelement element-class)) " RETURN: Whether this set contains anElement. " (gethash anelement (index self))) (defmethod add-element ((self hashed-set-class) (newelement element-class)) " PRE: already_in = (CONTAINS-ELEMENT self newElement), old_CARDINAL = (CARDINAL self) POST: already_in ==> (CARDINAL self) == old_CARDINAL (not already_in) ==> (CARDINAL self) == (1+ old_CARDINAL) (CONTAINS-ELEMENT self newElement) " (call-next-method) (setf (gethash newelement (index self)) newelement)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defclass edge-class (element-class) ((tag :initform nil :initarg :tag :documentation "Reserved for the client.")) (:documentation "An abstract edge.")) (defmethod description ((self edge-class)) " RETURN: A string describing this element. " (let ((nodes (nodes self))) (format nil "<A ~A between { ~A and ~A }>" (class-name (class-of self)) (description (car nodes)) (description (cdr nodes))))) (defgeneric nodes (self) (:documentation " RETURN: A list of NODES. For a GRAPH, it would be the nodes of the graph. For an edge, it would be the two nodes of the edge in no specific order. (Subclasses implementing directed edges should add specific methods to get the `from' and the `to' NODES).")) (defgeneric is-between-nodes (self nodea nodeb) (:documentation " RETURN: Whether this edge is between `nodeA' and `nodeB'. If this edge is directed then `nodeA' is compared to the from node and `nodeB' is compared to the to node, otherwise, the node order is not important.")) (defgeneric successor-of (self node) (:documentation " RETURN: If node is a node of the edge, then return its successor or nil. That is, for an undirected edge e, (and (eq (SUCCESSOR-OF e (car (NODES e))) (cdr (NODES e))) (eq (SUCCESSOR-OF e (cdr (NODES e))) (car (NODES e))) ) while for a directed edge d: (xor (eq (SUCCESSOR-OF e (car (NODES e))) (cdr (NODES e))) (eq (SUCCESSOR-OF e (cdr (NODES e))) (car (NODES e))) )")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defgeneric weight (edge) (:documentation "The weight of the edge.")) (defclass weight-mixin-class () ((weight :initform 1 :initarg :weight :accessor weight :type number :documentation "The weight of the edge.")) (:documentation "This is a mixin for the subclasses of EDGE-CLASS to add a weight to the edge.")) (defmethod set-weight ((self weight-mixin-class) (newweight integer)) " POST: (equal (weight self) newWeight) " (setf (slot-value self 'weight) newweight)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun node-list-p (item) " RETURN: Whether `item' is a list of two objects kind of ELEMENT-CLASS. " (and (listp item) (null (cddr item)) (typep (first item) 'element-class) (typep (second item) 'element-class))) (defclass undirected-edge-class (edge-class) ((nodes :initarg :nodes :accessor nodes :type (satisfies node-list-p) :documentation "A cons containing the two unordered NODES of the edge." )) (:documentation "An undirected edge.")) (defmethod copy ((self undirected-edge-class) &key &allow-other-keys) " RETURN: A COPY of this edge (only with same NODES). " (make-instance 'undirected-edge-class :nodes (nodes self))) (defun identical-nodes (nodes-cons-a nodes-cons-b) " RETURN: Whether NODES-cons-a and NODES-cons-b contain the same NODES. " (or (and (eq (car nodes-cons-a) (car nodes-cons-b)) (eq (cdr nodes-cons-a) (cdr nodes-cons-b))) (and (eq (car nodes-cons-a) (cdr nodes-cons-b)) (eq (cdr nodes-cons-a) (car nodes-cons-b))))) ;; (defmethod identicalTo ((self UNDIRECTED-EDGE-CLASS) (other PjBElement)) ;; " ;; RETURN: Whether self and other are the same undirected edge. ;; NOTE: We only compare the NODES linked by this edge, ;; not any other attribute ;; that could be added by a subclass... ;; " ;; (and (is-kind-of other UNDIRECTED-EDGE-CLASS) ;; (IDENTICAL-NODES (NODES self) (NODES other))) ;; ) (defmethod is-between-nodes ((self edge-class) (nodea element-class) (nodeb element-class)) " RETURN: Whether this edge is between `nodeA' and `nodeB'. The node order is not important. " (identical-nodes (nodes self) (cons nodea nodeb))) (defmethod successor-of ((self undirected-edge-class) (node element-class)) " RETURN: If node is a node of this edge, then the other node, else nil. " (let ( (nodes (nodes self)) ) (cond ((eq node (car nodes)) (cdr nodes)) ((eq node (cdr nodes)) (car nodes)) (t nil)))) (defmethod set-nodes ((self undirected-edge-class) (nodea element-class) (nodeb element-class)) " DO: set the NODES of this edge. " (setf (slot-value self 'nodes) (cons nodea nodeb))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defclass weighted-undirected-edge-class (undirected-edge-class weight-mixin-class) () (:documentation "A weighted, undirected edge.")) (defmethod description ((self weighted-undirected-edge-class)) " RETURN: A string describing this element. " (let ((nodes (nodes self))) (format nil "<A ~A between { ~A and ~A } weighting ~A>" (class-name (class-of self)) (description (car nodes)) (description (cdr nodes)) (weight self)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defgeneric from (edge) (:documentation "The `from' node of this edge.")) (defgeneric to (edge) (:documentation "The `to' node of this edge.")) (defclass directed-edge-class (edge-class) ((from :initarg :from :accessor from :type element-class :documentation "The `from' node of this edge." ) (to :initarg :to :accessor to :type element-class :documentation "The `to' node of this edge." )) (:documentation "An directed edge.")) (defmethod copy ((self directed-edge-class) &key &allow-other-keys) " RETURN: A COPY of this edge (only with same NODES). " (make-instance (class-of self) :from (from self) :to (to self))) (defmethod nodes ((self directed-edge-class)) " RETURN: A list containing the two NODES of the edge in no particular order. NOTE: Use the accessor methods `from' and `to' to get the wanted node. " (cons (from self) (to self))) ;; (defmethod identicalTo ((self DIRECTED-EDGE-CLASS) (other PjBElement)) ;; " ;; RETURN: Whether self and other are the same directed edge. ;; NOTE: We only compare the NODES linked by this edge, ;; not any other attribute ;; that could be added by a subclass... ;; " ;; (and (is-kind-of other DIRECTED-EDGE-CLASS) ;; (identicalTo (from self) (from other)) ;; (identicalTo (to self) (to other)) ) ;; ) (defmethod is-between-nodes ((self directed-edge-class) (nodea element-class) (nodeb element-class)) " RETURN: Whether this edge is between `nodeA' and `nodeB'. `nodeA' is compared to the from node and `nodeB' is compared to the to node. " (and (eq (from self) nodea) (eq (to self) nodeb))) (defmethod successor-of ((self directed-edge-class) (node element-class)) " RETURN: If node is the `from' node of this edge, then the `to' node, else nil. " (if (eq node (from self)) (to self) nil)) (defmethod set-nodes ((self directed-edge-class) (newfrom element-class) (newto element-class)) " DO: set the NODES of this edge. " (setf (slot-value self 'from) newfrom) (setf (slot-value self 'to) newto)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defclass weighted-directed-edge-class (directed-edge-class weight-mixin-class) () (:documentation "A weighted, directed edge.")) (defmethod description ((self weighted-directed-edge-class)) " RETURN: A string describing this element. " (let ((nodes (nodes self))) (format nil "<A ~A between { ~A and ~A } weighting ~A>" (class-name (class-of self)) (description (car nodes)) (description (cdr nodes)) (weight self)))) (defmethod copy ((self weighted-directed-edge-class) &key &allow-other-keys) " RETURN: A COPY of this edge (only with same NODES). " (make-instance (class-of self) :weight (weight self) :from (from self) :to (to self))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun subclass-of-edge-p (item) " RETURN: Whether `item' is a subclass of EDGE-CLASS (not EDGE-CLASS itself). " (subtypep item 'edge-class)) (defgeneric edges (graph) (:documentation "The edges of the graph.")) (defgeneric edge-class (graph) (:documentation "The class of edges of the graph.")) (defclass graph-class (element-class) ((nodes :initarg :nodes :accessor nodes :type set-class :documentation "The set of NODES in this graph.") (edges :initarg :edges :accessor edges :type set-class :documentation "The set of edges in this graph.") (edge-class :initform 'undirected-edge-class :initarg :edge-class :accessor edge-class ;;:type (satisfies SUBCLASS-OF-EDGE-P) :documentation "The class used to make new edges in this graph. Default is UNDIRECTED-EDGE-CLASS.")) (:documentation "A graph of elements. By default, it's a undirected graph.")) (defmethod initialize-instance :after ((self graph-class) &rest initargs &key &allow-other-keys) " DO: Initalize the instance nodes and edges. " (declare (ignore initargs)) (unless (slot-boundp self 'nodes) (setf (nodes self) (make-instance 'set-class))) (if (slot-boundp self 'edges) (progn ;; todo: we should check that all edges are between two nodes of the graph. ) (setf (edges self) (make-instance 'set-class))) self) (defmethod description ((self graph-class)) " RETURN: A string describing this element. " (format nil "<A ~A with ~D NODES and ~D edges>" (class-name (class-of self)) (cardinal (nodes self)) (cardinal (edges self)))) (defmethod add-node ((self graph-class) (newnode element-class)) " DO: Add newNode to the set of NODES of this graph. " (add-element (nodes self) newnode)) (defmethod add-nodes ((self graph-class) newnodelist) " DO: Add a list of new NODES to the set of NODES of this graph. " (add-elements (nodes self) newnodelist)) (defmethod remove-node ((self graph-class) (oldnode element-class)) " DO: Remove the oldNode from the graph. This implies removing all the edges adjacent to the node too. " (when (contains-element (nodes self) oldnode) (remove-edges self (select-elements (edges self) (lambda (edge) (or (eq oldnode (from edge)) (eq oldnode (to edge)))))))) (defmethod remove-nodes ((self graph-class) oldnodelist) " DO: Remove all the NODES of the oldNodeList from this graph. " (dolist (node oldnodelist) (remove-node self node))) (defmethod add-edge ((self graph-class) (newedge edge-class)) " PRE: (and (CONTAINS-ELEMENT (NODES self) (nth 0 (NODES newEdge))) (CONTAINS-ELEMENT (NODES self) (nth 1 (NODES newEdge)))) DO: Add a new edge to this graph. " (when (and (contains-element (nodes self) (car (nodes newedge))) (contains-element (nodes self) (cdr (nodes newedge)))) (add-element (edges self) newedge))) (defmethod add-edge-between-nodes ((self graph-class) (nodea element-class) (nodeb element-class)) " DO: Create a new edge (of class edge-class) between `nodeA' and `nodeB'. and add it to this graph. If the edge is directed, then `nodeA' is the `from' node and `nodeB' the `to' node. " (let ((edge (make-instance (edge-class self)))) (set-nodes edge nodea nodeb) (add-edge self edge))) (defmethod remove-edge ((self graph-class) (oldedge edge-class)) " DO: Remove the `oldEdge' from this graph. " (remove-element (edges self) oldedge)) (defmethod remove-edges ((self graph-class) edge-list) " DO: Remove all the edges in edge-list from this graph. " (dolist (edge edge-list) (remove-edge self edge))) (defmethod remove-edges-between-nodes ((self graph-class) (nodea element-class) (nodeb element-class)) " DO: Remove all edges between `nodeA' and `nodeB'. " (mapc (lambda (edge) (remove-edge self edge)) (edges-between-nodes self nodea nodeb))) (defmethod edges-between-nodes ((self graph-class) (nodea element-class) (nodeb element-class)) " RETURN: A list of edges existing between the `nodeA' and `nodeB'. If the graph is directed then `nodeA' corresponds to the from node and `nodeB' corresponds to the to node. " (select-elements (edges self) (lambda (edge) (is-between-nodes edge nodea nodeb)))) (defmethod directed-edges-between-nodes ((self graph-class) (fromnode element-class) (tonode element-class)) " RETURN: A list of edges existing from the `fromNode' and to the `toNode'. " (select-elements (edges self) (lambda (edge) (eq (successor-of edge fromnode) tonode)))) (defmethod directed-edges-from-node ((self graph-class) (fromnode element-class)) " PRE: edge-class is-subclass-of DIRECTED-EDGE-CLASS or edge-class eq DIRECTED-EDGE-CLASS. RETURN: A list of edges existing from the `fromNode'. " (unless (subtypep (edge-class self) 'directed-edge-class) (error "This graph is not a directed graph. Can't apply ~ DIRECTED-EDGES-FROM-NODE.")) (select-elements (edges self) (lambda (edge) (eq (from edge) fromnode)))) (defmethod successor-nodes ((self graph-class) (node element-class)) " RETURN: The list of successors NODES of the given node in this graph. NOTE: For undirected graphs, it's the same as ADJACENT-NODES. " (let ((result nil)) (perform-with-elements (edges self) (lambda (edge) (let ( (succ (successor-of edge node)) ) (when succ (unless (member succ result) (push succ result)))))) result)) (defmethod adjacent-nodes ((self graph-class) (node element-class)) " RETURN: The list of NODES adjacent to the given node in this graph. NOTE: For directed graphs, an adjacent node is either a predecessor or a successors of the node. " (let ((result nil)) (perform-with-elements (edges self) (lambda (edge) (let ((ns (nodes edge))) (cond ((eq node (car ns)) (unless (member (cdr ns) result) (push (cdr ns) result))) ((eq node (cdr ns)) (unless (member (car ns) result) (push (car ns) result))))))) result)) (defmethod flow-distance-from-node ((self graph-class) (startnode element-class) (prop-name symbol)) " DO: Compute for each node in this graph the distance from the startNode, and store it as a property named prop-name. NOTE: If the graph is not connex, then some distances will be nil, meaning infinity. " (perform-with-elements (nodes self) (lambda (node) (set-property node prop-name nil))) (when (contains-element (nodes self) startnode) (set-property startnode prop-name 0) (let ( (cur-nodes (list startnode)) cur-node distance suc-nodes suc-dist ) (loop :while cur-nodes :do (setf cur-node (car cur-nodes) cur-nodes (cdr cur-nodes) distance (1+ (get-property cur-node prop-name)) suc-nodes (successor-nodes self cur-node)) ;; (not (null distance)) (dolist (suc-node suc-nodes) (setf suc-dist (get-property suc-node prop-name)) (when (or (null suc-dist) (< distance suc-dist)) (set-property suc-node prop-name distance) (unless (member suc-node cur-nodes) (push suc-node cur-nodes)))))))) (defmethod walk-from-node ((self graph-class) (startnode element-class) lambda-body) " DO: Walk the graph starting form startNode, calling lambda-body with each node as argument. " (let ((stamp (gensym "walked-"))) (when (contains-element (nodes self) startnode) (perform-with-elements (nodes self) (lambda (node) (set-property node stamp nil))) (let ( (cur-nodes (list startnode)) cur-node suc-nodes ) (loop :while cur-nodes :do (setq cur-node (car cur-nodes) cur-nodes (cdr cur-nodes)) (set-property cur-node stamp t) (funcall lambda-body cur-node) (setq suc-nodes (successor-nodes self cur-node)) (dolist (suc-node suc-nodes) (unless (get-property suc-node stamp) (push suc-node cur-nodes)) ))) (perform-with-elements (nodes self) (lambda (node) (delete-property node stamp)))))) (defmethod walk-edges-from-node ((self graph-class) (startnode element-class) lambda-body) " DO: Walk the graph starting form startNode, calling lambda-body with each edges as argument. Since it's the edges that are passed to lambda-body, one node can be \"walked\" several times either as `from' or `to' node or different edges. " (let ((stamp (gensym "walked-"))) (when (contains-element (nodes self) startnode) (perform-with-elements (edges self) (lambda (item) (set-property item stamp nil))) (perform-with-elements (nodes self) (lambda (item) (set-property item stamp nil))) (set-property startnode stamp t) (let ((cur-nodes (list startnode)) cur-node) (loop :while cur-nodes :do (setq cur-node (car cur-nodes) cur-nodes (cdr cur-nodes)) (dolist (edge (directed-edges-from-node self cur-node)) (unless (get-property edge stamp) (set-property edge stamp t) (funcall lambda-body edge) (unless (get-property (to edge) stamp) (set-property (to edge) stamp t) (push (to edge) cur-nodes)))))) (perform-with-elements (edges self) (lambda (item) (delete-property item stamp))) (perform-with-elements (nodes self) (lambda (item) (delete-property item stamp)))))) (defmethod copy ((self graph-class) &key (copy-nodes nil) (copy-edges t) &allow-other-keys) " RETURN: A COPY of this graph. NOTE: By default, the NODES are the same, but the edges are duplicated. The following keys are recognized: :COPY-NODES default: NIL; T ==> COPY-EDGE :COPY-EDGES default: T; NIL ==> (NOT COPY-NODE) The following combination are valid: COPY-NODES COPY-EDGE You get a deep COPY of the graph, where you can change anything independtly from the orginal. (NOT COPY-NODES) COPY-EDGE You get a new graph with new edges, but the same NODES. (NOT COPY-NODES) (NOT COPY-EDGE) You get a new graph with the same edges and the same NODES. But you still can add or remove NODES or edges to make it different from the original graph. " (let (new-nodes new-edges node-hash) (when (and copy-nodes (not copy-edges)) (error "Can't have both COPY-NODES and (NOT COPY-EDGES).")) (unless copy-nodes (setf copy-nodes nil)) (unless (not copy-edges) (setf copy-edges t)) (when (not copy-edges) (setf copy-nodes nil)) (when copy-nodes (setf copy-edges t)) (if copy-nodes (setf node-hash (make-hash-table :test 'eq :size (cardinal (nodes self))) new-nodes (make-instance 'set-class :elements (map-elements 'list (nodes self) (lambda (node) (let ((new-node (copy node))) (setf (gethash node node-hash) new-node) new-node))))) (setf new-nodes (nodes self))) (if copy-edges (setf new-edges (make-instance 'set-class :elements (map-elements 'list (edges self) (lambda (edge) (let ((new-edge (copy edge)) nodes) (when copy-nodes (setq nodes (nodes new-edge)) (set-nodes new-edge (gethash (car nodes) node-hash) (gethash (cdr nodes) node-hash))) new-edge))))) (setf new-edges (edges self))) (make-instance (class-of self) :nodes new-nodes :edges new-edges :edge-class (edge-class self)))) (defmethod find-nodes-with-property ((self graph-class) (property symbol) value) " RETURN: A list of NODES that have as property PROPERTY the value VALUE. " (find-elements-with-property (nodes self) property value)) (defmethod show-graph ((self graph-class)) " DO: Prints a description of the graph on the *STANDARD-OUTPUT*. " (format t "~A {~%" (description self)) (perform-with-elements (nodes self) (lambda (node) (format t " node ~A~%" (description node)))) (perform-with-elements (edges self) (lambda (edge) (format t " edge ~A~%" (description edge)))) (format t "}~%")) ;;;; THE END ;;;;
44,623
Common Lisp
.lisp
1,078
35.115028
103
0.628327
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
e32a86c971ab42910ddc52abcffa80b3bc4ffb7a0d1a1f332cdf35b3c3503172
5,086
[ -1 ]
5,087
symbol.lisp
informatimago_lisp/common-lisp/cesarum/symbol.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: symbol.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Export symbol functions. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2021-06-11 <PJB> Corrected typo in keywordize lambda-list. ;;;; 2018-12-30 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2018 - 2021 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (in-package "COMMON-LISP-USER") (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SYMBOL" (:use "COMMON-LISP") (:export "KEYWORDIZE" "SCAT") (:documentation " This package exports some symbol processing functions. License: AGPL3 Copyright Pascal J. Bourguignon 2018 - 2021 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SYMBOL") (defun scat (&rest string-designators) "Interns the concatenation of the STRING-DESIGNATORS." (intern (apply (function concatenate) 'string (mapcar (function string) string-designators)))) (defun keywordize (&rest string-designators) " RETURN: A new keyword with STRING-DESIGNATOR as name. " (intern (apply (function concatenate) 'string (mapcar (function string) string-designators)) (load-time-value (find-package "KEYWORD")))) ;;;; THE END ;;;;
3,044
Common Lisp
.lisp
73
38.835616
83
0.664411
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
6ab121c0a0b7607bc917f76effc994a53efa98bec81f7c256121dcafd909f768
5,087
[ -1 ]
5,088
simple-test.lisp
informatimago_lisp/common-lisp/cesarum/simple-test.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: simple-test.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Defines a simple test tool. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2015-03-08 <PJB> Added with-debugger-on-failure. ;;;; 2015-01-25 <PJB> Added format-control/arguments to ;;;; progress-failure and macros callint it. ;;;; 2010-12-14 <PJB> Created. ;;;;BUGS ;;;; ;;;; - we should use source-form to parse lambda-list for define-test. ;;;; ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2010 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SIMPLE-TEST" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.LISP-SEXP.SOURCE-FORM" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.TIME") #+mocl (:shadowing-import-from "COM.INFORMATIMAGO.MOCL.KLUDGES.MISSING" "*TRACE-OUTPUT*" "*LOAD-VERBOSE*" "*LOAD-PRINT*" "ARRAY-DISPLACEMENT" "CHANGE-CLASS" "COMPILE" "COMPLEX" "ENSURE-DIRECTORIES-EXIST" "FILE-WRITE-DATE" "INVOKE-DEBUGGER" "*DEBUGGER-HOOK*" "LOAD" "LOGICAL-PATHNAME-TRANSLATIONS" "MACHINE-INSTANCE" "MACHINE-VERSION" "NSET-DIFFERENCE" "RENAME-FILE" "SUBSTITUTE-IF" "TRANSLATE-LOGICAL-PATHNAME") (:export "*DEBUG-ON-ERROR*" "WITH-DEBUGGER-ON-ERROR" "*DEBUG-ON-FAILURE*" "WITH-DEBUGGER-ON-FAILURE" "DEFINE-TEST" "CHECK" "ASSERT-TRUE" "ASSERT-FALSE" "EXPECT-CONDITION" "TEST-MESSAGE" "*TEST-OUTPUT*" "*VERBOSE-TALLY*" "*VERBOSE-PROGRESS*" "TESTING" "SLOW-TEST" "PROGRESS-START" "PROGRESS-SUCCESS" "PROGRESS-FAILURE-MESSAGE" "PROGRESS-FAILURE" "PROGRESS-TALLY" ;; deprecated: "TEST") (:documentation " This package defines a simple test tool. (define-test <test-name> (<test-arguments>) (check = (fact 3) 6) (assert-true <expr> (<place>…) \"message ~A\" <arguments>…) (assert-false <expr> (<place>…) \"message ~A\" <arguments>…) (if <test> (progress-success) (progress-failure-message '<expr> \"message ~A\" <arguments>…))) Tests can be run in the scope of a WITH-DEBUGGER-ON-ERROR or a WITH-DEBUGGER-ON-FAILURE macro, to enter the debugger when an error is signaled during the test, or if a test fails. This may be useful to debug the test or the failure. (with-debugger-on-failure (test/all)) ;; single shot testing: (testing (check = (fact 3) 6)) License: AGPL3 Copyright Pascal J. Bourguignon 2010 - 2015 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SIMPLE-TEST") (defvar *debug-on-error* nil "Whether an error in a test should go to the debugger.") (defvar *debug-on-failure* nil "Whether a failure in a test should go to the debugger.") (defvar *success-count* 0 "The total number of successful tests.") (defvar *failure-count* 0 "The total number of failed tests.") (defvar *verbose-tally* t "Whether to print the number of successful, failed and performed tests.") (defvar *verbose-progress* nil "Whether to display dots or exclamation points while testing.") (defvar *test-output* (make-synonym-stream '*standard-output*)) ;; Private: (defvar *last-success-p* nil) (defvar *current-test-name* nil) (defvar *current-test-parameters* nil) (defvar *current-test-printed-p* nil) (defvar *report-string* "") (defparameter *cr* #\return) (defun progress-start () "Resets the progress counters (success/failure counts)." (setf *success-count* 0 *failure-count* 0 *last-success-p* nil *report-string* (make-array 8 :element-type 'character :adjustable t :fill-pointer 0)) (values)) (defun verbose (default) "Returns whether the test must be verbose. We conjoin the DEFAULT parameter with *LOAD-VERBOSE*, ASDF-VERBOSE* and QUICKLOAD-VERBOSE* when available." (and default (or (not *load-pathname*) *load-verbose* (and (find-package "ASDF") (find-symbol "*ASDF-VERBOSE*" "ASDF") (symbol-value (find-symbol "*ASDF-VERBOSE*" "ASDF"))) (and (find-package "QUICKLISP") (find-symbol "*QUICKLOAD-VERBOSE*" "QUICKLISP-CLIENT") (symbol-value (find-symbol "*QUICKLOAD-VERBOSE*" "QUICKLISP-CLIENT")))))) (defun test-message (format-control &rest format-arguments) "Formats the parameters on the *TEST-OUTPUT* when running the test verbosely cf. VERBOSE, *VERBOSE-PROGRESS*" (when (verbose t) (format *test-output* "~&~?~%" format-control format-arguments) (force-output *test-output*))) (defun progress-report (new-last-succcess-p) "Prints on *TEST-OUTPUT* the current progress report." (setf *last-success-p* new-last-succcess-p) (when (verbose *verbose-progress*) (if *last-success-p* (format *test-output* "~A" (aref *report-string* (1- (length *report-string*)))) (format *test-output* "~&~A" *report-string*)) (force-output *test-output*)) (values)) (defun progress-success () "Indicate one more successful test." (incf *success-count*) (vector-push-extend #\. *report-string*) (progress-report t)) (defun current-test-identification (&optional max-length) "Returns the identification of the current test (over a maximum length of MAX-LENGTH)" (let ((*print-circle* nil)) (if (or (null max-length) (null *current-test-parameters*)) (format nil "(~{~S~^ ~})" (cons *current-test-name* *current-test-parameters*)) (let* ((items (mapcar (lambda (parameter) (let ((label (let ((*package* (if (and (symbolp parameter) (symbol-package parameter)) (symbol-package parameter) *package*))) (format nil "~S" parameter)))) (list (length label) label))) (cons *current-test-name* *current-test-parameters*))) (idlength (+ 1 (length items) (reduce (function +) items :key (function first)))) (candidates (sort (butlast (loop :for cell :on items :collect cell)) (function >) :key (function caadr)))) (loop :while (and candidates (< max-length idlength)) :do (progn (decf idlength (1- (caadar candidates))) (setf (car (cdadar candidates)) "…") (pop candidates)) :finally (return (format nil "(~{~A~^ ~})" (mapcar (function second) items)))))))) (defun test/current-test-identification () (assert (equal (let ((*current-test-name* 'hello-world) (*current-test-parameters* '())) (current-test-identification nil)) "(hello-world)")) (assert (equal (let ((*current-test-name* 'hello-world) (*current-test-parameters* '((1 2 3 4) "howdy doo dabadaboo" #(a b c d e f)))) (current-test-identification nil)) "(hello-world (1 2 3 4) \"howdy doo dabadaboo\" #(a b c d e f))")) (assert (equal (let ((*current-test-name* 'hello-world) (*current-test-parameters* '((1 2 3 4) "howdy doo dabadaboo" #(a b c d e f)))) (current-test-identification 1)) "(hello-world … … …)")) (assert (equal (let ((*current-test-name* 'test/non-empty-vector-with-too-little-data) (*current-test-parameters* '())) (current-test-identification 20)) "(test/non-empty-vector-with-too-little-data)")) :success) (define-condition test-failure () ((expression :initarg :expression :reader test-failure-expression) (message :initarg :message :initform "" :reader test-failure-message) (arguments :initarg :arguments :initform '() :reader test-failure-arguments)) (:report (lambda (condition stream) (format stream "Failure on expression: ~S~%~?" (test-failure-expression condition) (test-failure-message condition) (test-failure-arguments condition))))) (defun progress-failure-message (expression message &rest arguments) "Indicates one more failed test, with a formatted MESSAGE and ARGUMENTS." (incf *failure-count*) (vector-push-extend #\! *report-string*) (unless *current-test-printed-p* (setf *current-test-printed-p* t) (format *test-output* "~&~A" (current-test-identification))) (format *test-output* "~&Failure: expression: ~S~@ ~&~?~%" expression message arguments) (force-output *test-output*) (progress-report nil) (when *debug-on-failure* (invoke-debugger (make-condition 'test-failure :expression expression :message message :arguments arguments)))) (defun progress-failure (compare expression expected-result result &optional places format-control &rest format-arguments) "Indicates one more failed test, reporting the expression, the expected and actual results, and the relevant places, in addition to a formatted message." (progress-failure-message expression "~& evaluates to: ~S~@ ~& which is not ~A~@ ~& to the expected result: ~S~@ ~{~&~23A: ~S~}~@[~@ ~&~?~]~&" result compare expected-result places format-control format-arguments)) (defun progress-tally (success-count failure-count) "When testing verbosely, prints the test tally, SUCCESS-COUNT and FAILURE-COUNT." (when (verbose *verbose-tally*) (let ((name-max-length 40)) (flet ((write-tally (name) (format *test-output* "~&~VA~@[~%~0@*~V<~>~3@*~]~ ~9D test~:*~P,~:*~[~; ~;~]~ ~8D success~:*~[es~;~:;es~]~ ~:[,~2:*~[~; ~;~]~*~8D failure~:*~P~;~].~%" name-max-length name (< name-max-length (length name)) (+ success-count failure-count) success-count (zerop failure-count) failure-count))) (write-tally (current-test-identification name-max-length)) (force-output *test-output*) ;; (let* ((test-name (current-test-identification name-max-length)) ;; (data (genline "")) ;; (nlen (length test-name))) ;; (format *test-output* "~&~A~%" ;; (if (and (< nlen (+ name-max-length 4)) (char= #\space (aref data nlen))) ;; (progn ;; (replace data test-name) ;; data) ;; (genline (concatenate 'string (subseq test-name 0 43) "…")))) ;; (force-output *test-output*)) ))) (values)) (defmacro assert-true (expression &optional places format-control &rest format-arguments) "Evaluates a test EXPRESSION and check it returns true. EXAMPLE: (assert-true (= 2 (+ 1 1)))) " (let ((vresult (gensym "RESULT-"))) `(let ((,vresult (if *debug-on-error* (handler-bind ((error (function invoke-debugger))) ,expression) (handler-case ,expression (error (err) (list 'error (princ-to-string err))))))) (if ,vresult (progress-success) (progress-failure 'equivalent ',expression 't ,vresult (list ,@(mapcan (lambda (place) `(',place ,place)) places)) ,format-control ,@format-arguments))))) (defmacro assert-false (expression &optional places format-control &rest format-arguments) "Evaluates a test EXPRESSION and check it returns NIL EXAMPLE: (assert-false (/= 2 (+ 1 1)))) " `(assert-true (not ,expression) ,places ,format-control ,@format-arguments)) (defmacro expect-condition (condition-class expression) "Evaluates a test EXPRESSION and check that it signals a condition of the specified CONDITION-CLASS. CONDITION-CLASS: evaluated to a class name. EXAMPLE: (expect-condition 'division-by-zero (/ 1 0)) " (let ((body (gensym)) (vcondition-class (gensym))) `(let ((,vcondition-class ,condition-class)) (flet ((,body () ,expression (progress-failure-message ',expression "Didn't signal the expected ~S condition." ,vcondition-class))) (if *debug-on-error* (block expect (handler-bind ((error (lambda (condition) (if (typep condition ,vcondition-class) (progn (progress-success) (return-from expect)) (invoke-debugger condition))))) (,body))) (handler-case (,body) (error (condition) (if (typep condition ,vcondition-class) (progress-success) (progress-failure-message ',expression "Signaled an unexpected ~S condition instead of ~S." condition ,vcondition-class))))))))) (defmacro test (compare expression expected &optional places format-control &rest format-arguments) "Deprecated, use CHECK instead." (warn "~S is deprecated, use CHECK instead." 'test) `(check ,compare ,expression ,expected ,places ,format-control ,@format-arguments)) (defmacro check (compare expression expected &optional places format-control &rest format-arguments) "Evaluates a test EXPRESSION and compare the result with EXPECTED (evaluated) using the COMPARE operator. EXAMPLE: (test equal (list 1 2 3) '(1 2 3)) " (let ((vresult (gensym "RESULT-")) (vexpected (gensym "EXPECTED-"))) `(let ((,vresult (if *debug-on-error* (handler-bind ((error (function invoke-debugger))) ,expression) (handler-case ,expression (error (err) (list 'error (princ-to-string err)))))) (,vexpected ,expected)) (if (,compare ,vresult ,vexpected) (progress-success) (progress-failure ',compare ',expression ,vexpected ,vresult (list ,@(mapcan (lambda (place) `(',place ,place)) places)) ,format-control ,@format-arguments))))) (defmacro testing (&body body) "Evaluates the body while tallying test successes and failures. The functions PROGRESS-SUCCESS, PROGRESS-FAILURE and PROGRESS-FAILURE-MESSAGE (eg. thru the macros ASSERT-TRUE, ASSERT-FALSE, EXPECT-CONDITION and TEST), should only be called in the dynamic context established by this TESTING macro. cf. DEFINE-TEST. " `(multiple-value-bind (successes failures) (let ((*success-count* 0) (*failure-count* 0) (*current-test-printed-p* nil)) (progress-start) (progn ,@body) (progress-tally *success-count* *failure-count*) (values *success-count* *failure-count*)) (incf *success-count* successes) (incf *failure-count* failures) (if (zerop failures) :success :failure))) (defmacro define-test (name parameters &body body) "Like DEFUN, but wraps the body in test reporting boilerplate. cf. TESTING." (let ((mandatory (loop :for param :in parameters :until (member param lambda-list-keywords) :collect param))) (multiple-value-bind (docstrings declarations forms) (parse-body :lambda body) `(defun ,name ,parameters ,@docstrings ,@declarations (let ((*current-test-name* ',name) (*current-test-parameters* (list ,@mandatory))) (testing ,@forms)))))) (defmacro with-debugger-on-error (&body body) "When running tests in the dynamic context established by this macro, errors will invoke the debugger instead of failing the test immediately." `(let ((*debug-on-error* t)) ,@body)) (defmacro with-debugger-on-failure (&body body) "When running tests in the dynamic context established by this macro, failures will invoke the debugger instead of failing the test immediately." `(let ((*debug-on-failure* t)) ,@body)) (defun slow-test* (expected-time thunk) (let ((result)) (test-message "Next test should take about ~A." (format-time expected-time)) (let ((time (chrono-real-time (setf result (funcall thunk))))) (test-message "Test took ~A" (format-time time))) result)) (defmacro slow-test (expected-time &body body) `(slow-test* ,expected-time (lambda () ,@body))) #| <!-- -*- mode:xml; coding:utf-8 -*- --> <?xml version="1.0" encoding="UTF-8"?> <!-- a description of the JUnit XML format and how Jenkins parses it. See also junit.xsd --> <!-- if only a single testsuite element is present, the testsuites element can be omitted. All attributes are optional. Not supported by maven surefire. --> <testsuites disabled="" <!-- total number of disabled tests from all testsuites. --> errors="" <!-- total number of tests with error result from all testsuites. --> failures="" <!-- total number of failed tests from all testsuites. --> name="" tests="" <!-- total number of tests from all testsuites. Some software may expect to only see the number of successful tests from all testsuites though. --> time="" <!-- time in seconds to execute all test suites. --> > <!-- testsuite can appear multiple times, if contained in a testsuites element. It can also be the root element. --> <testsuite name="" <!-- Full (class) name of the test for non-aggregated testsuite documents. Class name without the package for aggregated testsuites documents. Required --> tests="" <!-- The total number of tests in the suite, required. --> disabled="" <!-- the total number of disabled tests in the suite. optional. not supported by maven surefire. --> errors="" <!-- The total number of tests in the suite that errored. An errored test is one that had an unanticipated problem, for example an unchecked throwable; or a problem with the implementation of the test. optional --> failures="" <!-- The total number of tests in the suite that failed. A failure is a test which the code has explicitly failed by using the mechanisms for that purpose. e.g., via an assertEquals. optional --> hostname="" <!-- Host on which the tests were executed. 'localhost' should be used if the hostname cannot be determined. optional. not supported by maven surefire. --> id="" <!-- Starts at 0 for the first testsuite and is incremented by 1 for each following testsuite. optional. not supported by maven surefire. --> package="" <!-- Derived from testsuite/@name in the non-aggregated documents. optional. not supported by maven surefire. --> skipped="" <!-- The total number of skipped tests. optional --> time="" <!-- Time taken (in seconds) to execute the tests in the suite. optional --> timestamp="" <!-- when the test was executed in ISO 8601 format (2014-01-21T16:17:18). Timezone may not be specified. optional. not supported by maven surefire. --> > <!-- Properties (e.g., environment settings) set during test execution. The properties element can appear 0 or once. --> <properties> <!-- property can appear multiple times. The name and value attributres are required. --> <property name="" value=""/> </properties> <!-- testcase can appear multiple times, see /testsuites/testsuite@tests --> <testcase name="" <!-- Name of the test method, required. --> assertions="" <!-- number of assertions in the test case. optional. not supported by maven surefire. --> classname="" <!-- Full class name for the class the test method is in. required --> status="" <!-- optional. not supported by maven surefire. --> time="" <!-- Time taken (in seconds) to execute the test. optional --> > <!-- If the test was not executed or failed, you can specify one of the skipped, error or failure elements. --> <!-- skipped can appear 0 or once. optional --> <skipped message="" <!-- message/description string why the test case was skipped. optional --> /> <!-- error indicates that the test errored. An errored test had an unanticipated problem. For example an unchecked throwable (exception), crash or a problem with the implementation of the test. Contains as a text node relevant data for the error, for example a stack trace. optional --> <error message="" <!-- The error message. e.g., if a java exception is thrown, the return value of getMessage() --> type="" <!-- The type of error that occured. e.g., if a java execption is thrown the full class name of the exception. --> >error description</error> <!-- failure indicates that the test failed. A failure is a condition which the code has explicitly failed by using the mechanisms for that purpose. For example via an assertEquals. Contains as a text node relevant data for the failure, e.g., a stack trace. optional --> <failure message="" <!-- The message specified in the assert. --> type="" <!-- The type of the assert. --> >failure description</failure> <!-- Data that was written to standard out while the test was executed. optional --> <system-out>STDOUT text</system-out> <!-- Data that was written to standard error while the test was executed. optional --> <system-err>STDERR text</system-err> </testcase> <!-- Data that was written to standard out while the test suite was executed. optional --> <system-out>STDOUT text</system-out> <!-- Data that was written to standard error while the test suite was executed. optional --> <system-err>STDERR text</system-err> </testsuite> </testsuites> <testsuites id="id.of.scan" name="label of scan" tests="total-number-of-tests" failures="total-number-of-failures" time="duration"> <testsuite id="id.of.provider" name="name of provider" tests="number-of-tests" failures="number-of-failures" time="duration"> <testcase id="id.of.test" name="name of test" time="duration"> <failure message="title" type="severity"> severity = INFO WARNING ERROR - text of the rule and severity - analysis provider and the analysis category - source code File:line number </failure> </testcase> </testsuite> </testsuites> <?xml version="1.0" encoding="UTF-8" ?> <testsuites id="20140612_170519" name="New_configuration (14/06/12 17:05:19)" tests="225" failures="1262" time="0.001"> <testsuite id="codereview.cobol.analysisProvider" name="COBOL Code Review" tests="45" failures="17" time="0.001"> <testcase id="codereview.cobol.rules.ProgramIdRule" name="Use a program name that matches the source file name" time="0.001"> <failure message="PROGRAM.cbl:2 Use a program name that matches the source file name" type="WARNING"> WARNING: Use a program name that matches the source file name Category: COBOL Code Review – Naming Conventions File: /project/PROGRAM.cbl Line: 2 </failure> </testcase> </testsuite> </testsuites> |# ;;;; THE END ;;;;
27,066
Common Lisp
.lisp
519
41.622351
181
0.59046
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
36bbbbad337fab610ab5563cf797ab644a24f6b9abe2bea91d261cf54cce9849
5,088
[ -1 ]
5,089
dll.lisp
informatimago_lisp/common-lisp/cesarum/dll.lisp
;;;; -*- coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: dll.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; A doubly-linked list. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2011-06-22 <PJB> Corrected a bug in DLL. ;;;; 2005-04-28 <PJB> Clean-up. ;;;; 2004-03-01 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2004 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DLL" (:use "COMMON-LISP") (:export "DLL-DELETE" "DLL-INSERT" "DLL-NODE-POSITION" "DLL-NODE-NTH" "DLL-NODE-ITEM" "DLL-NODE-PREVIOUS" "DLL-NODE-NEXT" "DLL-NODE" "DLL-LAST" "DLL-FIRST" "DLL-POSITION" "DLL-NTH" "DLL-CONTENTS" "DLL-NCONC" "DLL-APPEND" "DLL-COPY" "DLL-EQUAL" "DLL-LENGTH" "DLL-EMPTY-P" "DLL-LAST-NODE" "DLL-FIRST-NODE" "DLL") (:documentation " This module exports a double-linked list type. This is a structure optimized for insertions and deletions in any place, each node keeping a pointer to both the previous and the next node. The stub keeps a pointer to the head of the list, and the list is circularly closed \(the tail points to the head). License: AGPL3 Copyright Pascal J. Bourguignon 2001 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DLL") (defstruct (dll (:conc-name %dll-)) "A Doubly-Linked List. A DLL keeps a reference to the first node and to the last node." (first nil) (last nil)) (defstruct dll-node "A node in a Doubly-Linked List. Each node is linked to the previous and to the next node in the list, and keeps a reference to its item." (previous nil) (next nil) (item nil)) (setf (documentation 'dll-node-previous 'function) "The previous node." (documentation 'dll-node-next 'function) "The next node." (documentation 'dll-node-item 'function) "The item of the node.") (defun dll (&rest list) " RETURN: A new DLL containing the elements passed as arguments. " (loop :with dlist = (make-dll) :for element :in list :for last-node = (dll-insert dlist nil element) :then (dll-insert dlist last-node element) :finally (return dlist))) (defun dll-first-node (dlist) " RETURN: The first node of the DLIST. " (%dll-first dlist)) (defun dll-last-node (dlist) " RETURN: The last node of the DLIST. " (%dll-last dlist)) (defun dll-empty-p (dlist) " RETURN: Whether the DLL DLIST is empty. ie. (zerop (dll-length dlist)) " (null (%dll-first dlist))) (defun dll-length (dlist) " RETURN: The number of elements in the DLL DLIST. " (do ((len 0 (1+ len)) (current (%dll-last dlist) (dll-node-previous current))) ((null current) len))) (defun dll-nth (index dlist) " RETURN: The INDEXth element in the DLL DLIST. " (do ((i 0 (1+ i)) (current (%dll-first dlist) (dll-node-next current))) ((or (null current) (= i index)) (when current (dll-node-item current))))) (defun dll-position (item dlist &key (test (function eql))) " RETURN: The INDEX of the first element in the DLL DLIST that satisfies the test (TEST element ITEM). " (do ((i 0 (1+ i)) (current (%dll-first dlist) (dll-node-next current))) ((or (null current) (funcall test (dll-node-item current) item)) (when current i)))) (defun dll-node-position (node dlist &key (test (function eql))) " RETURN: The INDEX of the first node in the DLL DLIST that satisfies the test (TEST element NODE). " (do ((i 0 (1+ i)) (current (%dll-first dlist) (dll-node-next current))) ((or (null current) (funcall test current node)) (when current i)))) (defun dll-equal (&rest dlls) " RETURN: Whether all the DLLS contain the same elements in the same order. " (or (null dlls) (null (cdr dlls)) (and (let ((left (first dlls)) (right (second dlls))) (and (equal (dll-node-item (%dll-first left)) (dll-node-item (%dll-first right))) (equal (dll-node-item (%dll-last left)) (dll-node-item (%dll-last right))) (do ((lnodes (dll-node-next (%dll-first left)) (dll-node-next lnodes)) (rnodes (dll-node-next (%dll-first right)) (dll-node-next rnodes))) ((or (eq lnodes (%dll-last left)) (eq rnodes (%dll-last right)) (not (equal (dll-node-item lnodes) (dll-node-item rnodes)))) (and (eq lnodes (%dll-last left)) (eq rnodes (%dll-last right))))) (dll-equal (cdr dlls))))))) (defun dll-copy (dlist) " RETURN: A copy of the DLL DLIST. " (do ((new-dll (make-dll)) (src (%dll-first dlist) (dll-node-next src)) (dst nil)) ((null src) new-dll) (setf dst (dll-insert new-dll dst (dll-node-item src))))) (defun dll-append (&rest dlls) " DO: Appends the elements in all the DLLS into a single dll. The DLLs are not modified. RETURN: A new dll with all the elements in DLLS. " (if (null dlls) (make-dll) (apply (function dll-nconc) (mapcar (function dll-copy) dlls)))) (defun dll-nconc (first-dll &rest dlls) " PRE: No dll appears twice in (CONS FIRST-DLL DLLS). DO: Extract the nodes from all but the FIRST-DLL, and append them all to that FIRST-DLL. POST: ∀l∈dlls, (dll-empty-p l) (dll-length first-dll) = Σ (dll-length old l) l∈dlls " (if (null dlls) first-dll (dolist (dll (rest dlls) first-dll) (let ((first (%dll-first dll))) (unless (null first) (setf (dll-node-previous first) (%dll-last first-dll) (dll-node-next (%dll-last first-dll)) first (%dll-last first-dll) (%dll-last dll) (%dll-first dll) nil (%dll-last dll) nil)))))) (defun dll-contents (dlist) " RETURN: A new list containing the items of the dll. " (do ((current (%dll-last dlist) (dll-node-previous current)) (result ())) ((null current) result) (push (dll-node-item current) result))) (defun dll-first (dlist) " RETURN: The first element in the DLL DLIST, or NIL if it's empty. " (unless (dll-empty-p dlist) (dll-node-item (%dll-first dlist)))) (defun dll-last (dlist) " RETURN: The last element in the DLL DLIST, or NIL if it's empty. " (unless (dll-empty-p dlist) (dll-node-item (%dll-last dlist)))) (defun dll-node-nth (index dlist) " RETURN: The INDEXth node of the DLL DLIST, or NIL if it's empty. " (do ((i 0 (1+ i)) (current (%dll-first dlist) (dll-node-next current))) ((or (null current) (= i index)) current))) (defun dll-insert (dlist node item) " DO: Insert a new node after NODE, or before first position when (NULL NODE). RETURN: The new node. " (let ((new-node nil)) (cond ((dll-empty-p dlist) ;; first item (setf new-node (make-dll-node :item item)) (setf (%dll-first dlist) new-node (%dll-last dlist) (%dll-first dlist))) ((null node) ;; insert before first (setf new-node (make-dll-node :previous nil :next (dll-first-node dlist) :item item)) (setf (dll-node-previous (%dll-first dlist)) new-node (%dll-first dlist) new-node)) ((not (dll-node-position node dlist)) (error "Node not in doubly-linked list.")) (t (setf new-node (make-dll-node :previous node :next (dll-node-next node) :item item)) (if (dll-node-next node) (setf (dll-node-previous (dll-node-next node)) new-node) (setf (%dll-last dlist) new-node)) (setf (dll-node-next node) new-node))) new-node)) (defun dll-extract-node (dlist node) (if (eq (dll-first-node dlist) node) (setf (%dll-first dlist) (dll-node-next node)) (setf (dll-node-next (dll-node-previous node)) (dll-node-next node))) (if (eq (dll-last-node dlist) node) (setf (%dll-last dlist) (dll-node-previous node)) (setf (dll-node-previous (dll-node-next node)) (dll-node-previous node))) dlist) (defun dll-delete (node dlist) " DO: Delete the NODE from the DLL DLIST. RETURN: DLIST " (unless (or (null node) (dll-empty-p dlist) (not (dll-node-position node dlist))) ;; Note O(N)! (dll-extract-node dlist node)) dlist) (defun dll-delete-nth (index dlist) " DO: Delete the INDEXth element of the DLL DLIST. RETURN: DLIST " (dll-extract-node dlist (dll-node-nth index dlist))) ;;;; THE END ;;;;
10,501
Common Lisp
.lisp
282
32
87
0.621946
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
77b3a6a9a4f7eeb763ec2ef9317de8a5f6d0acca5a05f2894c6ad11195200150
5,089
[ -1 ]
5,090
list-test.lisp
informatimago_lisp/common-lisp/cesarum/list-test.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: list-test.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Test list.lisp. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2015-02-25 <PJB> Extracted from list.lisp. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.LIST.TEST" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SIMPLE-TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.LIST") (:export "TEST/ALL")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.LIST.TEST") (define-test test/list-lengths () (dolist (test '( ;; proper lists (() 0 0) ((a) 1 0) ((a b) 2 0) ((a b c) 3 0) ((a b c d) 4 0) ((a b c d e) 5 0) ;; dotted lists (a 0 nil) ((a . b) 1 nil) ((a b . c) 2 nil) ((a b c . d) 3 nil) ((a b c d . e) 4 nil) ((a b c d e . f) 5 nil) ;; circular lists (#1=(a . #1#) 0 1) (#2=(a b . #2#) 0 2) (#3=(a b c . #3#) 0 3) (#4=(a b c d . #4#) 0 4) (#5=(a b c d e . #5#) 0 5) ((a . #6=(b . #6#)) 1 1) ((a . #7=(b c . #7#)) 1 2) ((a . #8=(b c d . #8#)) 1 3) ((a . #9=(b c d e . #9#)) 1 4) ((a b . #10=(c . #10#)) 2 1) ((a b . #11=(c d . #11#)) 2 2) ((a b . #12=(c d e . #12#)) 2 3) ((a b c . #13=(d . #13#)) 3 1) ((a b c . #14=(d e . #14#)) 3 2) ((a b c d . #15=(e . #15#)) 4 1) ((a b c d e . #16=(#16#)) 6 0) ; a proper list! :-) ) :success) (destructuring-bind (list . expected) test (let ((result (multiple-value-list (list-lengths list))) (*print-circle* t)) (assert-true (equal expected result) (result) "(list-lengths '~S)~% returned ~S~% expected ~S~%" list result expected))))) (define-test test/list-elements () (dolist (test '( ;; proper lists (() () 0 0) ((a) (a) 1 0) ((a b) (a b) 2 0) ((a b c) (a b c) 3 0) ((a b c d) (a b c d) 4 0) ((a b c d e) (a b c d e) 5 0) ;; dotted lists (a (a) 0 nil) ((a . b) (a b) 1 nil) ((a b . c) (a b c) 2 nil) ((a b c . d) (a b c d) 3 nil) ((a b c d . e) (a b c d e) 4 nil) ((a b c d e . f) (a b c d e f) 5 nil) ;; circular lists (#1=(a . #1#) (a) 0 1) (#2=(a b . #2#) (a b) 0 2) (#3=(a b c . #3#) (a b c) 0 3) (#4=(a b c d . #4#) (a b c d) 0 4) (#5=(a b c d e . #5#) (a b c d e) 0 5) ((a . #6=(b . #6#)) (a b) 1 1) ((a . #7=(b c . #7#)) (a b c) 1 2) ((a . #8=(b c d . #8#)) (a b c d) 1 3) ((a . #9=(b c d e . #9#)) (a b c d e) 1 4) ((a b . #10=(c . #10#)) (a b c) 2 1) ((a b . #11=(c d . #11#)) (a b c d) 2 2) ((a b . #12=(c d e . #12#)) (a b c d e) 2 3) ((a b c . #13=(d . #13#)) (a b c d) 3 1) ((a b c . #14=(d e . #14#)) (a b c d e) 3 2) ((a b c d . #15=(e . #15#)) (a b c d e) 4 1) ((a b c d e . #16=(#16#)) (a b c d e #16#) 6 0) ; a proper list! :-) ) :success) (destructuring-bind (list . expected) test (let ((result (multiple-value-list (list-elements list))) (*print-circle* t)) (assert-true (equal expected result) (result) "(~A '~S)~% returned ~S~% expected ~S~%" 'list-elements list result expected))))) (define-test test/tree-find () (assert-true (equal 'x (tree-find 'x 'x))) (assert-true (equal 'x (tree-find 'x '(x)))) (assert-true (equal 'x (tree-find 'x '(a b c x d e f)))) (assert-true (equal 'x (tree-find 'x '(a b c d . x)))) (assert-true (equal 'x (tree-find 'x '(() (a b c d . x))))) (assert-true (equal 'x (tree-find 'x '((a b (a b c d . x) x))))) (assert-true (equal 'x (tree-find "x" 'x :test (function string-equal)))) (assert-true (equal 'x (tree-find "x" '(x) :test (function string-equal)))) (assert-true (equal 'x (tree-find "x" '(a b c x d e f) :test (function string-equal)))) (assert-true (equal 'x (tree-find "x" '(a b c d . x) :test (function string-equal)))) (assert-true (equal 'x (tree-find "x" '(() (a b c d . x)) :test (function string-equal)))) (assert-true (equal 'x (tree-find "x" '((a b (a b c d . x) |x|)) :test (function string-equal)))) (assert-true (equal 'x (tree-find "x" 'x :test (function string=) :key (function string-downcase)))) (assert-true (equal 'x (tree-find "x" '(x) :test (function string=) :key (function string-downcase)))) (assert-true (equal 'x (tree-find "x" '(a b c x d e f) :test (function string=) :key (function string-downcase)))) (assert-true (equal 'x (tree-find "x" '(a b c d . x) :test (function string=) :key (function string-downcase)))) (assert-true (equal 'x (tree-find "x" '(() (a b c d . x)) :test (function string=) :key (function string-downcase)))) (assert-true (equal 'x (tree-find "x" '((a b (a b c d . x) |x|)) :test (function string=) :key (function string-downcase))))) (define-test test/iota () (check equalp (iota 5) '(0 1 2 3 4)) (check equalp (iota 5 0 -0.10) '(0 -0.1 -0.2 -0.3 -0.4)) (check equalp (iota (/ 30 4)) '(0 1 2 3 4 5 6)) (check equalp (iota (/ 30 4) 0 4) '(0 4 8 12 16 20 24))) (define-test test/all () (test/list-lengths) (test/list-elements) (test/tree-find) (test/iota)) ;;;; THE END ;;;;
7,013
Common Lisp
.lisp
155
37.058065
127
0.469677
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
b3556174ef89cb0cfe1491f2c3c99c6ecf1c918cb6e5d50f0bd2ded8546651ad
5,090
[ -1 ]
5,091
index-set-test.lisp
informatimago_lisp/common-lisp/cesarum/index-set-test.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: index-set-test.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; The tests for index-set.lisp ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2015-01-08 <PJB> Extracted from index-set.lisp ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.INDEX-SET.TEST" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SIMPLE-TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.INDEX-SET") (:shadowing-import-from "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SET" "UNION" "INTERSECTION" "MERGE" "INCLUDE") (:import-from "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.INDEX-SET" "EQUAL-RANGES" "COMPLEMENT-RANGES") (:export "TEST/ALL")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.INDEX-SET.TEST") ;;---------------------------------------------------------------------- ;; RANGE TESTS (define-test test/range () (assert-true (range-emptyp (make-range :start 1 :count 0))) (assert-true (range-emptyp (make-range :start 1 :last 0))) (assert-true (range-emptyp (make-range :start 1 :end 1))) (assert-true (not (range-emptyp (make-range :start 1 :count 1)))) (assert-true (not (range-emptyp (make-range :start 1 :last 1)))) (assert-true (not (range-emptyp (make-range :start 1 :end 2)))) (assert-true (equal-range (make-range :start 10 :end 21) (make-range :first 10 :last 20))) (assert-true (equal-range (make-range :start 0 :end -1) (make-range :first 0 :last -1))) (check = (range-start (make-range :start 1 :count 3)) 1) (check = (range-last (make-range :start 1 :count 3)) 3) (check = (range-end (make-range :start 1 :count 3)) 4) (check = (range-count (make-range :start 1 :count 3)) 3) (check = (range-start (copy-range (make-range :start 1 :count 3))) 1) (check = (range-last (copy-range (make-range :start 1 :count 3))) 3) (check = (range-end (copy-range (make-range :start 1 :count 3))) 4) (check = (range-count (copy-range (make-range :start 1 :count 3))) 3) (check = (range-start (make-range :start 11 :last 13)) 11) (check = (range-last (make-range :start 11 :last 13)) 13) (check = (range-end (make-range :start 11 :last 13)) 14) (check = (range-count (make-range :start 11 :last 13)) 3) (check = (range-start (copy-range (make-range :start 11 :last 13))) 11) (check = (range-last (copy-range (make-range :start 11 :last 13))) 13) (check = (range-end (copy-range (make-range :start 11 :last 13))) 14) (check = (range-count (copy-range (make-range :start 11 :last 13))) 3) (check = (range-start (make-range :start 11 :end 14)) 11) (check = (range-last (make-range :start 11 :end 14)) 13) (check = (range-end (make-range :start 11 :end 14)) 14) (check = (range-count (make-range :start 11 :end 14)) 3) (check = (range-start (copy-range (make-range :start 11 :end 14))) 11) (check = (range-last (copy-range (make-range :start 11 :end 14))) 13) (check = (range-end (copy-range (make-range :start 11 :end 14))) 14) (check = (range-count (copy-range (make-range :start 11 :end 14))) 3) (check = (range-start (make-range :count 3 :last 13)) 11) (check = (range-last (make-range :count 3 :last 13)) 13) (check = (range-end (make-range :count 3 :last 13)) 14) (check = (range-count (make-range :count 3 :last 13)) 3) (check = (range-start (copy-range (make-range :count 3 :last 13))) 11) (check = (range-last (copy-range (make-range :count 3 :last 13))) 13) (check = (range-end (copy-range (make-range :count 3 :last 13))) 14) (check = (range-count (copy-range (make-range :count 3 :last 13))) 3) (check = (range-start (make-range :count 3 :end 14)) 11) (check = (range-last (make-range :count 3 :end 14)) 13) (check = (range-end (make-range :count 3 :end 14)) 14) (check = (range-count (make-range :count 3 :end 14)) 3) (check = (range-start (copy-range (make-range :count 3 :end 14))) 11) (check = (range-last (copy-range (make-range :count 3 :end 14))) 13) (check = (range-end (copy-range (make-range :count 3 :end 14))) 14) (check = (range-count (copy-range (make-range :count 3 :end 14))) 3)) (define-test test/range/complement () (check equal-ranges (complement-ranges (vector) 0 100) (vector (make-range :start 0 :end 100))) (check equal-ranges (complement-ranges (vector (make-range :start 0 :end 100)) 0 100) (vector)) (check equal-ranges (complement-ranges (vector (make-range :start 0 :end 90)) 0 100) (vector (make-range :start 90 :end 100))) (check equal-ranges (complement-ranges (vector (make-range :start 10 :end 100)) 0 100) (vector (make-range :start 0 :end 10))) (check equal-ranges (complement-ranges (vector (make-range :start 10 :end 90)) 0 100) (vector (make-range :start 0 :end 10) (make-range :start 90 :end 100))) (expect-condition 'error (complement-ranges (vector (make-range :start 0 :end 100)) 10 90))) ;;---------------------------------------------------------------------- ;; INDEX-SET TESTS (define-test test/all () (let ((*package* (find-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.INDEX-SET"))) (test/range) (test/range/complement) (com.informatimago.common-lisp.cesarum.set.test:test/all/class 'index-set))) ;;;; THE END ;;;;
6,682
Common Lisp
.lisp
125
49.464
88
0.617539
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
addc8f1f78e54a98a82acca14cf5290222f04449ccbbec381fbf4b86c37585d9
5,091
[ -1 ]
5,092
utility.lisp
informatimago_lisp/common-lisp/cesarum/utility.lisp
;;;; -*- mode:lisp; coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: utility.lisp ;;;;LANGUAGE: common-lisp ;;;;SYSTEM: UNIX ;;;;USER-INTERFACE: UNIX ;;;;DESCRIPTION ;;;; This package exports some utility & syntactic sugar functions & macros. ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2016-01-16 <PJB> Removed CHRONO. Use ...TIME:CHRONO-RUN-TIME instead. ;;;; 2016-01-04 <PJB> Added HASH-TABLE-SELECT. ;;;; 2015-08-19 <PJB> Renamed INCLUDE -> INCLUDE-FILE. ;;;; 2015-06-13 <PJB> Added CHRONO. ;;;; 2014-10-22 <PJB> Added HASH-TABLE-TO-SEXP and SEXP-TO-HASH-TABLE. ;;;; 2013-06-30 <PJB> Added FLOAT-{,C,E}TYPECASE; exported [-+]EPSILON. ;;;; 2008-06-24 <PJB> Added INCF-MOD and DECF-MOD. ;;;; 2007-12-01 <PJB> Removed PJB-ATTRIB macro (made it a flet of PJB-DEFCLASS). ;;;; 2007-07-07 <PJB> Added TRACING. ;;;; 2007-03-19 <PJB> Added HASHTABLE and PRINT-HASHTABLE (typo on purpose). ;;;; 2007-02-18 <PJB> Added NSUBSEQ. ;;;; 2005-03-30 <PJB> Added SIGN. ;;;; 2005-03-17 <PJB> Added DEFINE-IF-UNDEFINED ;;;; 2005-03-17 <PJB> Added COMPOSE & COMPOSE-AND-CALL. ;;;; 2005-03-09 <PJB> Added DEFENUM. ;;;; 2004-12-13 <PJB> Removed UNREADABLE-OBJECT (use PRINT-UNREADABLE-OBJECT). ;;;; 2004-10-10 <PJB> Added UNREADABLE-OBJECT class, & reordered definitions. ;;;; 2004-03-31 <PJB> Renamed DEFINE-WITH-STRUCTURE to DEFINE-WITH-OBJECT, ;;;; since behavior of WITH-SLOT on structures is undefined. ;;;; 2004-02-27 <PJB> Added DEFINE-WITH-STRUCTURE, FOR, VECTOR-INIT; ;;;; removed (REPEAT ...) --> (LOOP ...). ;;;; 2004-01-19 <PJB> Added INCLUDE. ;;;; 2003-10-23 <PJB> Added COMPUTE-CLOSURE. ;;;; 2003-01-08 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2003 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.LISP-SEXP.SOURCE-FORM" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.LIST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SYMBOL") #+mocl (:shadowing-import-from "COM.INFORMATIMAGO.MOCL.KLUDGES.MISSING" "*TRACE-OUTPUT*" "*LOAD-VERBOSE*" "*LOAD-PRINT*" "ARRAY-DISPLACEMENT" "CHANGE-CLASS" "COMPILE" "COMPLEX" "ENSURE-DIRECTORIES-EXIST" "FILE-WRITE-DATE" "INVOKE-DEBUGGER" "*DEBUGGER-HOOK*" "LOAD" "LOGICAL-PATHNAME-TRANSLATIONS" "MACHINE-INSTANCE" "MACHINE-VERSION" "NSET-DIFFERENCE" "RENAME-FILE" "SUBSTITUTE-IF" "TRANSLATE-LOGICAL-PATHNAME" "PRINT-NOT-READABLE" "PRINT-NOT-READABLE-OBJECT") (:export "SIMPLE-PROGRAM-ERROR" "SIMPLE-PROGRAM-ERROR-FORMAT-CONTROL" "SIMPLE-PROGRAM-ERROR-FORMAT-ARGUMENTS" ;; 3 - EVALUATION AND COMPILATION "WITH-FUNCTIONS" "WITH-GENSYMS" "WSIOSBP" "PROGN-CONCAT" "CURRY" "RCURRY" "COMPOSE" "COMPOSE-AND-CALL" "/NTH-ARG" "/APPLY" "DEFINE-IF-UNDEFINED" "INCLUDE-FILE" "FUNCTIONAL-PIPE" "FIRST-ARG" "SECOND-ARG" "THIRD-ARG" "FOURTH-ARG" "FIFTH-ARG" "SIXTH-ARG" "SEVENTH-ARG" "EIGHTH-ARG" "NINTH-ARG" "TENTH-ARG" "NTH-ARG" ;; 4 - TYPES AND CLASSES "DEFENUM" "OP-TYPE-OF" ;; 5 - DATA AND CONTROL FLOW "SAFE-APPLY" "WHILE" "UNTIL" "FOR" ;; 7 - OBJECTS "DEFINE-STRUCTURE-CLASS" "DEFINE-WITH-OBJECT" "PJB-DEFCLASS" "PRINT-PARSEABLE-OBJECT" "OBJECT-IDENTITY" "SLOTED-OBJECT" "SLOTS-FOR-PRINT" "EXTRACT-SLOTS" "GEN-EXTRACT-SLOTS" ;; 8 - STRUCTURES "DEFINE-WITH-STRUCTURE" ;; 9 - CONDITIONS "HANDLING-ERRORS" ;; 12 - NUMBERS "SIGN" "DISTINCT-FLOAT-TYPES" "FLOAT-TYPECASE" "FLOAT-CTYPECASE" "FLOAT-ETYPECASE" "+EPSILON" "-EPSILON" ;; 14 - CONSES "MAXIMIZE" "TOPOLOGICAL-SORT" "TRANSITIVE-CLOSURE" "COMPUTE-CLOSURE" ; deprecated, renamed to transitive-closure "FIND-CYCLES" "FIND-SHORTEST-PATH" ;; 15 - ARRAYS "VECTOR-INIT" "UNDISPLACE-ARRAY" "DICHOTOMY-SEARCH" ;; 16 - STRINGS "CONCAT" "SCONC" "SCASE" "ISCASE" ;; 17 - SEQUENCES "NSUBSEQ" ;; 18 - HASH-TABLES "HASH-TABLE-KEYS" "HASH-TABLE-VALUES" "HASH-TABLE-ENTRIES" "HASH-TABLE-SELECT" "HASH-TABLE-PROJECTION" "HASH-TABLE-PATH" "COPY-HASH-TABLE" "MAP-INTO-HASH-TABLE" "HASHTABLE" "PRINT-HASHTABLE" "HASH-TABLE-TO-SEXP" "SEXP-TO-HASH-TABLE" ;; "DICHOTOMY" "TRACING" "TRACING-LET" "TRACING-LET*" "TRACING-LABELS" ;; "XOR" "EQUIV" "IMPLY" ;; "SET-EQUAL" ) (:export "PARSE-STRUCTURE-DEFINITION") (:export "DMS-D" "D-DMS") (:documentation " This package exports some utility & syntactic sugar functions and macros. License: AGPL3 Copyright Pascal J. Bourguignon 2003 - 2023 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 3 - EVALUATION AND COMPILATION ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmacro with-functions ((&rest fnames) &body body) `(flet ,(mapcar (lambda (fname) (if (listp fname) (destructuring-bind (name &rest parameters) fname `(,name ,parameters (funcall ,name ,@parameters))) `(,fname (&rest arguments) (apply ,fname arguments)))) fnames) (declare (inline ,@(mapcar (lambda (fname) (if (listp fname) (first fname) fname)) fnames))) ,@body)) #-:with-debug-gensym (defmacro with-gensyms (syms &body body) " DO: Replaces given symbols with gensyms. Useful for creating macros. NOTE: This version by Paul Graham in On Lisp." `(let ,(mapcar (lambda (s) `(,s (gensym ,(string s)))) syms) ,@body)) #+:with-debug-gensym (defpackage "COM.INFORMATIMAGO.GENSYMS" (:use)) #+:with-debug-gensym (defmacro with-gensyms (syms &body body) " DO: Replaces given symbols with gensyms. Useful for creating macros. NOTE: This version by Paul Graham in On Lisp." `(let ,(mapcar (lambda (s) `(,s (intern (string (gensym ,(string s))) "COM.INFORMATIMAGO.GENSYMS"))) syms) ,@body)) (defun progn-concat (forms) " DO: Wraps the forms in a PROGN. If they're PROGN forms, then their PROGN is unwrapped first. " `(progn ,@(mapcan (lambda (form) (cond ((null form) '()) ((and (listp form) (eq 'progn (first form))) (copy-list (rest form))) (t (list form)))) forms))) (defmacro wsiosbp (&body body) " Like with-standard-io-syntax but with the current package. The *PACKAGE* is kept bound to the current package. " (let ((vpack (gensym))) `(let ((,vpack *package*)) (with-standard-io-syntax (let ((*package* ,vpack)) ,@body))))) (defmacro define-argument-selector (name argument-number) (let ((arguments (loop :for i :from 0 :to argument-number :collect (gensym)))) `(defun ,name (,@(cdr arguments) &rest ,(car arguments)) ,(format nil "RETURN: The ~:R argument." argument-number) (declare (ignore ,@(butlast arguments))) ,(car (last arguments))))) (define-argument-selector first-arg 1) (define-argument-selector second-arg 2) (define-argument-selector third-arg 3) (define-argument-selector fourth-arg 4) (define-argument-selector fifth-arg 5) (define-argument-selector sixth-arg 6) (define-argument-selector seventh-arg 7) (define-argument-selector eighth-arg 8) (define-argument-selector ninth-arg 9) (define-argument-selector tenth-arg 10) (defun nth-arg (n &rest arguments) "RETURN: The Nth argument following N." (nth n arguments)) (defun curry (function &rest left-arguments) (lambda (&rest right-arguments) (apply function (append left-arguments right-arguments)))) (defun rcurry (function &rest right-arguments) (lambda (&rest left-arguments) (apply function (append left-arguments right-arguments)))) ;; (defmacro curry (function &rest left-arguments) ;; (let ((parameters (mapcar (lambda (arg) (gensym)) left-arguments)) ;; (right-arguments (gensym))) ;; `(let ,(mapcar (function list) parameters left-arguments) ;; (lambda (&rest ,right-arguments) ;; (apply (function ,function) ,@parameters ,right-arguments))))) (eval-when (:compile-toplevel :load-toplevel :execute) (defun compose-sexp (functions var) (if (null functions) var (list (car functions) (compose-sexp (cdr functions) var))))) (defmacro compose (&rest functions) " RETURN: The functional composition of the FUNCTIONS. EXAMPLE: (compose abs sin cos) = (lambda (&rest args) (abs (sin (apply (function cos) args)))) NOTE: (compose) = (function identity) (compose foo) = (function foo) " (cond ((null functions) `(function identity)) ((null (cdr functions)) `(function ,(car functions))) (t `(lambda (&rest args) ,(compose-sexp (butlast functions) `(apply (function ,(first (last functions))) args)))))) (defmacro compose-and-call (&rest functions-and-arg) " DO: Call the functional composition of the functions, on the argument. EXAMPLE: (compose-and-call abs sin cos 0.234) --> 0.8264353 " `(funcall ,((lambda (functions) (list 'lambda '(x) (compose-sexp functions 'x))) (butlast functions-and-arg)) ,(car (last functions-and-arg)))) ;; (funcall (compose 1+ sin 1-) 0) ;; (compose-and-call 1+ sin 1- 0) (defun /nth-arg (n) (lambda (&rest args) (nth n args))) (defun /apply (&rest funs) (lambda (&rest args) (mapcar (lambda (f) (apply f args)) funs))) (defmacro define-if-undefined (&rest definitions) "Use this to conditionally define functions, variables, or macros that may or may not be pre-defined in this Lisp. This can be used to provide CLtL2 compatibility for older Lisps. WHO'S THE AUTHOR?" `(progn ,@(mapcar #'(lambda (def) (let ((name (second def))) `(unless (or (boundp ',name) (fboundp ',name) (special-form-p ',name) (macro-function ',name)) ,def))) definitions))) #|| (define-if-undefined (defmacro with-simple-restart (restart &rest body) "Like PROGN, except provides control over restarts if there is an error." (declare (ignore restart)) `(progn ,@body)) (defmacro done-mac () nil) ) (defmacro uncond-mac () nil) ||# ;; (defun include-file (path) ;; " ;; NOTE: Untasty, but sometimes useful. ;; DO: Read from the file at PATH all the sexps and returns a list of them ;; prefixed with 'progn. ;; USAGE: #.(include-file \"source.lisp\") ;; " ;; (cons 'progn ;; (with-open-file (file path :direction :input :if-does-not-exist :error) ;; (do ((result '()) ;; (eof (gensym))) ;; ((eq eof (car result)) (nreverse (cdr result))) ;; (push (read file nil eof) result))))) (defgeneric include-file (path-or-stream) (:documentation " NOTE: Untasty, but sometimes useful. DO: Read from the file at PATH all the sexps and returns a list of them prefixed with 'progn. USAGE: #.(include-file \"source.lisp\") ") (:method ((path string)) (include-file (pathname path))) (:method ((path pathname)) (with-open-file (stream path :direction :input :if-does-not-exist :error) (include-file stream))) (:method ((stream stream)) (loop :for form := (read stream nil stream) :until (eql form stream) :do (eval form)))) (defmacro functional-pipe (&body forms) " Execute forms in sequence each in a lexical scope where *, ** and *** are bound to the results of the last three previous forms. Return the results of the last form. " (let ((bindings (mapcar (lambda (form) (list (gensym) form)) forms))) `(let* ,(loop for (*** ** * current) on (list* '(nil) '(nil) '(nil) bindings) unless (null current) collect (list (first current) (subst (first ***) '*** (subst (first **) '** (subst (first *) '* (second current)))))) ,(first (first (last bindings)))))) ;; (let ((*** nil) (** nil) (* nil)) ;; (let ((*** **) (** *) (* ,form)) ;; ... ;; *)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 4 - TYPES AND CLASSES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmacro defenum (name-and-options &rest constants) " Define an named enumeration type, a set of constants with integer values, and a label function to produce the name of the constants from the numerical value. NAME-AND-OPTIONS: The name of the enum type, or a list containing the name of the enum type and options (no option defined so far). The label function defined is named <enum-type-name>-LABEL CONSTANTS: The first element of CONSTANTS may be an optional docstring. Each constant is either a symbol naming the constant of the enum, (the value is then the successor of the previous value), or a list containing the constant name and the constant value. " (let ((name (if (consp name-and-options) (first name-and-options) name-and-options))) (when (stringp (first constants)) ; docstring (pop constants)) (let* ((min nil) (max nil) (defconstants (loop :with val = -1 :for cname :in constants :do (when (consp cname) (setf val (1- (second cname)) cname (first cname))) :collect `(defconstant ,cname ,(incf val) ,(format nil "~A enumeration value." name)) :do (if min (setf min (min min val)) (setf min val)) (if max (setf max (max max val)) (setf max val))))) (push `(defconstant ,(scat name '-min) ,min ,(format nil "The minimum ~A enumeration value." name)) defconstants) (push `(defconstant ,(scat name '-max) ,max ,(format nil "The maximum ~A enumeration value." name)) defconstants) `(eval-when (:compile-toplevel :load-toplevel :execute) ;; define a ({NAME}-LABEL value) function. (defun ,(intern (wsiosbp (format nil "~A-LABEL" name))) (value) ,(format nil "Produce the name of the constant having the given VALUE.") (case value ,@(loop :with val = -1 :for cname :in constants :do (if (consp cname) (setf val (second cname)) (incf val)) :collect `((,val) ',(if (consp cname) (first cname) cname))) (otherwise (format nil "#<~A:~D>" ',name value)))) ;; define the constants. ,@defconstants ;; define the type. (deftype ,name () "An enumeration type." ;; TODO: get a docstring from the parameters. '(member ,@(loop :with val = -1 :for cname :in constants :collect (if (consp cname) (setf val (second cname)) (incf val))))))))) (defun op-type-of (symbol &optional env) " From: [email protected] Newsgroups: comp.lang.lisp Date: 29 Jul 2004 03:59:50 GMT Message-ID: <[email protected]> " (if (fboundp symbol) (cond ((macro-function symbol env) 'macro) ((special-operator-p symbol) 'special-operator) ((compiled-function-p (symbol-function symbol)) 'compiled-function) (t 'interpreted-function)) (error "Symbol ~S is not an operator." symbol))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 5 - DATA AND CONTROL FLOW ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun safe-apply (fun &rest args) " DO: Call APPLY or REDUCE depending on the length of ARGS. NOTE: No prefix argument are allowed for REDUCE! (safe-apply 'concatenate 'string list-of-sequence) doesn't work! Use instead: (safe-apply (lambda (a b) (concatenate 'string a b)) list-of-sequence) " (let ((arg-list (car (last args)))) (if (< (+ (length args) (length arg-list)) call-arguments-limit) (apply fun (nconc (butlast args) arg-list)) (reduce fun (nconc (butlast args) arg-list))))) (defmacro while (condition &body body) "While loop." `(do () ((not ,condition)) ,@body)) (defmacro until (condition &body body) "Until loop." `(do () (,condition) ,@body)) (defmacro for ((var first last &optional (step nil stepp)) &body body) "For loop. DO: Repeat BODY with VAR bound to successive integer values from FIRST to LAST inclusive. If the optional STEP argument is abstent, then it is taken as 1 or -1 depending on the order of FIRST and LAST. VAR is incremented by STEP and it stops when VAR goes above or below LAST depending on the sign of STEP. " (when (and (not stepp) (numberp first) (numberp last)) (setf step (if (<= first last) 1 -1) stepp t)) (cond ((and stepp (numberp step)) ;; Hardwired step and comparison: (check-type step real) (let ((firstvar (gensym "FIRST")) (lastvar (gensym "LAST")) (cmp (if (minusp step) '< '>))) `(let ((,firstvar ,first) (,lastvar ,last)) (do ((,var ,firstvar (incf ,var ,step))) ((,cmp ,var ,lastvar)) ,@body)))) (stepp ;; Runtime evaluation of step and comparison: (let ((firstvar (gensym "FIRST")) (lastvar (gensym "LAST")) (stepvar (gensym "STEP")) (cmp (gensym "CMP"))) `(let* ((,firstvar ,first) (,lastvar ,last) (,stepvar ,step) (,cmp (if (minusp ,stepvar) (function <) (function >)))) (do ((,var ,firstvar (incf ,var ,stepvar))) ((funcall ,cmp ,var ,lastvar)) ,@body)))) (t ;; Runtime determination of step and comparison: (let ((firstvar (gensym "FIRST")) (lastvar (gensym "LAST")) (stepvar (gensym "STEP")) (cmp (gensym "CMP"))) `(let* ((,firstvar ,first) (,lastvar ,last) (,stepvar (if (<= ,firstvar ,lastvar) 1 -1)) (,cmp (if (minusp ,stepvar) (function <) (function >)))) (do ((,var ,firstvar (incf ,var ,stepvar))) ((funcall ,cmp ,var ,lastvar)) ,@body)))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 7 - OBJECTS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmacro pjb-defclass (name super &rest args) " This macro encapsulate DEFCLASS and allow the declaration of the attributes in a shorter syntax. ARGS is a list of s-expr, whose car is either :ATT (to declare an attribute) or :DOC to give the documentation string of the class. (:OPT ...) is not implemented yet. (:ATT name type [ init-value [doc-string] | doc-string ]) defines an attribute named NAME, of type TYPE, with the given initial value and documentation strings. An accessor and an initarg keyword of same NAME are also defined. " (flet ((attrib (name type &rest args) " This function outputs an attribute s-exp as used in defclass. ARGS may be of length 1 or 2. If (LENGTH ARGS) = 1 then if the argument is a string, then it's taken as the documentation and the initial value is NIL else it's taken as the initial value and the documentation is NIL. else the first is the initial value and the second is the documentation. The initarg an accessor are the same keyword built from the name. " (let ((iarg (intern (if (symbolp name) (symbol-name name) name) (find-package "KEYWORD"))) init doc) (cond ((= 2 (length args)) (setq init (car args) doc (cadr args)) ) ((= 1 (length args)) (if (stringp (car args)) (setq init nil doc (car args)) (setq init (car args) doc nil)) ) (t (error "Invalid attribute ~S" `(:att ,name ,type ,@args)))) (when (and (symbolp type) (null init)) (setf type (list 'or 'null type))) (when (null doc) (setf doc (symbol-name name))) `(,name :initform ,init :initarg ,iarg :accessor ,name :type ,type :documentation ,doc)))) (let ((fields nil) (options nil)) (do () ( (not args) ) (cond ((eq :att (caar args)) (push (apply (function attrib) (cdar args)) fields)) ((eq :doc (caar args)) (push (cons :documentation (cdar args)) options))) (setf args (cdr args))) (setf fields (nreverse fields)) (setf options (nreverse options)) `(defclass ,name ,super ,fields ,@options)))) #|| For :constructor, several options are allowed. |-----------------+--------------+----------------------+--------------------+-------------------------+--------------------------| | | | | | | | |-----------------+--------------+----------------------+--------------------+-------------------------+--------------------------| | default name | slot name | slot name | slot name | specified prefix | | |-----------------+--------------+----------------------+--------------------+-------------------------+--------------------------| | | | | | | | | | :conc-name | (:conc-name) | (:conc-name nil) | (:conc-name name) | | | struct-slot | slot | slot | slot | nameslot | | | | | | | | | |-----------------+--------------+----------------------+--------------------+-------------------------+--------------------------| | | | | | | | |-----------------+--------------+----------------------+--------------------+-------------------------+--------------------------| | default name | default name | default name | no function | specified name | specified name | |-----------------+--------------+----------------------+--------------------+-------------------------+--------------------------| | | | | | | | | | :constructor | (:constructor) | (:constructor nil) | (:constructor name) | (:constructor name args) | | make-struct | make-struct | make-struct | no constructor | name :slot | name arglist | | | | | | | | | | :copier | (:copier) | (:copier nil) | (:copier name) | | | copy-struct | copy-struct | copy-struct | no copier | name | | | | | | | | | | | :predicate | (:predicate) | (:predicate nil) | (:predicate name) | | | struct-p | struct-p | struct-p | no predicate | name | | | | | | | | | |-----------------+--------------+----------------------+--------------------+-------------------------+--------------------------| | | | | | | | | | | (:print-object) | | (:print-object name) | | | implemntation- | | default print-object | | print-object calls name | | | specific print | | method | | | | | | | | | | | | | | (:print-function) | | (:print-function name) | | | implementation- | | default print-object | | print-object calls name | | | specific print | | method | | | | | | | | | | | |-----------------+--------------+----------------------+--------------------+-------------------------+--------------------------| | | :named | | | | | | not named | named | | | | | | | | | | | (:include name slots*) | |-----------------+--------------+----------------------+--------------------+-------------------------+--------------------------| | | | | | (:initial-offset value) | | | | | | | (:type type) | | |-----------------+--------------+----------------------+--------------------+-------------------------+--------------------------| Using these results from GET-OPTION allows to distinguish all the cases: |--------------+--------------+--------------+-------------+------------------+------------------| | | :foo | (:foo) | (:foo nil) | (:foo name) | (:foo name args) | |--------------+--------------+--------------+-------------+------------------+------------------| | nil | :symbol | :singleton | (nil) | (name) | (name slots*) | |--------------+--------------+--------------+-------------+------------------+------------------| | default name | slot name | slot name | slot name | specified prefix | | |--------------+--------------+--------------+-------------+------------------+------------------| | default name | default name | default name | no function | specified name | specified name | |--------------+--------------+--------------+-------------+------------------+------------------| For conc-name: default-name = (null option) slot-name = (or (atom option) (null (first option))) name = (and (consp option) (first option)) For others: default-name = (atom option) no-function = (and (consp option) (null (first option))) name = (and (consp option) (first option)) ||# (defun option-key-p (key option) (eq key (if (symbolp option) option (car option)))) (defun get-option (key options &key list boolean) (let ((opts (remove key options :test-not (function option-key-p)))) (cond (list opts) (boolean (cond ((null opts) nil) ((cddr opts) (error "Expected only one ~S option, not ~{~S~^ ~}." key opts)) ((symbolp (car opts)) t) (t (error "Expected a flag ~S option, not ~{~S~^ ~}." key opts)))) ((null opts) nil) ((null (rest opts)) ; a single option (let ((opt (first opts))) (cond ((symbolp opt) :symbol) ((null (rest opt)) :singleton) (t (rest opt))))) (t (error "Expected only one ~S option, not ~{~S~^ ~}." key opts))))) (defun make-conc-name (option prefix name suffix) (cond ((null option) (scat prefix name suffix)) ((member option '(:symbol :singleton (nil)) :test (function equal)) '||) ((and option (listp option) (car option)) (car option)) (t nil))) (defun make-name (option prefix name suffix) (cond ((or (null option) (and option (not (listp option)))) (scat prefix name suffix)) ((and option (listp option) (car option)) (car option)) (t nil))) (defun get-name (option) (if (and option (listp option)) (car option) nil)) (defun parse-structure-name-and-options (name-and-options) (let ((name (if (symbolp name-and-options) name-and-options (car name-and-options))) (options (if (symbolp name-and-options) nil (cdr name-and-options)))) (let ((conc-name (get-option :conc-name options)) (constructors (get-option :constructor options :list t)) (copier (get-option :copier options)) (predicate (get-option :predicate options)) (print-function (get-option :print-function options)) (print-object (get-option :print-object options)) (include (get-option :include options)) (initial-offset (get-option :initial-offset options)) (structure-type-p (get-option :type options)) (structure-type (get-option :type options)) (namedp (get-option :named options :boolean t))) (when (and print-object print-function) (error 'simple-program-error :format-control "Cannot have :print-object and :print-function options.")) (when structure-type-p (unless (and (null (cdr structure-type)) (let ((structure-type (car structure-type))) (or (eql structure-type 'list) (eql structure-type 'vector) (and (listp structure-type) (eql (first structure-type) 'vector) (cdr structure-type) (typep (second structure-type) '(integer 0)) (null (cddr structure-type)))))) (error 'simple-program-error :format-control "Invalid structure :type option: ~S" :format-arguments (list (car structure-type))))) (let ((conc-name (make-conc-name conc-name "" name "-")) (copier (make-name copier "COPY-" name "")) (predicate (make-name predicate "" name "-P")) (print-function (get-name print-function)) (print-object (get-name print-object)) (constructors (if (null constructors) (list (make-name nil "MAKE-" name "")) (mapcan (lambda (x) (cond ((or (symbolp x) (= 1 (length x))) (list (make-name nil "MAKE-" name ""))) ((null (second x)) nil) ((= 2 (length x)) (list (second x))) (t (list (list (second x) (third x)))))) constructors)))) (values name conc-name constructors copier include initial-offset predicate print-function print-object (not (not structure-type-p)) (car structure-type) namedp))))) (defun parse-structure-definition (name-and-options doc-and-slots) (multiple-value-bind (name conc-name constructors copier include initial-offset predicate print-function print-object structure-type-p structure-type namedp) (parse-structure-name-and-options name-and-options) (let ((documentation (if (stringp (car doc-and-slots)) (car doc-and-slots) nil)) (slots (if (stringp (car doc-and-slots)) (cdr doc-and-slots) doc-and-slots))) (when (cdr include) (setf slots (append (cddr include) slots) include (list (car include)))) (let ((slot-names (mapcar (lambda (s) (if (symbolp s) s (car s))) slots)) (accessors (mapcar (lambda (s) (make-name nil (or conc-name "") (if (symbolp s) s (car s)) "")) slots))) (values name conc-name constructors copier include initial-offset predicate print-function print-object structure-type-p structure-type ;; -- documentation slots slot-names accessors namedp))))) (defun generate-class-structure (name conc-name constructors copier include initial-offset predicate print-function print-object structure-type-p structure-type documentation slots slot-names accessors) (declare (ignore structure-type-p structure-type initial-offset conc-name)) ;; TODO: use conc-name ;; TODO: signal error on bad structure-type or structure-type-p ;; TODO: signal error on non-zero initial-offset `(progn (defclass ,name ,include ,(mapcar (lambda (slot accessor) (if (symbolp slot) `(,slot :accessor ,accessor) (let* ((name (first slot)) (initform-p (cdr slot)) (initform (car initform-p)) (type-p (member :type (cddr slot))) (type (cadr type-p)) (read-only-p (member :read-only (cddr slot))) (read-only (cadr read-only-p))) `(,name ,(if (and read-only-p read-only) :reader :accessor) ,accessor ,@(when initform-p (list :initform initform)) ,@(when type-p (list :type type)))))) slots accessors) ,@(when documentation (list `(:documentation ,documentation)))) ,@(mapcar (lambda (constructor) ;; generate a constructor. (if (symbolp constructor) (let ((preds (mapcar (lambda (x) (declare (ignore x)) (gensym)) slot-names))) `(defun ,constructor (&key ,@(mapcar (lambda (s p) (list s nil p)) slot-names preds)) (let ((args nil)) ,@(mapcar (lambda (s p) `(when ,p (push ,s args) (push ,(keywordize s) args))) slot-names preds) (apply (function make-instance) ',name args)))) (let ((cname (first constructor)) (pospar (second constructor))) (declare (ignore pospar)) (warn "~S does not implement this case yet." 'define-structure-class) `(defun ,cname (&rest args) (declare (ignore args)) (error 'simple-program-error "~S does not implement this yet." 'define-structure-class))))) constructors) ,@(when copier (list `(defmethod ,copier ((self ,name)) (make-instance ',name ,@(mapcan (lambda (slot accessor) (list (keywordize slot) (list accessor 'self))) slot-names accessors))))) ,@(when predicate (list `(defmethod ,predicate (object) (eq (type-of object) ',name)))) ,@(when print-function (list `(defmethod print-object ((self ,name) stream) (,print-function self stream 0)))) ,@(when print-object (list `(defmethod print-object ((self ,name) stream) (,print-object self stream)))))) (defmacro define-structure-class (name-and-options &rest doc-and-slots) " DO: Define a class implementing the structure API. This macro presents the same API as DEFSTRUCT, but instead of defining a structure, it defines a class, and the same functions as would be defined by DEFSTRUCT. The option :TYPE accepts LIST, VECTOR or STRUCTURE. When given, it falls back to CL:DEFSTRUCT. The DEFSTRUCT option :INITIAL-OFFSET is only supported when :TYPE is given. " (multiple-value-bind (name conc-name constructors copier include initial-offset predicate print-function print-object structure-type-p structure-type documentation slots slot-names accessors) (parse-structure-definition name-and-options doc-and-slots) (if structure-type-p ;; For now, fall back to cl:defstruct. (if (eql structure-type 'structure) `(defstruct ,(remove :type name-and-options :key (lambda (x) (when (listp x) (first x)))) ,@doc-and-slots) `(defstruct ,name-and-options ,@doc-and-slots)) (generate-class-structure name conc-name constructors copier include initial-offset predicate print-function print-object structure-type-p structure-type documentation slots slot-names accessors)))) (defmacro define-with-object (class-name slots) " DO: Define a macro: (WITH-{CLASS-NAME} object &body body) expanding to: (with-slots ({slots}) object @body) " `(defmacro ,(intern (with-standard-io-syntax (format nil "WITH-~A" class-name))) (object &body body) `(with-slots (quote ,,(mapcar (lambda (slot) (list slot slot)) slots)) ,object ,@body))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Printing objects. ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (declaim (declaration stepper)) (declaim (ftype (function ((or string symbol character) &rest t) symbol) keywordize)) ;;; ;;; We have two way to print easily objects: ;;; ;;; 1- inherit from the SLOTED-OBJECT mixin class, and define a ;;; SLOTS-FOR-PRINT method on your classes. ;;; ;;; 2- define a PRINT-OBJECT method on your classes using the macro ;;; PRINT-PARSEABLE-OBJECT. ;;; (defclass sloted-object () () (:documentation " This is a mixin class providing generic SLOTS and PRINT-OBJECT methods. ")) (defgeneric extract-slots (object slots) (:documentation " RETURN: A plist slot values. OBJECT: A lisp object. SLOTS: A list of slot names. ") (:method (object slots) (assert (every (function symbolp) slots) (slots)) (loop :for slot :in slots :collect (keywordize slot) :collect (if (slot-boundp object slot) (slot-value object slot) '#:unbound)))) (defgeneric slots-for-print (object) (:method-combination append) (:documentation " This generic function collects a p-list describing the slots of the OBJECT. The generic function EXTRACT-SLOTS can be used to build this p-list. The APPEND method combination automatically appends the lists provided by the SLOTS-FOR-PRINT methods on the various subclasses. ") (:method append ((object sloted-object)) '())) (defmethod print-object ((self sloted-object) stream) (declare (stepper disable)) (print-unreadable-object (self stream :identity t :type t) (format stream "~{~S~^ ~}" (slots-for-print self))) self) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun object-identity (object) " RETURN: A string containing the object identity as printed by PRINT-UNREADABLE-OBJECT. " (declare (stepper disable)) (let ((*step-mode* :run) (*print-readably* nil)) (declare (special *step-mode*)) (let ((ident (with-output-to-string (stream) (print-unreadable-object (object stream :type nil :identity t))))) (subseq ident 3 (1- (length ident)))))) (defun call-print-parseable-object (object stream type identity thunk) " SEE: PRINT-PARSEABLE-OBJECT " (declare (stepper disable)) (let ((*step-mode* :run)) (declare (special *step-mode*)) (if *print-readably* (error 'print-not-readable :object object) (progn (format stream "~S" (append (when type (list (class-name (class-of object)))) (funcall thunk object) (when identity (list :id (object-identity object))))) object)))) (defun gen-extract-slots (ovar slots) " SEE: PRINT-PARSEABLE-OBJECT RETURN: A form building a plist of slot values. " (cons 'list (loop :for slot :in slots :collect (if (symbolp slot) (keywordize slot) `(quote ,(first slot))) :collect (if (symbolp slot) `(if (slot-boundp ,ovar ',slot) (slot-value ,ovar ',slot) '#:unbound) `(ignore-errors ,(second slot)))))) (defmacro print-parseable-object ((object stream &key (type t) identity) &rest slots) " DO: Prints on the STREAM the object as a list. If all the objects printed inside it are printed readably or with PRINT-PARSEABLE-OBJECT, then that list should be readable, at least with *READ-SUPPRESS* set to T. OBJECT: Either a variable bound to the object to be printed, or a binding list (VARNAME OBJECT-EXPRESSION), in which case the VARNAME is bound to the OBJECT-EXPRESSION during the evaluation of the SLOTS. STREAM: The output stream where the object is printed to. TYPE: If true, the class-name of the OBJECT is printed as first element of the list. IDENTITY: If true, the object identity is printed as a string in the last position of the list. SLOTS: A list of either a symbol naming the slot, or a list (name expression), name being included quoted in the list, and the expression being evaluated to obtain the value. RETURN: The object that bas been printed (so that you can use it in tail position in PRINT-OBJECT conformingly). EXAMPLE: (print-parseable-object (object stream :type t :identity t) slot-1 (:slot-2 (thing-to-list (slot-2 object))) slot-3) " `(locally (declare (stepper disable)) ,(if (symbolp object) `(call-print-parseable-object ,object ,stream ,type ,identity (lambda (,object) (declare (ignorable ,object) (stepper disable)) ,(gen-extract-slots object slots))) (destructuring-bind (ovar oval) object `(let ((,ovar ,oval)) (call-print-parseable-object ,ovar ,stream ,type ,identity (lambda (,ovar) (declare (ignorable ,ovar) (stepper disable)) ,(gen-extract-slots ovar slots)))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 8 - STRUCTURES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; (DEFMACRO DEFINE-WITH-STRUCTURE (NAME-AND-OPTIONS SLOTS) ;; " ;; NAME-AND-OPTIONS: Either a structure name or a list (name . options). ;; Valid options are: (:conc-name prefix). ;; DO: Define a macro: (WITH-{NAME} object &body body) ;; expanding to a symbol-macrolet embedding body where ;; symbol macros are defined to access the slots. ;; " ;; (LET* ((NAME (IF (SYMBOLP NAME-AND-OPTIONS) ;; NAME-AND-OPTIONS (CAR NAME-AND-OPTIONS))) ;; (CONC-NAME (IF (SYMBOLP NAME-AND-OPTIONS) ;; (CONCATENATE 'STRING (STRING NAME) "-") ;; (LET ((CONC-OPT (CAR (MEMBER :CONC-NAME ;; (CDR NAME-AND-OPTIONS) ;; :KEY (FUNCTION CAR))))) ;; (IF CONC-OPT ;; (SECOND CONC-OPT) ;; (CONCATENATE 'STRING (STRING NAME) "-")))))) ;; `(EVAL-WHEN (:COMPILE-TOPLEVEL :LOAD-TOPLEVEL :EXECUTE) ;; (DEFMACRO ;; ,(INTERN (WITH-STANDARD-IO-SYNTAX (FORMAT NIL "WITH-~A" NAME))) ;; (OBJECT &BODY BODY) ;; (IF (SYMBOLP OBJECT) ;; `(SYMBOL-MACROLET ;; ,(MAPCAR ;; (LAMBDA (SLOT) ;; (LIST SLOT ;; (LIST ;; (INTERN (WITH-STANDARD-IO-SYNTAX ;; (CONCATENATE 'STRING ;; (STRING ',CONC-NAME) (STRING SLOT)))) ;; OBJECT))) ',SLOTS) ;; ,@BODY) ;; (LET ((OBJV (GENSYM))) ;; `(LET ((,OBJV ,OBJECT)) ;; (SYMBOL-MACROLET ;; ,(MAPCAR ;; (LAMBDA (SLOT) ;; (LIST SLOT ;; (LIST ;; (INTERN (WITH-STANDARD-IO-SYNTAX ;; (CONCATENATE 'STRING ;; (STRING ',CONC-NAME) (STRING SLOT)))) ;; ;; OBJV))) ',SLOTS) ;; ,@BODY)))))))) ;;DEFINE-WITH-STRUCTURE (defmacro define-with-structure (name-and-options &rest slots) " NAME-AND-OPTIONS: Either a structure name or a list (name . options). Valid options are: (:conc-name prefix). DO: Define a macro: (WITH-{NAME} object &body body) expanding to a symbol-macrolet embedding body where symbol macros are defined to access the slots. " (let* ((name (if (symbolp name-and-options) name-and-options (car name-and-options))) (conc-name (if (symbolp name-and-options) (concatenate 'string (string name) "-") (let ((conc-opt (car (member :conc-name (cdr name-and-options) :key (function car))))) (if conc-opt (second conc-opt) (concatenate 'string (string name) "-"))))) (slot-names (mapcar (lambda (slot) (if (listp slot) (car slot) slot)) slots))) `(progn (defstruct ,name-and-options ,@slots) (defmacro ,(intern (with-standard-io-syntax (format nil "WITH-~A" name))) (object &body body) (if (symbolp object) `(symbol-macrolet ,(mapcar (lambda (slot) (list slot (list (intern (concatenate 'string (string ',conc-name) (string slot))) object))) ',slot-names) ,@body) (let ((objv (gensym))) `(let ((,objv ,object)) (symbol-macrolet ,(mapcar (lambda (slot) (list slot (list (intern (concatenate 'string (string ',conc-name) (string slot))) objv))) ',slot-names) ,@body)))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 9 - CONDITIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define-condition simple-program-error (program-error) ((format-control :initarg :format-control :reader simple-program-error-format-control) (format-arguments :initarg :format-arguments :reader simple-program-error-format-arguments)) (:report (lambda (condition stream) (format stream "~?" (simple-program-error-format-control condition) (simple-program-error-format-arguments condition))))) (defmacro handling-errors (&body body) " DO: Execute the BODY with a handler for CONDITION and SIMPLE-CONDITION reporting the conditions. " `(handler-case (progn ,@body) (simple-condition (err) (format *error-output* "~&~A:~%~?~&" (class-name (class-of err)) (simple-condition-format-control err) (simple-condition-format-arguments err)) (finish-output *error-output*)) (condition (err) (format *error-output* "~&~A:~%~A~%" (class-name (class-of err)) err) (finish-output *error-output*)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 12 - NUMBERS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun sign (n) " RETURN: -1 if N is negative, +1 if N is positive, 0 if N is 0. " (cond ((zerop n) 0) ((plusp n) 1) (t -1))) (defmacro incf-mod (&environment env place modulo &optional (increment 1)) "INCF modulo MODULO" (multiple-value-bind (vars vals store-vars writer-form reader-form) (get-setf-expansion place env) (when (cdr store-vars) (error "Can't expand this.")) `(let* (,@(mapcar (function list) vars vals)) (let ((,(car store-vars) (mod (+ ,reader-form ,increment) ,modulo))) ,writer-form)))) (defmacro decf-mod (&environment env place modulo &optional (decrement 1)) "DECF modulo MODULO" (multiple-value-bind (vars vals store-vars writer-form reader-form) (get-setf-expansion place env) (when (cdr store-vars) (error "Can't expand this.")) `(let* (,@(mapcar (function list) vars vals)) (let ((,(car store-vars) (mod (- ,reader-form ,decrement) ,modulo))) ,writer-form)))) (eval-when (:compile-toplevel :load-toplevel :execute) (declaim (inline type-equal-p)) (defun type-equal-p (t1 t2) (and (subtypep t1 t2) (subtypep t2 t1))) (defun distinct-float-types () " RETURN: a subset of (long-float double-float single-float short-float) that represents the partition of the float type for this implementation. There can be fewer than four internal representations for floats. If there are fewer distinct representations, the following rules apply: • If there is only one, it is the type single-float. In this representation, an object is simultaneously of types single-float, double-float, short-float, and long-float. • Two internal representations can be arranged in either of the following ways: □ Two types are provided: single-float and short-float. An object is simultaneously of types single-float, double-float, and long-float. □ Two types are provided: single-float and double-float. An object is simultaneously of types single-float and short-float, or double-float and long-float. • Three internal representations can be arranged in either of the following ways: □ Three types are provided: short-float, single-float, and double-float. An object can simultaneously be of type double-float and long-float. □ Three types are provided: single-float, double-float, and long-float. An object can simultaneously be of types single-float and short-float. " ;; #+emacs ;; (insert ;; (karnaugh '(s=i s=d s=l i=d i=l d=l) ;; (list "1" "21" "22" "31" "32" "4" ;; (cons "i" (lambda (s=i s=d s=l i=d i=l d=l) ;; (and (==> (and s=i s=d) i=d) ;; (==> (and s=i s=l) i=l) ;; (==> (and s=i i=d) s=d) ;; (==> (and s=i i=l) s=l) ;; ;; (==> (and s=d s=l) d=l) ;; (==> (and s=d i=d) s=i) ;; (==> (and s=d i=l) s=l) ;; (==> (and s=d d=l) s=l) ;; ;; (==> (and s=l i=l) s=i) ;; (==> (and s=l d=l) s=d) ;; ;; (==> (and i=d i=l) d=l) ;; (==> (and i=d d=l) i=l) ;; ;; (==> (and s=i s=l) s=d) ;; (==> (and s=l s=d) s=i) ;; ;; (==> (not s=i) (not (or s=d s=l))) ;; (==> (not s=d) (not s=l)) ;; (==> (not i=d) (not i=l)) ;; (==> (not d=l) (not i=l)) ;; ;; )))))) ;; ;; 1 short-float=single-float=double-float=long-float ;; 21 short-float | single-float=double-float=long-float ;; 22 short-float=single-float | double-float=long-float ;; 31 short-float | single-float | double-float=long-float ;; 32 short-float=single-float | double-float | long-float ;; 4 short-float | single-float | double-float | long-float ;; not conforming configuruations: ;; n1 short-float=single-float=double-float | long-float ;; n2 short-float | single-float=double-float | long-float ;; ;; +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+ ;; | s=i | s=d | s=l | i=d | i=l | d=l | 1 | 21 | 22 | 31 | 32 | 4 | n1 | n2 | ;; +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+ ;; | YES | YES | YES | YES | YES | YES | v | | | | | | | | ;; | YES | YES | NO | YES | NO | NO | | | | | | | v | | ;; | NO | NO | NO | YES | YES | YES | | v | | | | | | | ;; | NO | NO | NO | YES | NO | NO | | | | | | | | v | ;; | YES | NO | NO | NO | NO | YES | | | v | | | | | | ;; | YES | NO | NO | NO | NO | NO | | | | | v | | | | ;; | NO | NO | NO | NO | NO | YES | | | | v | | | | | ;; | NO | NO | NO | NO | NO | NO | | | | | | v | | | ;; +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+ (let ((s=i (type-equal-p 'short-float 'single-float)) (i=d (type-equal-p 'single-float 'double-float)) (d=l (type-equal-p 'double-float 'long-float))) (if i=d (if s=i (if d=l '(single-float) #|1|# '(single-float long-float) #|n1|#) (if d=l '(short-float single-float) #|21|# '(short-float single-float long-float) #|n2|#)) (if s=i (if d=l '(single-float double-float) #|22|# '(single-float double-float long-float) #|32|#) (if d=l '(short-float single-float double-float) #|31|# '(short-float single-float double-float long-float) #|4|#))))) (defun generate-distinct-float-types-typecase (operator expression clauses) (let ((types (distinct-float-types))) `(,operator ,expression ,@(loop :for (type . body) :in clauses :when (member type types) :collect `(,type ,@body)))))) (defmacro float-typecase (expression &body clauses) " EXPRESSION: an expression evaluate to some value. CLAUSES: typecase clauses where the type is one of the standard FLOAT direct subtypes, ie. one of (SHORT-FLOAT SINGLE-FLOAT DOUBLE-FLOAT LONG-FLOAT). NOTE: Implementations may conflate the various subtypes of FLOAT. When two float types are conflated, some implementation will signal a warning on any typecase that have them in separate clauses. Since they're the same type, we can as well remove the duplicate clauses. SEE: CLHS Type SHORT-FLOAT, SINGLE-FLOAT, DOUBLE-FLOAT, LONG-FLOAT DO: Expands to a TYPECASE where only the clauses with unique float types are present. " (generate-distinct-float-types-typecase 'typecase expression clauses)) (defmacro float-etypecase (expression &body clauses) " EXPRESSION: an expression evaluate to some value. CLAUSES: etypecase clauses where the type is one of the standard FLOAT direct subtypes, ie. one of (SHORT-FLOAT SINGLE-FLOAT DOUBLE-FLOAT LONG-FLOAT). NOTE: Implementations may conflate the various subtypes of FLOAT. When two float types are conflated, some implementation will signal a warning on any typecase that have them in separate clauses. Since they're the same type, we can as well remove the duplicate clauses. SEE: CLHS Type SHORT-FLOAT, SINGLE-FLOAT, DOUBLE-FLOAT, LONG-FLOAT DO: Expands to a ETYPECASE where only the clauses with unique float types are present. " (generate-distinct-float-types-typecase 'etypecase expression clauses)) (defmacro float-ctypecase (expression &body clauses) " EXPRESSION: an expression evaluate to some value. CLAUSES: ctypecase clauses where the type is one of the standard FLOAT direct subtypes, ie. one of (SHORT-FLOAT SINGLE-FLOAT DOUBLE-FLOAT LONG-FLOAT). NOTE: Implementations may conflate the various subtypes of FLOAT. When two float types are conflated, some implementation will signal a warning on any typecase that have them in separate clauses. Since they're the same type, we can as well remove the duplicate clauses. SEE: CLHS Type SHORT-FLOAT, SINGLE-FLOAT, DOUBLE-FLOAT, LONG-FLOAT DO: Expands to a CTYPECASE where only the clauses with unique float types are present. " (generate-distinct-float-types-typecase 'ctypecase expression clauses)) (defun +epsilon (float) "Returns the float incremented by the smallest increment possible." (multiple-value-bind (significand exponent sign) (decode-float float) (* sign (scale-float (if (minusp sign) (- significand (float-etypecase float (long-float long-float-negative-epsilon) (double-float double-float-negative-epsilon) (single-float single-float-negative-epsilon) (short-float short-float-negative-epsilon))) (+ significand (float-etypecase float (long-float long-float-epsilon) (double-float double-float-epsilon) (single-float single-float-epsilon) (short-float short-float-epsilon)))) exponent)))) (defun -epsilon (float) "Returns the float incremented by the smallest increment possible." (multiple-value-bind (significand exponent sign) (decode-float float) (* sign (scale-float (if (minusp sign) (+ significand (float-etypecase float (long-float long-float-negative-epsilon) (double-float double-float-negative-epsilon) (single-float single-float-negative-epsilon) (short-float short-float-negative-epsilon))) (- significand (float-etypecase float (long-float long-float-epsilon) (double-float double-float-epsilon) (single-float single-float-epsilon) (short-float short-float-epsilon)))) exponent)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 14 - CONSES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun maximize (predicate list) " RETURN: The maximum value and the item in list for which predicate is the maximum. " (do ((max-value nil) (max-item nil) (list list (cdr list)) (value)) ((null list) (values max-value max-item)) (setq value (funcall predicate (car list))) (when (or (null max-value) (> value max-value)) (setq max-value value max-item (car list))))) ;;MAXIMIZE ;; (DEFUN COMPUTE-CLOSURE (FUN SET) ;; " ;; FUN: set --> P(set) ;; x |--> { y } ;; RETURN: The closure of fun on the set. ;; NOTE: Not a lisp closure! ;; EXAMPLE: (compute-closure (lambda (x) (list (mod (* x 2) 5))) '(1)) --> (2 4 3 1) ;; " ;; (LOOP ;; :FOR NEW-SET = (DELETE-DUPLICATES (UNION SET (MAPCAN FUN SET))) ;; :WHILE (SET-EXCLUSIVE-OR NEW-SET SET) ;; :DO (SETF SET NEW-SET) ;; :FINALLY (RETURN NEW-SET))) (defun compute-closure (fun set) (warn "The function ~S has been renamed ~S, please update your programs." 'compute-closure 'transitive-closure) (transitive-closure fun set)) (defun transitive-closure (fun set &key (test 'eql) (use 'list)) " FUN: set --> P(set) x |--> { y } SET: A sequence. TEST: EQL, EQUAL or EQUALP USE: Either HASH-TABLE or LIST; specifies the data structure used for the intermediary sets. RETURN: A list containing closure of fun on the set. EXAMPLE: (transitive-closure (lambda (x) (list (mod (* x 2) 5))) '(1)) --> (3 4 2 1) NOTE: This version avoids calling FUN twice with the same argument. " ;; current -> fun -> follows ;; closure + current -> closure ;; follows - closures -> current (ecase use (list (let ((closure '()) (current '()) (follows '())) (macrolet ((enter (item list) `(pushnew ,item ,list :test test)) (enter-all (items list) `(setf ,list (delete-duplicates (append ,items ,list) :test test)))) (setf current (coerce set 'list)) (loop :do (loop ;; current -> fun -> follows :for item :in current :initially (setf follows '()) :do (enter-all (funcall fun item) follows) ;; closure + current -> closure (enter item closure)) (loop ;; follows - closures -> current :for item :in follows :initially (setf current '()) :unless (member item closure :test test) :do (enter item current)) :while current :finally (return-from transitive-closure closure))))) (hash-table (let ((closure (make-hash-table :test test)) (current (make-hash-table :test test)) (follows (make-hash-table :test test))) (flet ((enter (item hash) (setf (gethash item hash) t)) (enter-all (items hash) (map nil (lambda (item) (setf (gethash item hash) t)) items))) (declare (inline enter enter-all)) (enter-all set current) (loop :do (loop ;; current -> fun -> follows :for item :being :each :hash-key :in current :initially (clrhash follows) :do (enter-all (funcall fun item) follows) ;; closure + current -> closure (enter item closure)) (loop ;; follows - closures -> current :for item :being :each :hash-key :in follows :initially (clrhash current) :unless (gethash item closure) :do (enter item current)) :while (plusp (hash-table-count current)) :finally (return-from transitive-closure (loop :for item :being :each :hash-key :in closure :collect item)))))))) ;; (array->list array) --> (coerce array 'list) ;; (DEFUN ARRAY->LIST (A) (MAP 'LIST (FUNCTION IDENTITY) A));;ARRAY->LIST (defun topological-sort (nodes lessp) " RETURN: A list of NODES sorted topologically according to the partial order function LESSP. If there are cycles (discounting reflexivity), then the list returned won't contain all the NODES. " (loop :with sorted = '() :with incoming = (map 'vector (lambda (to) (loop :for from :in nodes :when (and (not (eq from to)) (funcall lessp from to)) :sum 1)) nodes) :with q = (loop :for node :in nodes :for inco :across incoming :when (zerop inco) :collect node) :while q :do (let ((n (pop q))) (push n sorted) (loop :for m :in nodes :for i :from 0 :do (when (and (and (not (eq n m)) (funcall lessp n m)) (zerop (decf (aref incoming i)))) (push m q)))) :finally (return (nreverse sorted)))) ;; (mapc (function print-cycle) (find-cycles (list-all-packages) ;; (function package-use-list))) ;; (find-cycles (list-all-packages) (function package-use-list)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 15 - ARRAYS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun vector-init (vector constructor) " DO: Sets all the slots in vector to the successive results of the function CONSTRUCTOR called with integers from 0 up s to the dimension of the VECTOR. RETURN: VECTOR " (do ((index 0 (1+ index))) ((>= index (array-dimension vector 0))) (setf (aref vector index) (funcall constructor index))) vector) (defun undisplace-array (array) " RETURN: The fundamental array and the start and end positions into it of a displaced array. AUTHOR: Erik Naggum <[email protected]> " (let ((length (length array)) (start 0)) (loop (multiple-value-bind (to offset) (array-displacement array) (if to (setq array to start (+ start offset)) (return (values array start (+ start length)))))))) (defun dichotomy (matchp start end) " MATCHP: A function taking an integer between [START,END[, and returning an order (signed integer). START: The minimum integer. END: The maximum integer+1. RETURN: (values found index order) POST: (<= start index (1- end)) +-------------------+----------+-------+----------+ | Case | found | index | order | +-------------------+----------+-------+----------+ | x < a[i] | FALSE | start | less | | a[i] < x < a[i+1] | FALSE | i | greater | | x = a[i] | TRUE | i | equal | | a[max] < x | FALSE | end-1 | greater | +-------------------+----------+-------+----------+ " (let* ((curmin start) (curmax end) (index (truncate (+ curmin curmax) 2)) (order (funcall matchp index))) (loop :while (and (/= 0 order) (/= curmin index)) :do ;; (format t "~&min=~S cur=~S max=~S <~S>~%" curmin index curmax (funcall matchp index)) (if (minusp order) (setf curmax index) (setf curmin index)) (setf index (truncate (+ curmin curmax) 2)) (setf order (funcall matchp index))) ;; (format t "~&min=~S cur=~S max=~S <~S> []~%" curmin index curmax (funcall matchp index)) (when (and (< start index) (minusp order)) (setf order 1) (decf index)) (assert (or (minusp (funcall matchp index)) (and (plusp (funcall matchp index)) (or (>= (1+ index) end) (minusp (funcall matchp (1+ index))))) (= (funcall matchp index) 0))) (values (zerop order) index order))) (defun dichotomy-search (vector value compare &key (start 0) (end (length vector)) (key (function identity))) " PRE: entry is the element to be searched in the table. (<= start end) RETURN: (values found index order) POST: (<= start index end) +-------------------+----------+-------+----------+ | Case | found | index | order | +-------------------+----------+-------+----------+ | x < a[min] | FALSE | min | less | | a[i] < x < a[i+1] | FALSE | i | greater | | x = a[i] | TRUE | i | equal | | a[max] < x | FALSE | max | greater | +-------------------+----------+-------+----------+ " (if (zerop (length vector)) (values nil 0 -1) (let* ((curmin start) (curmax end) (index (truncate (+ curmin curmax) 2)) (order (funcall compare value (funcall key (aref vector index)))) ) (loop :while (and (/= 0 order) (/= curmin index)) :do ;; (FORMAT T "~&min=~S cur=~S max=~S key=~S <~S> [cur]=~S ~%" CURMIN INDEX CURMAX VALUE (FUNCALL COMPARE VALUE (FUNCALL KEY (AREF VECTOR INDEX))) (AREF VECTOR INDEX)) (if (< order 0) (setf curmax index) (setf curmin index)) (setf index (truncate (+ curmin curmax) 2)) (setf order (funcall compare value (funcall key (aref vector index))))) (when (and (< start index) (< order 0)) (setf order 1) (decf index)) (assert (or (minusp (funcall compare value (funcall key (aref vector index)))) (and (plusp (funcall compare value (funcall key (aref vector index)))) (or (>= (1+ index) end) (minusp (funcall compare value (funcall key (aref vector (1+ index))))))) (zerop (funcall compare value (funcall key (aref vector index))))) (index) "The compare function is invalid: value<a[~D] or a[~:*~D]<value<a[~D] or a[~D]<value or a[~0@*~D]=value" index (1+ index) end) (values (= order 0) index order)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 16 - STRINGS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmacro sconc (&rest args) "Concatenate strings." `(concat ,@args)) (defun concat (&rest items) (with-output-to-string (*standard-output*) (dolist (item items) (typecase item (string (write-string item *standard-output*)) (sequence (write-sequence item *standard-output*)) (t (with-standard-io-syntax (format *standard-output* "~A" item))))))) (defmacro define-case-macro (name test) `(defmacro ,name (keyform &body clauses) ,(format nil " DO: A CASE, but using ~A as test instead of the EQL test. " test) (let ((key (gensym "KEY"))) `(let ((,key ,keyform)) (cond ,@(mapcar (lambda (clause) (if (or (eq (car clause) 'otherwise) (eq (car clause) 't)) `(t ,@(cdr clause)) `(,(typecase (car clause) ((or string symbol character) `(,',test ,key ',(car clause))) (list `(member ,key ',(car clause) :test (function ,',test))) (t (error "Bad ICASE clause: ~S~% expected type STRING-DESIGNATOR or LIST of STRING-DESIGNATOR" clause))) ,@(cdr clause)))) clauses)))))) (define-case-macro scase string=) (define-case-macro iscase string-equal) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 17 - SEQUENCES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun nsubseq (sequence start &optional (end nil)) " RETURN: When the SEQUENCE is a vector, the SEQUENCE itself, or a dispaced array to the SEQUENCE. When the SEQUENCE is a list, it may destroy the list and reuse the cons cells to make the subsequence. " (if (vectorp sequence) (if (and (zerop start) (or (null end) (= end (length sequence)))) sequence (make-array (- (if end (min end (length sequence)) (length sequence)) start) :element-type (array-element-type sequence) :displaced-to sequence :displaced-index-offset start)) (let ((result (nthcdr start sequence))) (when end ;; TODO: when end is bigger than (length sequence), this (setf cdr) fails: (setf (cdr (nthcdr (- end start -1) sequence)) nil)) result))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; 18 - HASH-TABLES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun hash-table-keys (table) "Returns a list of the keys in the TABLE." (let ((result '())) (maphash (lambda (k v) (declare (ignore v)) (push k result)) table) result)) (defun hash-table-values (table) "Returns a list of the values in the TABLE." (let ((result '())) (maphash (lambda (k v) (declare (ignore k)) (push v result)) table) result)) (defun hash-table-entries (table) "Returns an a-list of the entries (key . val) in the TABLE." (let ((result '())) (maphash (lambda (k v) (push (cons k v) result)) table) result)) (defgeneric hash-table-projection (keys table) (:documentation "Returns a new hash-table containing the same values as in TABLE but only for the given keys. KEYS can be a list of keys, or a generalized boolean function called with key and value.")) (defmethod hash-table-projection ((keys null) (table hash-table)) (make-hash-table :test (hash-table-test table) :size 0 :rehash-size (hash-table-rehash-size table) :rehash-threshold (hash-table-rehash-threshold table))) (defmethod hash-table-projection ((keys cons) table) (let ((result (make-hash-table :test (hash-table-test table) :size (length keys) :rehash-size (hash-table-rehash-size table) :rehash-threshold (hash-table-rehash-threshold table)))) (dolist (key keys result) (setf (gethash key result) (gethash key table))))) (defmethod hash-table-projection ((keys function) table) (let ((result (make-hash-table :test (hash-table-test table) :size (hash-table-count table) :rehash-size (hash-table-rehash-size table) :rehash-threshold (hash-table-rehash-threshold table)))) (maphash (lambda (key value) (when (funcall keys key value) (setf (gethash key result) value))) table) result)) (defun hash-table-select (predicate table) " RETURN: An a-list of (k . v) from the TABLE such as (funcall PREDICATE k v) is true. " (let ((result '())) (maphash (lambda (k v) (when (funcall predicate k v) (push (cons k v) result))) table) result)) (defun hash-table-path (table &rest keys) "Given a hash-table that may contain other hash-table, walks down the path of KEYS, returning the ultimate value" (if (null keys) table (apply (function hash-table-path) (gethash (first keys) table) (rest keys)))) (defun copy-hash-table (table) " TABLE: (OR NULL HASH-TABLE) RETURN: If TABLE is NIL, then NIL, else a new HASH-TABLE with the same TEST, SIZE, REHASH-THRESHOLD REHASH-SIZE and KEY->VALUE associations than TABLE. (Neither the keys nor the values are copied). " (check-type table (or null hash-table)) (when table (let ((copy (make-hash-table :test (hash-table-test table) :size (hash-table-size table) :rehash-threshold (hash-table-rehash-threshold table) :rehash-size (hash-table-rehash-size table)))) (maphash (lambda (k v) (setf (gethash k copy) v)) table) copy))) (defun hashtable (&key (test (function eql)) (size nil sizep) (rehash-size nil rehash-size-p) (rehash-threshold nil rehash-threshold-p) elements) "Creates a new hash-table, filled with the given ELEMENTS. ELEMENTS must be a list of lists of two items, the key and the value. Note: we use the name HASHTABLE to avoid name collision." (let ((table (apply (function make-hash-table) :test test (append (when sizep (list :size size)) (when rehash-size-p (list :rehash-size rehash-size)) (when rehash-threshold-p (list :rehash-threshold rehash-threshold)))))) (dolist (item elements table) (setf (gethash (first item) table) (second item))))) (defun map-into-hash-table (sequence &key (key (function identity)) (value (function identity)) (test (function eql)) (size nil sizep) (rehash-size nil rehash-size-p) (rehash-threshold nil rehash-threshold-p)) " Creates a new hash-table, filled with the associations obtained by applying the function KEY and the function VALUE on each element of the SEQUENCE. The other key parameter are passed to MAKE-HASH-TABLE. " (let ((table (apply (function make-hash-table) :test test (append (when sizep (list :size size)) (when rehash-size-p (list :rehash-size rehash-size)) (when rehash-threshold-p (list :rehash-threshold rehash-threshold)))))) (map nil (lambda (element) (setf (gethash (funcall key element) table) (funcall value element))) sequence) table)) (defun hash-table-to-sexp (table) "Returns a sexp containing the hash-table data." (list 'hash-table :test (hash-table-test table) :size (hash-table-count table) :rehash-size (hash-table-rehash-size table) :rehash-threashold (hash-table-rehash-threshold table) :elements (let ((entries '())) (maphash (lambda (k v) (push (cons k v) entries)) table) entries))) (defun sexp-to-hash-table (sexp) "Create a new hash-table containing the data described in the sexp \(produced by HASH-TABLE-TO-SEXP." (check-type sexp list) (assert (eq 'hash-table (first sexp))) (let* ((plist (rest sexp)) (test (getf plist :test 'eql)) (size (getf plist :size 8)) (rehash-size (getf plist :rehash-size 1.5)) (rehash-threshold (getf plist :rehash-threshold 0.85)) (elements (getf plist :elements)) (table (make-hash-table :test test :size size :rehash-size rehash-size :rehash-threshold rehash-threshold))) (loop :for (k . v) :in elements :do (setf (gethash k table) v)) table)) (defun print-hashtable (table &optional (stream *standard-output*)) "Prints readably the hash-table, using #. and the HASHTABLE function." (format stream "#.(HASHTABLE :TEST (FUNCTION ~S) :SIZE ~D ~%~ ~& :REHASH-SIZE ~A :REHASH-THRESHOLD ~A~%~ ~& :ELEMENTS '(" (hash-table-test table) (hash-table-count table) (hash-table-rehash-size table) (hash-table-rehash-threshold table)) (maphash (lambda (k v) (format stream "~%(~S ~S)" k v)) table) (format stream "))") ;; (format stream "#.~S" ;; `(let ((table (make-hash-table ;; :test (function ;; ,(case (hash-table-test table) ;; #+clisp (EXT:FASTHASH-EQ 'eq) ;; #+clisp (EXT:FASTHASH-EQL 'eql) ;; #+clisp (EXT:FASTHASH-EQUAL 'equal) ;; (otherwise (hash-table-test table)))) ;; :size ,(hash-table-size table)))) ;; (setf ,@(let ((assignments '())) ;; (maphash (lambda (k v) ;; (push `(quote ,v) assignments) ;; (push `(gethash ',k table) assignments)) ;; table) ;; assignments)) ;; table)) table) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; TRACING ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defmacro tracing (&body body) " TRACE works only on non-CL functions. This macro will work somewhat on any form in body. " `(progn ,@(mapcan (lambda (form) (let ((results (gensym))) (list `(format *trace-output* "~&~S~%" ',form) `(let ((,results (multiple-value-list ,form))) (format *trace-output* "~&--> ~{~S~^~% ~}" ,results) (values-list ,results))))) body))) ;; (let ((a (1+ b)) ;; (b (1+ a))) ;; (print (list a b))) ;; ;; (let ((#:a1 (let ((r (1+ b))) ;; (format t "~S = ~S = ~S~%" '#:a1 '(1+ b) r) ;; r)) ;; (#:b1 (let ((r (1+ a))) ;; (format t "~S = ~S = ~S~%" '#:b1 '(1+ a) r) ;; r)) ;; (a (progn ;; (format t "~S = ~S = ~S~%" 'a '#:a1 #:a1) ;; #:a1)) ;; (b (progn ;; (format t "~S = ~S = ~S~%" 'b '#:b1 #:b1) ;; #:b1))) ;; (print (list a b))) (defmacro tracing-let (clauses &body body) " Like LET, but prints on the *trace-output* the value of the bindings. " (let ((vals (mapcar (lambda (clause) (gensym (symbol-name (if (symbolp clause) clause (first clause))))) clauses)) (res (gensym))) `(let ,(mapcar (lambda (val expr) `(,val (let ((,res ,expr)) (format *trace-output* "~&LET ~S = ~S --> ~S~%" ',val ',expr ,res) ,res))) vals (mapcar (lambda (clause) (if (symbolp clause) nil (second clause))) clauses)) (let ,(mapcar (lambda (var val) `(,var (progn (format *trace-output* "~&LET ~S = ~S --> ~S~%" ',var ',val ,val) ,val))) (mapcar (lambda (clause) (if (symbolp clause) clause (first clause))) clauses) vals) ,@body)))) (defmacro tracing-let* (clauses &body body) " Like LET*, but prints on the *trace-output* the value of the bindings. " (if (null clauses) `(progn ,@body) `(tracing-let (,(first clauses)) (tracing-let* ,(rest clauses) ,@body)))) (defmacro tracing-labels (defs &body body) "This macro is a replacement for LABELS that traces the calls of the local functions." `(cl:labels ,(mapcar (lambda (def) (let ((arguments (make-argument-list (parse-lambda-list (second def) :ordinary))) (res (gensym "RESULTS"))) (when (null (first (last arguments))) (setf arguments (butlast arguments))) `(,(first def) ,(second def) ,@(when (stringp (third def)) (list (third def))) (format *trace-output* "~&Entering ~A (~{~{:~A ~S~}~^ ~})~%" ',(first def) (list ,@(mapcar (lambda (arg) `(list ',arg ,arg)) arguments))) (unwind-protect (let (,res) (format *trace-output* "~&Exiting ~A --> ~{~S~^; ~}~%" ',(first def) (setf ,res (multiple-value-list (progn ,@(cddr def))))) (values-list ,res)) (format *trace-output* "~&Unwinding ~A~%" ',(first def)))))) defs) ,@body)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Binary decision tree ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (eval-when (:compile-toplevel :load-toplevel :execute) (defun infix-to-tree (sequence) (labels ((itt (items start end) (cond ((= start end) nil) ((= (1+ start) end) (list (aref items start))) (t (let ((pivot (truncate (/ (+ start end) 2)))) (list (aref items pivot) (itt items start pivot) (itt items (1+ pivot) end))))))) (let ((vect (coerce sequence 'vector))) (itt vect 0 (length vect))))) (defun map-tree-postfix (fun tree) (if (null tree) nil (funcall fun (first tree) (map-tree-postfix fun (second tree)) (map-tree-postfix fun (third tree)))))) (defmacro decision-tree (expression &rest clauses) " CLAUSES: Each clause is of the forms: (less|:less . <body>) (<real> . <body>) DO: Evaluate the expression, which must be a real, and generate a binary decision tree to select the <body> of the clause whose limit is <= the expression and the next clause limit is > the expression. " (let ((vexpr (gensym)) (less (when (and (symbolp (first (first clauses))) (string-equal 'less (first (first clauses)))) (pop clauses))) (clauses (sort (coerce clauses 'vector) (function <) :key (function car)))) `(let ((,vexpr ,expression)) ,(map-tree-postfix (let ((index -1)) (flet ((gen-case () (incf index) (if (zerop index) `(progn ,@(cdr less)) `(progn ,@(cdr (aref clauses (1- index))))))) (lambda (node left right) (if (and (null left) (null right)) `(if (< ,vexpr ,(car node)) ,(gen-case) ,(gen-case)) `(if (< ,vexpr ,(car node)) ,left ,(if (null right) (gen-case) right)))))) (infix-to-tree clauses))))) (defun xor (a b) "Return A ⊻ B" (or (and a (not b)) (and (not a) b))) (defun equiv (a b) "Return A ⇔ B" (eql (not a) (not b))) (defun imply (p q) "Return P ⇒ Q" (or (not p) q)) ;; (defun set-equal (a b) ;; "Return A ⊂ B ∧ A ⊃ B" ;; (and (subsetp a b) (subsetp b a))) (defun d-dms (d) "Convert a decimal value into an integer and 60th and 3600th encoded as a \"HH:MM:SS.sss\" string." (let* ((epsilon 0.000001d0) (hou (floor d)) (min* (* 60.0d0 (- d hou))) (min (floor min*)) (sec* (* 60.0d0 (- min* min))) (sec)) (if (< (- 60.0d0 epsilon) sec*) (progn (setf min (+ min 1.0)) (if (<= 60.0d0 min) (setf min 0.0d0 hou (+ 1.0d0 hou))) (setf sec* (- (+ epsilon sec*) (floor (+ epsilon sec*)))))) (setf sec sec*) (if (< (- sec (floor sec)) 0.000001d0) (format nil "~D:~2,'0D:~2,'0D" hou min sec) (if (< (- 1.0d0 0.000001d0) (- sec (floor sec))) (format nil "~D:~2,'0D:~2,'0D" hou min (+ 0.000001d0 sec)) (format nil "~D:~2,'0D:~9,6,,,'0F" hou min sec))))) (defun dms-d (arg &rest rest) "Convert value given as an integer and 60th and 3600th, encoded as a \"HH:MM:SS.sss\" string, into a decimal value." (if (stringp arg) (let* ((one (position #\: arg)) (hou (parse-integer (subseq arg 0 one))) (two (if (null one) nil (position #\: arg :start (+ one 1)))) (min (if (null one) 0d0 (parse-integer (subseq arg (+ one 1) two)))) (sec (if (null two) 0d0 (let ((value (read-from-string (subseq arg (+ two 1))))) (assert (typep value 'real)) value)))) (if (null rest) (+ hou (/ min 60.0d0) (/ sec 3600.0d0)) (error "DMS-D expects either one string or one to three numbers."))) (let ((hou arg) (min (if (null (first rest)) 0d0 (first rest))) (sec (if (null (second rest)) 0d0 (second rest)))) (+ hou (/ min 60.0d0) (/ sec 3600.0d0))))) ;;;; THE END ;;;;
96,570
Common Lisp
.lisp
2,023
37.47652
180
0.485068
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
b99dcf38a8c58d0970a2c7cc4b2cd4c4bf16a2a651acda329a11d77585b0d167
5,092
[ -1 ]
5,093
a-star.lisp
informatimago_lisp/common-lisp/cesarum/a-star.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: a-star.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Implements the A* algorithm. ;;;; cf. http://gabrielgambetta.com/path1.html ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2014-10-22 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2014 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.A-STAR" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY") (:export "+INFINITY+" "FIND-PATH") (:documentation "The A* algorithm.")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.A-STAR") (defconstant +infinity+ most-positive-long-float) (defun find-path (successors previous set-previous cost set-cost estimate-distance goalp start-node goal-node) " DO: Implement the A* algorithm. SUCCESSORS: a function giving for each node, the list of its successors. PREVIOUS: a getter giving the current previous node for the given node. SET-PREVIOUS: a setter to set the current previous node for the given node. (lambda (new-previous node)) COST: a getter giving the current cost of the given node. The default should be +INFINITY+. SET-COST: a setter setting the current cost of the given node. (lambda (new-cost node)) ESTIMATE-DISTANCE: a function of two nodes returning a cost estimate of the distance between them. GOALP: a predicate indicating whether the node is the GOAL-NODE (or close enough). START-NODE: the start node of the searched path. GOAL-NODE: the end node of the searched path. RETURN: a path, ie. a list of nodes from START-NODE to GOAL-NODE. " (with-functions (successors previous set-previous cost set-cost estimate-distance goalp) (flet ((build-path (node) (loop :with path = '() :for current = node :then (previous current) :while current :do (push current path) :finally (return path))) (choose-node (reachable) (loop :with min-cost = +infinity+ :with best-node = nil :for node :in reachable :for cost-start-to-node = (cost node) :for cost-node-to-goal = (estimate-distance node goal-node) :for total-cost = (+ cost-start-to-node cost-node-to-goal) :do (print (list node '/ cost-start-to-node '+ cost-node-to-goal '= total-cost '/ min-cost)) :when (< total-cost min-cost) :do (setf min-cost total-cost best-node node) :finally (return best-node)))) (declare (inline build-path choose-node)) (set-cost 0 start-node) (loop :with reachable = (list start-node) :with explored = '() :while reachable :do (let ((node (choose-node reachable))) (when (goalp node) (return-from find-path (build-path node))) (setf reachable (delete node reachable)) (push node explored) (let ((new-reachable (set-difference (successors node) explored))) (dolist (adjacent new-reachable) (unless (member adjacent reachable) (push adjacent reachable)) (let ((new-cost (1+ (cost node)))) (when (< new-cost (cost adjacent)) (set-previous node adjacent) (set-cost new-cost adjacent)))))))))) ;;;; THE END ;;;;
4,923
Common Lisp
.lisp
107
37.850467
107
0.573006
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
b00abe5bcfb6e91c91c655cb6f5fe5bde657672465c08d9cd91a79087a3c9c2b
5,093
[ -1 ]
5,094
dfa.lisp
informatimago_lisp/common-lisp/cesarum/dfa.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: dfa.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Implements a DFA, Deterministic Finite Automaton ;;;; (or Deterministic Finite State Machine). ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2012-02-01 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2012 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DFA" (:use "COMMON-LISP") (:export "DFA" "DFA-STATE" "DEFINE-STATE-MACHINE" "ON-ENTRY" "ON-EXIT" "GO-TO-STATE") (:documentation " This package implements a DFA, Deterministic Finite Automaton (or Deterministic Finite State Machine). A DFA has a state. Our DFAs also have a set of slots. Each DFA is implemented as a class. Events are represented as generic functions called with the DFA instance as first argument (and optionnaly other arguments). They are specialized on each specific class of DFA they're applicable to. Example: (define-state-machine test-dfa :slots ((data :initarg :data :initform nil :accessor data)) :initial zero :states ((zero (:entry () (print `(entering zero))) (:exit () (print `(exiting zero))) (got-a (sym) (push (cons 'a sym) data)) (got-b (sym) (push (cons 'b sym) data) (go-to-state one sym))) (one (:entry (sym) (print `(entering one ,sym))) (:exit () (print `(exiting one))) (got-a (sym) (push (cons 'a sym) data)) (got-b (sym) (push (cons 'b sym) data) (go-to-state zero)))) :documentation \"A test DFA\") (defparameter *d* (make-test-dfa '())) prints: (entering zero) --> *d* (got-a *d* 'a) --> ((a . a)) (got-b *d* 'b) prints: (exiting zero) (entering one b) --> (entering one b) (got-a *d* 'a) --> ((a . a) (b . b) (a . a)) (slot-value *d* 'data) --> ((a . a) (b . b) (a . a)) License: AGPL3 Copyright Pascal J. Bourguignon 2012 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DFA") (defgeneric dfa-state (dfa) (:documentation "The state of the DFA.")) (defclass dfa () ((state :initarg :state :accessor dfa-state)) (:documentation " A base class for DFAs. A DFA has a state, and transitions from one state to another can be performed by event methods. ")) (defmethod print-object ((self dfa) stream) "Prints the DFA as an unreadable object, and showing its state." (print-unreadable-object (self stream :identity t :type t) (ignore-errors (format stream ":STATE ~S" (dfa-state self)))) self) (defgeneric on-entry (dfa state &rest rest) (:documentation " This generic function is called on entry into the state, ie. at the end of the transition, when the state has been updated. (Methods may further change the state). The REST arguments are those passed to the event. ") (:method (dfa state &rest rest) (declare (ignore dfa state rest)) ;; do nothing by default. (values))) (defgeneric on-exit (dfa state &rest rest) (:documentation " This generic function is called on exit from the state, ie. at the beginning of the transition, before the state changes. The REST arguments are those passed to the event. ") (:method (dfa state &rest rest) (declare (ignore dfa state rest)) ;; do nothing by default. (values))) ;; (make-<name> initial-slot-value...) ;; (event1 <dfa> ...) (eval-when (:compile-toplevel :load-toplevel :execute) ;; Note we need these definitions at compilation-time for they're ;; used in the DEFINE-STATE-MACHINE macro. (defstruct dfa-event "Events are implemeted as a method on the DFA objects. Each method dispatches on the state of the DFA." name lambda-list state-body-map) (defstruct dfa-entrex " Entrexes are on-Entry and on-Exit actions. They're implemented as normal functions specific to each DFA state. " name state lambda-list body) (defun collect-events (states) " STATES: an A-list of state-name and events. Each event is a list containing the name of the event (a symbol), a lambda list, followed by the body of the event in that state. Returns the list of dfa-events and the list of dfa-entrexes collected from the STATES. " (let ((entrexes '()) (events '())) (dolist (state states) (destructuring-bind (state-name &rest evs) state (dolist (ev evs) (destructuring-bind (name lambda-list &body body) ev (case name ((:entry :exit) (when (find-if (lambda (entrex) (and (eql name (dfa-entrex-name entrex)) (eql state-name (dfa-entrex-state entrex)))) entrexes) (error "Duplicate ~A for state ~S" name state-name)) (push (make-dfa-entrex :name name :state state-name :lambda-list lambda-list :body body) entrexes)) (otherwise (let ((event (find name events :key (function dfa-event-name)))) (if event (progn (assert (equalp lambda-list (dfa-event-lambda-list event))) (push (cons state-name body) (dfa-event-state-body-map event))) (push (make-dfa-event :name name :lambda-list lambda-list :state-body-map (list (cons state-name body))) events))))))))) (values events entrexes))) (defun state-names (states) "The list of names of states." (mapcar (function first) states)) (defun slot-names (slots) "The list of names of slots." (mapcar (lambda (slot) (if (symbolp slot) slot (first slot))) slots)) (defmacro with-go-to-state ((dfa-var state-names) &body body) "Execute the BODY in a context where GO-TO-STATE is defined as a macro to transition to a new state." (let ((vgts (gensym "GO-TO-STATE-"))) `(flet ((,vgts (dfa state &rest arguments) (on-exit dfa (dfa-state dfa)) (setf (dfa-state dfa) state) (apply (function on-entry) dfa state arguments))) (macrolet ((go-to-state (state &rest arguments) (assert (member state ',state-names)) (list* ',vgts ',dfa-var (list 'quote state) arguments))) ,@body)))) (defun generate-entrex-method (dfa-class slot-names state-names entrex) " Generate the entrex method. DFA-CLASS: name of the DFA. The entrex method is named either ON-ENTRY or ON-EXIT and dispatches on the DFA class and the state name. " (let* ((vdfa 'dfa) (vstate (gensym "STATE-")) (vrest (gensym "REST-")) (body `(with-go-to-state (,vdfa ,state-names) ,@(dfa-entrex-body entrex))) (body (if (dfa-entrex-lambda-list entrex) `(destructuring-bind ,(dfa-entrex-lambda-list entrex) ,vrest ,body) `(progn (assert (null ,vrest)) ,body))) (body (if slot-names `(with-slots ,slot-names ,vdfa ,body) body))) `(defmethod ,(ecase (dfa-entrex-name entrex) ((:entry) 'on-entry) ((:exit) 'on-exit)) ((,vdfa ,dfa-class) (,vstate (eql ',(dfa-entrex-state entrex))) &rest ,vrest) "A state entry or exit method." (declare (ignorable ,vdfa ,vstate)) ; needed with some implementations. ,body))) (defun generate-event-method (dfa-class slot-names state-names event) " Generate the event method. DFA-CLASS: name of the DFA. " (let* ((vdfa 'dfa) (body `(with-go-to-state (,vdfa ,state-names) (case (dfa-state ,vdfa) ,@(mapcar (lambda (state-body) (destructuring-bind (state &body body) state-body `((,state) ,@body))) (dfa-event-state-body-map event)) (otherwise #|ignore|# (values))))) (body (if slot-names `(with-slots ,slot-names ,vdfa ,body) body))) `(defmethod ,(dfa-event-name event) ((,vdfa ,dfa-class) ,@(dfa-event-lambda-list event)) "A state transition event." ,body))) );eval-when (defmacro define-state-machine (name &key slots initial states documentation) " Defines a DFA class named NAME with the given SLOTS. The CLAUSES define the states and transitions, that are implemented as generic functions on the DFA class. " (assert (and (symbolp name) (not (keywordp name)))) (check-type slots list) (check-type initial symbol) (check-type states cons) (check-type documentation (or null string)) (unless initial (setf initial (first (first states)))) (assert (every (function consp) states)) (assert (find initial states :key (function first))) (assert (let ((state-names (mapcar (function first) states))) (equal state-names (remove-duplicates state-names)))) (multiple-value-bind (events entrexes) (collect-events states) (let ((vdfa (gensym "DFA-")) (initial-ex (find-if (lambda (entrex) (and (eql :entry (dfa-entrex-name entrex)) (eql initial (dfa-entrex-state entrex)))) entrexes)) (slot-names (slot-names slots)) (state-names (state-names states)) (init-slots (let ((init-slots '())) (dolist (slot slots init-slots) (when (and (listp slot) (getf (rest slot) :initarg)) (push (first slot) init-slots)))))) `(progn (defclass ,name (dfa) ,slots ,@(when documentation `((:documentation ,documentation)))) ;; TODO: add a INITIALIZE-INSTANCE method to let the user initialize the DFA with MAKE-INSTANCE. (defun ,(intern (with-standard-io-syntax (format nil "MAKE-~A" name)) (or (symbol-package name) *package*)) ,(append ;; make-dfa takes as mandatory parameters all the slots that have a :initarg init-slots (when initial-ex (dfa-entrex-lambda-list initial-ex))) ,(format nil "Instanciates a new ~A DFA." name) (let ((,vdfa (make-instance ',name :state ',initial))) ,@(when slots `((setf ,@(mapcan (lambda (slot) (let ((sname (if (symbolp slot) slot (first slot)))) (list `(slot-value ,vdfa ',sname) sname))) init-slots)))) (on-entry ,vdfa ',initial ,@(when initial-ex (dfa-entrex-lambda-list initial-ex))) ,vdfa)) ,@(mapcar (lambda (ex) (generate-entrex-method name slot-names state-names ex)) entrexes) ,@(mapcar (lambda (ev) (generate-event-method name slot-names state-names ev)) events) ',name)))) #| ;; Example: (define-state-machine session-dfa :slots ((session :initarg :session) (timer :accessor session-dfa-timer)) :initial closed :states ((closed (session-open () (go-to-state connecting)) (session-disconnect () (logger :client :warn "SESSION-DFA got a SESSION-DISCONNECT while in CLOSED state."))) (connecting (:entry () (if (perform-open-session session) (go-to-state connected) (cannot-open-session (session-lo-dfa session)))) (cannot-open-session () (let ((delay (random 20))) (logger :client :warn "Cannot connect right now, will try in ~A second~:*~P." delay) (go-to-state waiting delay))) (session-open () (logger :client :warn "SESSION-DFA got a SESSION-OPEN while in CONNECTING state.")) (session-close () (perform-close-session session) (go-to-state closed)) (session-disconnect () (perform-close-session session) (go-to-state waiting (random 20)))) (waiting (:entry (delay) (setf timer (add-timer *event-base* (lambda () (session-timeout dfa)) delay :one-shot t))) (:exit () (remove-timer *event-base* (session-dfa-timer dfa))) (session-timeout () (go-to-state connecting)) (session-close () (go-to-state closed)) (session-disconnect () (logger :client :warn "SESSION-DFA got a SESSION-DISCONNECT while in WAITING state."))) (connected (:entry () ;; TODO: activate the protocol FSM (receive-bytes session)) (session-close () (perform-close-session session) (go-to-state closed)) (session-disconnect () (perform-close-session session) (go-to-state connecting))))) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DFA") (define-state-machine left :initial on :states ((on (push-left (right) (print '(left stays on)) (push-right right dfa)) (pull-left (right) (print '(left goes off)) (go-to-state off))) (off (push-left (right) (print '(left goes on)) (go-to-state on)) (pull-left (right) (print '(left stays off)) (pull-right right dfa))))) (define-state-machine right :initial on :states ((on (push-right (left) (print '(right stays on)) (push-left left dfa)) (pull-right (left) (print '(right goes off)) (go-to-state off))) (off (push-right (left) (print '(right goes on)) (go-to-state on)) (pull-right (left) (print '(right stays off)) (pull-left left dfa))))) (let ((left (make-left)) (right (make-right))) (push-left left right)) |# ;;;; THE END ;;;;
16,852
Common Lisp
.lisp
370
34.983784
126
0.560337
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
9b6ac2192dce2a4544b871dde669c97033756cedd4181937413b6a2b09e8007f
5,094
[ -1 ]
5,095
tea.lisp
informatimago_lisp/common-lisp/cesarum/tea.lisp
;;;; -*- mode:lisp; coding:utf-8 -*- ;;;; mode:mmm; ;;;;************************************************************************** ;;;;FILE: tea.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Implementation of the TEA ;;;; Tiny Encryption Algorithm: ;;;; http://web.archive.org/web/20070929150931/http://www.simonshepherd.supanet.com/tea.htm ;;;; ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2006-03-20 <PJB> Created. ;;;;BUGS ;;;;TODO ;;;; Implement the new variant. ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2006 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.TEA" (:use "COMMON-LISP") (:export "TEA-DECIPHER" "TEA-ENCIPHER") (:documentation " This package imlements the TEA, Tiny Encryption Algorithm. Tiny Encryption Algorithm: <http://web.archive.org/web/20070929150931/http://www.simonshepherd.supanet.com/tea.htm> Note: This algorithm as weaknesses. See also: COM.INFORMATIMAGO.COMMON-LISP.CESARUM.RAIDEN License: AGPL3 Copyright Pascal J. Bourguignon 2006 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.TEA") (eval-when (:compile-toplevel :load-toplevel :execute) (defconstant +n+ 32)) (declaim (inline op)) (defun op (x a b sum) (logxor (+ (ash x 4) a) (+ x sum) (+ (ash x -5) b))) (defmacro ciploop ((v w k y z a b c d (sum init-sum) delta) &body body) `(let ((,y (aref ,v 0)) (,z (aref ,v 1)) (,sum ,init-sum) (,delta #x9e3779b9) (,a (aref ,k 0)) (,b (aref ,k 1)) (,c (aref ,k 2)) (,d (aref ,k 3))) (loop :repeat +n+ :do (progn ,@body) :finally (setf (aref ,w 0) ,y (aref ,w 1) ,z)))) (defmacro c-incf (var expr) `(setf ,var (mod (+ ,var ,expr) #x100000000))) (defmacro c-decf (var expr) `(setf ,var (mod (- ,var ,expr) #x100000000))) (defun tea-encipher (v w k) " DO: Encipher the clear text vector V, storing the code in the vector W, using the key K. V: The clear text: a vector of two 32-bit words. W: The code: a vector of two 32-bit words. K: The key: a vector of four 32-bit words. " (ciploop (v w k y z a b c d (sum 0) delta) (c-incf sum delta) (c-incf y (op z a b sum)) (c-incf z (op y c d sum)))) (defun tea-decipher (v w k) " DO: Decipher the code vector V, storing the decrypted clear text in the vector W, using the key K. V: The code: a vector of two 32-bit words. W: The clear text: a vector of two 32-bit words. K: The key: a vector of four 32-bit words. " (ciploop (v w k y z a b c d (sum #.(mod (* +n+ #x9e3779b9) #x100000000)) delta) (c-decf z (op y c d sum)) (c-decf y (op z a b sum)) (c-decf sum delta))) #| {%c-mode%} void encipher(unsigned long *const v,unsigned long *const w, const unsigned long *const k) { register unsigned long y=v[0],z=v[1],sum=0,delta=0x9E3779B9, a=k[0],b=k[1],c=k[2],d=k[3],n=32; while(n-->0) { sum += delta; y += (z << 4)+a ^ z+sum ^ (z >> 5)+b; z += (y << 4)+c ^ y+sum ^ (y >> 5)+d; } w[0]=y; w[1]=z; } void decipher(unsigned long *const v,unsigned long *const w, const unsigned long *const k) { register unsigned long y=v[0],z=v[1],sum=0xC6EF3720, delta=0x9E3779B9,a=k[0],b=k[1], c=k[2],d=k[3],n=32; /* sum = delta<<5, in general sum = delta * n */ while(n-->0) { z -= (y << 4)+c ^ y+sum ^ (y >> 5)+d; y -= (z << 4)+a ^ z+sum ^ (z >> 5)+b; sum -= delta; } w[0]=y; w[1]=z; } {%/c-mode%} |# #| {%c-mode%} /* ANSI C (New Variant) */ void encipher(const unsigned long *const v,unsigned long *const w, const unsigned long * const k) { register unsigned long y=v[0],z=v[1],sum=0,delta=0x9E3779B9,n=32; while(n-->0) { y += (z << 4 ^ z >> 5) + z ^ sum + k[sum&3]; sum += delta; z += (y << 4 ^ y >> 5) + y ^ sum + k[sum>>11 & 3]; } w[0]=y; w[1]=z; } void decipher(const unsigned long *const v,unsigned long *const w, const unsigned long * const k) { register unsigned long y=v[0],z=v[1],sum=0xC6EF3720, delta=0x9E3779B9,n=32; /* sum = delta<<5, in general sum = delta * n */ while(n-->0) { z -= (y << 4 ^ y >> 5) + y ^ sum + k[sum>>11 & 3]; sum -= delta; y -= (z << 4 ^ z >> 5) + z ^ sum + k[sum&3]; } w[0]=y; w[1]=z; } {%/c-mode%} |# (defun word (a b c d) (dpb a (byte 8 24) (dpb b (byte 8 16) (dpb c (byte 8 8) d)))) (defun read-words (bits what) (loop :for bytes = (progn (format t "Please enter ~D bits of ~A: " bits what) (let ((buffer (read-line *standard-input* nil nil))) (map 'vector (function char-code) buffer))) :while (and bytes (< (* 8 (length bytes)) bits)) :finally (return (and bytes (loop :for i :from 0 :by 4 :below (truncate (+ 7 bits) 8) :collect (word (aref bytes (+ i 0)) (aref bytes (+ i 1)) (aref bytes (+ i 2)) (aref bytes (+ i 3))) into words :finally (return (coerce words 'vector))))))) (defun interactive-test () (loop with code = (vector 0 0) with decr = (vector 0 0) for clear = (prog1 (read-words 64 "clear text") (terpri)) for key = (prog1 (read-words 128 "key") (terpri)) while (and clear key) do (progn (tea-encipher clear code key) (format t "(encipher ~S ~S)~% --> ~S~%" clear key code) (tea-decipher code decr key) (format t "(decipher ~S ~S)~% --> ~S~%" code key decr) (unless (equalp clear decr) (format t "!!! ERROR !!!~%"))))) (defun test () (with-input-from-string (*standard-input* "Hello World! John McCarthy invented LISP. Big Unknown Secret. Very very secret key. Forget it! ") (interactive-test))) ;;;; THE END ;;;;
7,937
Common Lisp
.lisp
196
34.510204
94
0.563263
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
b241d511f173b5fdcd8a8f4fa264b55aeb77c752548e90fb5ad2ffa2c8695a1b
5,095
[ -1 ]
5,096
dictionary.lisp
informatimago_lisp/common-lisp/cesarum/dictionary.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: dictionary.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; See defpackage documentation string. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2010-08-16 <PJB> Created ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2010 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DICTIONARY" (:use "COMMON-LISP") (:export "DICTIONARY" "MAKE-DICTIONARY" "A-LIST" "P-LIST" "ADAPTATING-DICTIONARY" ; "HASH-TABLE" "DICTIONARY-SET" "DICTIONARY-GET" "DICTIONARY-DELETE" "DICTIONARY-MAP" "DICTIONARY-COUNT" ;; low-level: "DICTIONARY-CLASS" "DICTIONARY-TEST" "DICTIONARY-DATA" "ADAPTATING-DICTIONARY-LIMIT") (:documentation " Implements a DICTIONARY API over HASH-TABLE, P-LIST, A-LIST and an ADAPTATIVE-DICTIONARY class that automatically switch between HASH-TABLE and A-LIST depending on the number of entries. License: AGPL3 Copyright Pascal J. Bourguignon 2010 - 2015 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DICTIONARY") (defgeneric dictionary-test (dictionary) (:documentation "RETURN: The test function of the dictionary.")) (defclass dictionary-class () ((test :initarg :test :initform (function eql) :reader dictionary-test)) (:documentation "An abstract Dictionary clas.")) (deftype dictionary () '(or hash-table dictionary-class)) (defgeneric make-dictionary (type &key test size contents) (:documentation " TYPE: Name of a class implementing the dictionary protocol. TEST: Restricted to EQL, EQUAL or EQUALP when type is HASH-TABLE. CONTENTS: A p-list containing the initial key value pairs. ")) (defgeneric dictionary-set (dictionary key value) (:documentation "Enter or update the VALUE associated with the KEY into the DICTIONARY.")) (defgeneric dictionary-get (dictionary key &optional default) (:documentation "RETURN: The value associated with the KEY in the DICTIONARY.")) (defgeneric dictionary-delete (dictionary key) (:documentation "Remove the KEY from the DICTIONARY.")) (defgeneric dictionary-map (fun dictionary) (:documentation "Call the function FUN on each KEY VALUE association in the DICTIONARY.")) (defgeneric dictionary-count (dictionary) (:documentation "RETURN: the number of associations in the DICTIONARY.")) (defsetf dictionary-get (dictionary key &optional default) (new-value) (declare (ignorable default)) `(dictionary-set ,dictionary ,key ,new-value)) ;; hash-table (defmethod make-dictionary ((type (eql 'hash-table)) &key (test (function eql)) (size 8) (contents '())) (declare (ignore type)) (let ((dictionary (make-hash-table :test test :size size))) (loop :for (key value) :on contents :by (function cddr) :do (dictionary-set dictionary key value)) dictionary)) (defmethod dictionary-test ((dictionary hash-table)) (hash-table-test dictionary)) (defmethod dictionary-set ((dictionary hash-table) key value) (setf (gethash key dictionary) value)) (defmethod dictionary-get ((dictionary hash-table) key &optional default) (gethash key dictionary default)) (defmethod dictionary-delete ((dictionary hash-table) key) (remhash key dictionary)) (defmethod dictionary-map (fun (dictionary hash-table)) (let ((results '())) (maphash (lambda (key value) (push (funcall fun key value) results)) dictionary) (nreverse results))) (defmethod dictionary-count ((dictionary hash-table)) (hash-table-count dictionary)) (defgeneric dictionary-data (dictionary) (:documentation "The data in the dictionary.")) (defclass a-list (dictionary-class) ((data :initarg :data :initform '() :accessor dictionary-data)) (:documentation "A dictionary implemented as an A-list.")) (defmethod make-dictionary ((type (eql 'a-list)) &key (test (function eql)) (size 8) (contents '())) (declare (ignore type size)) (let ((dictionary (make-instance 'a-list :test test))) (loop :for (key value) :on contents :by (function cddr) :do (dictionary-set dictionary key value)) dictionary)) (defmethod dictionary-set ((dictionary a-list) key value) (let ((pair (assoc key (dictionary-data dictionary) :test (dictionary-test dictionary)))) (if pair (setf (cdr pair) value) (setf (dictionary-data dictionary) (acons key value (dictionary-data dictionary)))) value)) (defmethod dictionary-get ((dictionary a-list) key &optional default) (let ((pair (assoc key (dictionary-data dictionary) :test (dictionary-test dictionary)))) (if pair (values (cdr pair) t) (values default nil)))) (defmethod dictionary-delete ((dictionary a-list) key) (let ((pair (assoc key (dictionary-data dictionary) :test (dictionary-test dictionary)))) (setf (dictionary-data dictionary) (delete key (dictionary-data dictionary) :test (dictionary-test dictionary) :key (function car))) pair)) (defmethod dictionary-map (fun (dictionary a-list)) (mapcar (lambda (pair) (funcall fun (car pair) (cdr pair))) (dictionary-data dictionary))) (defmethod dictionary-count ((dictionary a-list)) (length (dictionary-data dictionary))) (defclass p-list (dictionary-class) ((data :initarg :data :initform '() :accessor dictionary-data)) (:documentation "A dictionary implemented as a P-list.")) ;; Note: these are not lisp p-list, which are restricted to symbol keys and therefore eql test. (defmethod make-dictionary ((type (eql 'p-list)) &key (test (function eql)) (size 8) (contents '())) (declare (ignore type size)) (make-instance 'p-list :test test :data (copy-list contents))) (defmethod dictionary-set ((dictionary p-list) key value) (loop :with test = (dictionary-test dictionary) :for cell :on (dictionary-data dictionary) :by (function cddr) :when (funcall test (first cell) key) :do (return-from dictionary-set (setf (second cell) value)) :finally (setf (dictionary-data dictionary) (list* key value (dictionary-data dictionary))) (return-from dictionary-set value))) (defmethod dictionary-get ((dictionary p-list) key &optional default) (loop :with test = (dictionary-test dictionary) :for cell :on (dictionary-data dictionary) :by (function cddr) :when (funcall test (first cell) key) :do (return-from dictionary-get (values (second cell) t)) :finally (return-from dictionary-get (values default nil)))) (defmethod dictionary-delete ((dictionary p-list) key) (let ((test (dictionary-test dictionary)) (data (dictionary-data dictionary))) (when data (when (funcall test (first data) key) (setf (dictionary-data dictionary) (cddr (dictionary-data dictionary))) (return-from dictionary-delete (cons (first data) (second data)))) (loop :for cell :on data :by (function cddr) :for k = (third cell) :while (cddr data) :when (funcall test key k) :do (let ((v (fourth cell))) (setf (cddr cell) (cddddr cell)) (return-from dictionary-delete (cons k v)))) nil))) (defmethod dictionary-map (fun (dictionary p-list)) (loop :for (key value) :on (dictionary-data dictionary) :by (function cddr) :collect (funcall fun key value))) (defmethod dictionary-count ((dictionary p-list)) (truncate (length (dictionary-data dictionary)) 2)) (defgeneric adaptating-dictionary-limit (dictionary) (:documentation "The number of elements over which the adaptating DICTIONARY switches to hash-tables, and below which it switches to A-lists.")) (defclass adaptating-dictionary (dictionary-class) ((dictionary :initarg :dictionary) (limit :initarg :limit :initform 10 :type (integer 0) :accessor adaptating-dictionary-limit)) (:documentation "A dictionary that changes between an A-list implementation and a hash-table implementation depending on the number of entries.")) (defgeneric adaptating-dictionary-adapt (dictionary)) (defmethod adaptating-dictionary-adapt ((dictionary adaptating-dictionary)) (flet ((copy-dictionary (dictionary type) (make-dictionary type :test (dictionary-test dictionary) :size (dictionary-count dictionary) :contents (let ((contents '())) (dictionary-map (lambda (key value) (push value contents) (push key contents)) dictionary) contents)))) (with-slots (dictionary limit) dictionary (cond ((and (typep dictionary 'hash-table) (< (dictionary-count dictionary) limit)) (setf dictionary (copy-dictionary dictionary 'a-list))) ((and (not (typep dictionary 'hash-table)) (<= limit (dictionary-count dictionary))) (setf dictionary (copy-dictionary dictionary 'hash-table))))))) (defmethod make-dictionary ((type (eql 'adaptating-dictionary)) &key (test (function eql)) (size 8) (contents '())) (declare (ignore type)) ;; TODO: determine the limit automatically. (let ((limit 10)) (make-instance 'adaptating-dictionary :limit limit :dictionary (make-dictionary (if (< size limit) 'a-list 'hash-table) :test test :size size :contents contents)))) (defmethod dictionary-set ((dictionary adaptating-dictionary) key value) (prog1 (with-slots (dictionary) dictionary (dictionary-set dictionary key value)) (adaptating-dictionary-adapt dictionary))) (defmethod dictionary-get ((dictionary adaptating-dictionary) key &optional default) (multiple-value-prog1 (with-slots (dictionary) dictionary (dictionary-get dictionary key default)) (adaptating-dictionary-adapt dictionary))) (defmethod dictionary-delete ((dictionary adaptating-dictionary) key) (prog1 (with-slots (dictionary) dictionary (dictionary-delete dictionary key)) (adaptating-dictionary-adapt dictionary))) (defmethod dictionary-map (fun (dictionary adaptating-dictionary)) (with-slots (dictionary) dictionary (dictionary-map fun dictionary))) (defmethod dictionary-count ((dictionary adaptating-dictionary)) (with-slots (dictionary) dictionary (dictionary-count dictionary))) ;;;; THE END ;;;;
12,723
Common Lisp
.lisp
256
42.914063
148
0.664059
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
02c303140b8bf25191a19c881489b7216e4d98630776eaf8ee346dd52519cff9
5,096
[ -1 ]
5,097
unit.lisp
informatimago_lisp/common-lisp/cesarum/unit.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: unit.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Unit converter. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2018-07-24 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2018 - 2018 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UNIT" (:use "COMMON-LISP") (:export "FAHRENHEIT" "KELVIN" "CELCIUS" "RANKINE")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UNIT") (defun fahrenheit (f) "Return f Fahrenheit in Kelvin." (* (- f 32.0) 5/9)) (defun kelvin (k) "Return k Kelvin in Kelvin." k) (defun celcius (c) "Return c Celcius in Kelvin." (+ c 273.15)) (defun rankine (r) "Return r Rankine in Kelvin." (fahrenheit (- r 459.67))) ;;;; THE END ;;;;
1,872
Common Lisp
.lisp
53
32.773585
83
0.58269
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
43f6e8f2524fe9091bc220c51ecf50a8c92d9cf7df950c010a93187ef1081512
5,097
[ -1 ]
5,098
date.lisp
informatimago_lisp/common-lisp/cesarum/date.lisp
;;; -*- coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: date.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Handle times and dates. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2007-05-23 <PJB> Created. ;;;;BUGS ;;;; ;;;; The current implementation uses Common Lisp universal-time ;;;; and therefore inherits all the bugs of the CL universal-time ;;;; specification. ;;;; ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2007 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) ;; http://www.staff.science.uu.nl/~gent0113/calendar/isocalendar.htm ;; http://en.wikipedia.org/wiki/Julian_day#Calculation ;; - find inverse of (julian-day-number/gregorian d m y) --> j ;; - check the origin of julian-day ;; (com.informatimago.common-lisp.cesarum.gregorian-calendar:date-from-day-number (- 733314 2454374)) ;; 24 ; ;; 11 ; ;; -4713 ;; - check the historical names of the day (day starting from noon?, ;; hebrew days starting from eve). ;;; See also: http://emr.cs.uiuc.edu/~reingold/calendars.shtml ;; From: Patrice Lespagnol <[email protected]> ;; Subject: Re: convert julian date to universal ;; Newsgroups: comp.lang.lisp ;; Date: Thu, 17 Jan 2008 03:50:07 -0800 (PST) ;; Organization: http://groups.google.com ;; Message-ID: <c2e4c6de-5eb1-4fdc-8644-665e6b68bc8d@v29g2000hsf.googlegroups.com> ;; ;; > More likely the other way round (year month day). The code can't ;; > possibly be correct though, since Julian days start at noon UT. ;; > Replacing (ceiling j) by (round j) should cure that. At least, then ;; > the example given in the wikipedia entry comes out right. ;; Yes, that's right. The function was incorrect in case of a fractional ;; part < 0.5. ;; ;; (defun julian-to-gregorian-calendar (j) ;; (let ((i 0)(l 0)(n 0)(x 0)(d 0)) ;; (setf l (+ (round j) 68569)) ;; (setf n (truncate (* l 4) 146097)) ;; (decf l (truncate (+ (* n 146097) 3) 4)) ;; (setf i (truncate (* (+ 1 l) 4000) 1461001)) ;; (decf l (- (truncate (* i 1461) 4) 31)) ;; (setf x (truncate (* l 80) 2447)) ;; (setf d (- l (truncate (* x 2447) 80))) ;; (setf l (truncate x 11)) ;; (values (+ (* 100 (- n 49)) i l) ;; (- (+ x 2) (* l 12)) ;; d))) ;; Note: We use several packages to avoid name clashes between ;; similar functions for different calendars. ;; grep -i defpackage date.lisp |awk '{printf ";;%7s%s\n","",$2}' ;; "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DATE.UTILITY" ;; "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.JULIAN-CALENDAR" ;; "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.GREGORIAN-CALENDAR" ;; "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DATE" (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DATE.UTILITY" (:use "COMMON-LISP") (:export "DATE<" "DATE>" "DATE<=" "DATE>=" "DATE=" "DATE/=" "DURATION" "*DURATION-KEYWORDS*" "SECONDE" "MINUTE" "HOUR" "DAY" "WEEK" "MONTH" "YEAR" "DURATION+" "DURATION-" "DURATION*" "DURATION*" "*SECONDE*" "*MINUTE*" "*HOUR*" "*DAY*" "*WEEK*" "*MONTH*" "*YEAR*" "*QUARTER*" "DURATION-BETWEEN" "DATE-BEFORE" "DATE-AFTER" ;; INTERNAL: "AS-LIST-OF-NUMBERS" "DEFINE-DATE-COMPARE-METHODS" "HMS60-TO-SECONDES" "HMS60-FROM-SECONDES" "COMPARE-LISTS-OF-NUMBERS" "CURRENT-TIMEZONE" "DST-IN-YEAR" "+JANUARY+" "+FEBRUARY+" "+MARCH+" "+APRIL+" "+MAY+" "+JUNE+" "+JULY+" "+AUGUST+" "+SEPTEMBER+" "+OCTOBER+" "+NOVEMBER+" "+DECEMBER+" "ENGLISH-NAME-OF-JULIAN-WEEKDAY" "ENGLISH-NAME-OF-JULIAN-MONTH" "COLLAPSE-JULIAN-DURATION" "JULIAN-DAY-NUMBER/GREGORIAN" "JULIAN-DAY-NUMBER/JULIAN" "JULIAN-DATE" "WEEKDAY-OF-JULIAN-DATE") (:documentation " Internal date utilities. Defines utilities to process dates. See also: COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DATE COM.INFORMATIMAGO.COMMON-LISP.CESARUM.GREGORIAN-CALENDAR COM.INFORMATIMAGO.COMMON-LISP.CESARUM.JULIAN-CALENDAR License: AGPL3 Copyright Pascal J. Bourguignon 2007 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.JULIAN-CALENDAR" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DATE.UTILITY") (:export "LEAP-YEAR-P" "DATE-FROM-DAY-NUMBER" "DATE-TO-DAY-NUMBER") (:documentation " Defines the Julian calendar. See also: COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DATE COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DATE.UTILITY COM.INFORMATIMAGO.COMMON-LISP.CESARUM.GREGORIAN-CALENDAR License: AGPL3 Copyright Pascal J. Bourguignon 2007 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.GREGORIAN-CALENDAR" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DATE.UTILITY") (:export "GREGORIAN-CALENDAR-DATE" "GREGORIAN" "SECONDE" "MINUTE" "HOUR" "DAY" "WEEK" "MONTH" "YEAR" "WEEKDAY" "TIMEZONE" "TO-TIMEZONE" "+JANUARY+" "+FEBRUARY+" "+MARCH+" "+APRIL+" "+MAY+" "+JUNE+" "+JULY+" "+AUGUST+" "+SEPTEMBER+" "+OCTOBER+" "+NOVEMBER+" "+DECEMBER+" "AS-JULIAN-DATE" "LEAP-YEAR-P" "AS-UNIVERSAL-TIME" "PREVIOUS-DAY" "NEXT-DAY" "INCREMENT-DAY" "DECREMENT-DAY" "DURATION-BETWEEN" "DATE-AFTER" "DATE-BEFORE" ;; Internal: "AS-LIST-OF-NUMBERS" "DATE-FROM-DAY-NUMBER" "DATE-TO-DAY-NUMBER") (:documentation " Defines the Gregorian calendar. See also: COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DATE COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DATE.UTILITY COM.INFORMATIMAGO.COMMON-LISP.CESARUM.JULIAN-CALENDAR License: AGPL3 Copyright Pascal J. Bourguignon 2007 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DATE" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DATE.UTILITY") (:import-from "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.JULIAN-CALENDAR") (:import-from "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.GREGORIAN-CALENDAR" "GREGORIAN-CALENDAR-DATE" "GREGORIAN" "SECONDE" "MINUTE" "HOUR" "DAY" "WEEK" "MONTH" "YEAR" "WEEKDAY" "TIMEZONE" "TO-TIMEZONE" "+JANUARY+" "+FEBRUARY+" "+MARCH+" "+APRIL+" "+MAY+" "+JUNE+" "+JULY+" "+AUGUST+" "+SEPTEMBER+" "+OCTOBER+" "+NOVEMBER+" "+DECEMBER+" "LEAP-YEAR-P" "AS-UNIVERSAL-TIME" "AS-JULIAN-DATE" "PREVIOUS-DAY" "NEXT-DAY" "INCREMENT-DAY" "DECREMENT-DAY" "DURATION-BETWEEN" "DATE-AFTER" "DATE-BEFORE") (:export "DATE<" "DATE>" "DATE<=" "DATE>=" "DATE=" "DATE/=" "DURATION" "*DURATION-KEYWORDS*" "SECONDE" "MINUTE" "HOUR" "DAY" "WEEK" "MONTH" "YEAR" "DURATION+" "DURATION-" "DURATION*" "DURATION*" "*SECONDE*" "*MINUTE*" "*HOUR*" "*DAY*" "*WEEK*" "*MONTH*" "*YEAR*" "*QUARTER*" "+JANUARY+" "+FEBRUARY+" "+MARCH+" "+APRIL+" "+MAY+" "+JUNE+" "+JULY+" "+AUGUST+" "+SEPTEMBER+" "+OCTOBER+" "+NOVEMBER+" "+DECEMBER+" "GREGORIAN-CALENDAR-DATE" "GREGORIAN" "WEEKDAY" "TIMEZONE" "TO-TIMEZONE" "AS-UNIVERSAL-TIME" "AS-JULIAN-DATE" "PREVIOUS-DAY" "NEXT-DAY" "INCREMENT-DAY" "DECREMENT-DAY" "DURATION-BETWEEN" "DATE-BEFORE" "DATE-AFTER") (:documentation " Calendars, dates and times. See also: COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DATE COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DATE.UTILITY COM.INFORMATIMAGO.COMMON-LISP.CESARUM.GREGORIAN-CALENDAR COM.INFORMATIMAGO.COMMON-LISP.CESARUM.JULIAN-CALENDAR License: AGPL3 Copyright Pascal J. Bourguignon 2007 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; UTILITIES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DATE.UTILITY") (defgeneric date-after (date duration) (:documentation "RETURN: The date DURATION after DATE.")) (defgeneric date-before (date duration) (:documentation "RETURN: The date DURATION before DATE.")) (defun compare-lists-of-numbers (a b) " PRE: (and (proper-list-p a) (proper-list-p b) (every (function realp) a) (every (function realp) b)) RETURN: The lexicographical order of the two lists of numbers. " (cond ((null a) (if (null b) 0 -1)) ((null b) +1) ((= (car a) (car b)) (compare-lists-of-numbers (cdr a) (cdr b))) ((< (car a) (car b)) -1) (t +1))) (defun hms60-to-secondes (seconde minute hour) " RETURN: The number of seconds corresponding to hour:minute:second in base sixty. " (+ (* (+ (* hour 60) minute) 60) seconde)) (defun hms60-from-secondes (secondes) " RETURN: seconde ; minute ; hour POST: (or (not (integerp secondes)) (= secondes (multiple-value-call (function hms-to-secondes) (hms60-from-secondes secondes)))) " (multiple-value-bind (minutes seconde) (floor secondes 60) (multiple-value-bind (hour minute) (floor minutes 60) (values seconde minute hour)))) (defun current-timezone () " RETURN: The current default timezone, expressed as a number of seconds from Greenwich; East positive. WARNING: COMMON-LISP convention is West positive. " (multiple-value-bind (se mi ho da mo ye) (decode-universal-time (get-universal-time)) (- (encode-universal-time se mi ho da mo ye 0) (encode-universal-time se mi ho da mo ye)))) (defconstant +january+ 1 "The number of the January month in the Gregorial calendar.") (defconstant +february+ 2 "The number of the February month in the Gregorial calendar.") (defconstant +march+ 3 "The number of the Marchmonth in the Gregorial calendar.") (defconstant +april+ 4 "The number of the April month in the Gregorial calendar.") (defconstant +may+ 5 "The number of the May month in the Gregorial calendar.") (defconstant +june+ 6 "The number of the June month in the Gregorial calendar.") (defconstant +july+ 7 "The number of the July month in the Gregorial calendar.") (defconstant +august+ 8 "The number of the August month in the Gregorial calendar.") (defconstant +september+ 9 "The number of the September month in the Gregorial calendar.") (defconstant +october+ 10 "The number of the October month in the Gregorial calendar.") (defconstant +november+ 11 "The number of the November month in the Gregorial calendar.") (defconstant +december+ 12 "The number of the December month in the Gregorial calendar.") (defun english-name-of-julian-weekday (weekday) " RETURN: A string containing the name in English of the WEEKDAY. " (aref #("Monday" "Tuesday" "Wednesday" "Thirsday" "Friday" "Saturday" "Sunday") weekday)) (defun english-name-of-julian-month (month) " RETURN: A string containing the name in English of the MONTH (Julian, Gregorian, etc, calendars). " (aref #("January" "February" "Mars" "April" "May" "June" "July" "August" "September" "October" "November") (1- month))) (defun julian-day-number/gregorian (day month year) " RETURN: The Julian Day Number for the given Gregorian Date. URL: <http://en.wikipedia.org/wiki/Julian_day#Calculation> " (let* ((a (floor (- 14 month) 12)) (y (- (+ year 4800) a)) (m (+ month (* 12 a) -3))) (+ day (floor (+ (* 153 m) 2) 5) (* 365 y) (floor y 4) (- (floor y 100)) (floor y 400) -32045))) (defun julian-day-number/julian (day month year) " RETURN: The Julian Day Number for the given Julian Date. URL: <http://en.wikipedia.org/wiki/Julian_day#Calculation> " (let* ((a (floor (- 14 month) 12)) (y (- (+ year 4800) a)) (m (+ month (* 12 a) -3))) (+ day (floor (+ (* 153 m) 2) 5) (* 365 y) (floor y 4) -32083))) (defun julian-date (seconde minute hour julian-day-number) " RETURN: The Julian Date for the given time and Julian Day Number. URL: <http://en.wikipedia.org/wiki/Julian_day#Calculation> " (+ julian-day-number (/ (- hour 12) 24) (/ minute 1440) (/ seconde 86400))) (defun weekday-of-julian-date (julian-date) " RETURN: The Day of the week of the given Julian Day. 0 = Monday, 1 = Tuesday, ..., 6 = Sunday. URL: <http://en.wikipedia.org/wiki/Julian_day#Calculation> " (mod (truncate (+ julian-date 1/2)) 7)) ;;; ---------------------------------------- ;;; ;;; ABSTRACT CALENDAR ;;; ---------------------------------------- ;;; (defgeneric as-list-of-numbers (date) (:documentation "Return the values of the date from the most significant number to the last. It can be a list of a single number. This is meaningful only in the context of the given date class, and used to compare two dates of the same class.")) (defgeneric units-of-list-of-numbers (date) (:documentation "Return a list of duration keywords corresponding to the numbers returned by as-list-of-numbers. These keywords may not necessarily be already in *DURATION-KEYWORDS*, but could be merged there.")) ;;; First define the generic functions for date<, date=, etc... (macrolet ((define-generic-date-compare (name) `(defgeneric ,name (date1 date2) (:documentation ,(format nil "RETURN: Whether DATE1 is ~A DATE2." (case name (date< "before") (date<= "before or the same as") (date> "after") (date>= "after or the same as") (date= "the same as") (date/= "different from")))) (:method (date1 date2) (error (if (and (typep date1 (type-of date2)) (typep date2 (type-of date1))) "~S: Arguments are not comparable dates: ~S vs. ~S" "Both dates must be of the same class ~ to be compared with ~S; ~S vs. ~S") ',name date1 date2))))) (define-generic-date-compare date<) (define-generic-date-compare date>) (define-generic-date-compare date<=) (define-generic-date-compare date>=) (define-generic-date-compare date=) (define-generic-date-compare date/=)) ;;; Then define the macros for date<, date=, for any class having ;;; an as-list-of-numbers method: (defmacro define-date-compare-methods (class) " DO: Define date comparison methods. " `(macrolet ((define-date-compare (name op) `(defmethod ,name ((a ,',class) (b ,',class)) (,op (compare-lists-of-numbers (as-list-of-numbers a) (as-list-of-numbers b)) 0)))) (define-date-compare date< <) (define-date-compare date> >) (define-date-compare date<= <=) (define-date-compare date>= >=) (define-date-compare date= =) (define-date-compare date/= /=) ',class)) (defgeneric duration-between (end start) (:documentation "Return the DURATION between END and START. Both END and START dates must be of the same class.")) ;;; ---------------------------------------- ;;; ;;; DURATION ;;; ---------------------------------------- ;;; (defparameter *duration-keywords* '(:year :month :week :day :hour :minute :seconde) "A list of keywords allowed in duration expressions, in the order they should be printed.") (defclass duration () ((expression :documentation "A p-list" :reader expression)) (:documentation " We store durations 'symbolically'. The 'units' may be colinear in a given calendar, but we don't collapse them because either they may be not colinear in other calendars, or their ratio may not be always the same (eg. 1 year is 24 months in the Davian calendar vs 12 months in the Gregorian calendar, or 1 month may be 28, 29, 30 or 31 days). There is no order for durations. Moreover, the set of units is not hardwired, the client may add new units to the *DURATION-KEYWORDS* list. Only the units listed in *DURATION-KEYWORDS* are processed by the DURATION arithmetic operators. This allows us to use these DURATION objects with respect to any calendar. ")) (defun duration (&rest expression &key &allow-other-keys) " RETURN: A new DURATION instance, initialized with the EXPRESSION. NOTE: Only the keywords listed in *DURATION-KEYWORDS* are really allowed. " (let ((keywords (loop :for k :in expression :by (function cddr) :collect k))) (unless (subsetp keywords *duration-keywords*) (error "Unexpected keyword for ~S: ~S" 'duration (delete-duplicates (set-difference keywords *duration-keywords*))))) (let ((duration (make-instance 'duration))) (setf (slot-value duration 'expression) (loop :for k :in *duration-keywords* :for v = (getf expression k) :when v :nconc (list k v))) duration)) (defmethod print-object ((self duration) stream) (if *print-escape* (if *print-readably* (format stream "#.(~S ~{~S~^ ~})" 'duration (slot-value self 'expression)) (print-unreadable-object (self stream :identity nil :type t) (let ((*print-escape* nil)) (print-object self stream)))) (format stream "~(~{~*~A ~2:*~A~P~^, ~}~)" (slot-value self 'expression))) self) (macrolet ((define-accessor (name &optional no-writer-p) `(progn (defgeneric ,name (duration) (:documentation ,(let ((*print-circle* nil)) (format nil "RETURN: The ~A of the duration. NOTE: This is not the duration expressed in ~:*~A, just the ~:*~A component of the duration." (string-downcase name)))) (:method ((self duration)) (getf (slot-value self 'expression) ',(intern (string name) "KEYWORD") 0))) ,@(unless no-writer-p `((defgeneric (setf ,name) (value duration)) (defmethod (setf ,name) (value (self duration)) (setf (getf (slot-value self 'expression) ',(intern (string name) "KEYWORD")) value)))) ',name))) (define-accessor seconde) (define-accessor minute) (define-accessor hour) (define-accessor day) (define-accessor week) (define-accessor month) (define-accessor year)) (defun op-plist (a b n) "a+nb" (loop :with r = '() :for k :in *duration-keywords* :for u = (getf a k) :for v = (getf b k) :do (if u (if v (let ((s (+ u (* n v)))) (unless (zerop s) (push k r) (push s r))) (progn (push k r) (push u r))) (when v (let ((s (* n v))) (unless (zerop s) (push k r) (push s r))))) :finally (return (nreverse r)))) (defgeneric duration+ (a b) (:documentation "RETURN: The sum of two durations.")) (defgeneric duration- (a b) (:documentation "RETURN: The difference of two durations.")) (defgeneric duration* (a n) (:documentation "RETURN: The product of a duration by a number.")) (defgeneric duration/ (a n) (:documentation "RETURN: The division of a duration by a number.")) (defmethod duration+ ((a duration) (b duration)) (apply (function duration) (op-plist (slot-value a 'expression) (slot-value b 'expression) 1))) (defmethod duration- ((a duration) (b duration)) (apply (function duration) (op-plist (slot-value a 'expression) (slot-value b 'expression) -1))) (defmethod duration* ((a duration) (b real)) (apply (function duration) (op-plist '() (slot-value a 'expression) b))) (defmethod duration/ ((a duration) (b real)) (apply (function duration) (op-plist '() (slot-value a 'expression) (/ b)))) (defparameter *seconde* (duration :seconde 1) "Symbolic duration of one second.") (defparameter *minute* (duration :minute 1) "Symbolic duration of one minute.") (defparameter *hour* (duration :hour 1) "Symbolic duration of one hour.") (defparameter *day* (duration :day 1) "Symbolic duration of one day.") (defparameter *week* (duration :week 1) "Symbolic duration of one week.") (defparameter *month* (duration :month 1) "Symbolic duration of one month.") (defparameter *quarter* (duration :month 3) "Symbolic duration of one quarter.") (defparameter *year* (duration :year 1) "Symbolic duration of one year.") (defgeneric collapse-julian-duration (duration) (:documentation " DO: Collapse weeks as 7 days. RETURN: secondes; minutes; hours; days; months; years NOTE: If you add keywords to *DURATION-KEYWORDS* you may have to override this method. ")) (defmethod collapse-julian-duration ((self duration)) " DO: Collapse weeks as 7 days. RETURN: secondes; minutes; hours; days; months; years NOTE: If you add keywords to *DURATION-KEYWORDS* you may have to override this method. " (values (seconde self) (minute self) (hour self) (+ (day self) (* 7 (week self))) (month self) (year self))) (defun dst-in-year (year) " RETURN: A list of (year m d) where DST is shifted in or out in the YEAR/ BUG: This uses the undetermined local timezone, we don't know what country DST is returned... " (loop :for m :from 1 :to 12 :nconc (loop :for d :from 1 :below (aref (if (com.informatimago.common-lisp.cesarum.gregorian-calendar:leap-year-p year) #(31 29 31 30 31 30 31 31 30 31 30 31) #(31 28 31 30 31 30 31 31 30 31 30 31)) (1- m)) :when (/= *day* (- (encode-universal-time 0 0 0 (1+ d) m year) (encode-universal-time 0 0 0 d m year))) :collect (list year m d (/ (- (encode-universal-time 0 0 0 (1+ d) m year) (encode-universal-time 0 0 0 d m year)) 60 60))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; COM.INFORMATIMAGO.COMMON-LISP.CESARUM.JULIAN-CALENDAR ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.JULIAN-CALENDAR") (defconstant +days-in-fouryears+ (+ (* 3 365) 366)) (defconstant +days-in-fourcentury+ (* 25 +days-in-fouryears+) "Number of days in 400 years. In the Julian calendar, the four-year cycle repeats indefinitely.") (defun leap-year-p (year) " RETURN: Whether YEAR is a julian leap year. NOTE: We don't implement here the actual leap years (they started with a leap year every three years, since they used to count both the start and end items...). " (zerop (mod year 4))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; COM.INFORMATIMAGO.COMMON-LISP.CESARUM.GREGORIAN-CALENDAR ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.GREGORIAN-CALENDAR") (defconstant +days-in-fouryears+ (+ (* 3 365) 366)) (defconstant +days-in-fourcentury+ (+ (* 97 +days-in-fouryears+) (* 3 (* 4 365))) "Number of days in 400 gregorian years: 96 groups of 4 years including 3 flat years and one leap year + 3 groups of four flat years, multiple of 100 not multiple of 400 + 1 group of 4 years including 3 flat years and one leap year, multiple of 400.") (defun leap-year-p (year) " RETURN: Whether YEAR is a gregorian leap year. " (or (zerop (mod year 400)) (and (not (zerop (mod year 100))) (zerop (mod year 4))))) ;; (cons 0 (reverse ;; (loop ;; :for f ;; :on (reverse ;; (list ;; (* 25 (+ (* 3 365) 366)) ; first century ;; (1- (* 25 (+ (* 3 365) 366))) ; second century ;; (1- (* 25 (+ (* 3 365) 366))) ; third century ;; (1- (* 25 (+ (* 3 365) 366))))) ; fourth century ;; :collect (reduce '+ f)))) ; fourth century ;; (loop ;; :for v :in '((31 29 31 30 31 30 31 31 30 31 30 31) ;; (31 28 31 30 31 30 31 31 30 31 30 31)) ;; :collect (loop ;; :for f :in (cons 0 (butlast v)) ;; :for s = f :then (+ s f) ;; :collect s)) (declaim (inline days-in-month)) (defun days-in-month (year month) (aref (if (leap-year-p year) #(31 29 31 30 31 30 31 31 30 31 30 31) #(31 28 31 30 31 30 31 31 30 31 30 31)) month)) (declaim (inline days-in-year)) (defun days-in-year (year) (if (leap-year-p year) #(0 31 60 91 121 152 182 213 244 274 305 335 366) #(0 31 59 90 120 151 181 212 243 273 304 334 365))) ;; 400 404 500 504 600 604 700 704 ;; +---+---+---....----+---+---....----+---+---....----+---+---... (defun date-from-day-number (day-number) " RETURN: the gregorian-date of the given DAY-NUMBER. " (multiple-value-bind (4centuries rest) (floor day-number +days-in-fourcentury+) (let ((centuries 0)) (when (<= 36525 rest) (multiple-value-setq (centuries rest) (floor (- rest 36525) 36524)) (incf centuries)) (multiple-value-bind (4years rest) (if (zerop centuries) (floor rest +days-in-fouryears+) (if (< rest (1- +days-in-fouryears+)) (values 0 rest) (multiple-value-bind (4years rest) (floor (- rest +days-in-fouryears+ -1) +days-in-fouryears+) (values (1+ 4years) rest)))) (let ((years 0)) (if (and (plusp centuries) (zerop 4years)) ; 500, 600, 700 (multiple-value-setq (years rest) (floor rest 365)) (when (<= 366 rest) (multiple-value-setq (years rest) (floor (- rest 366) 365)) (incf years))) (let ((year (+ (* 400 4centuries) (* 100 centuries) (* 4 4years) years))) (if (zerop rest) (values 1 1 year) (loop :with c = (days-in-year year) :for month :from 0 :while (<= (aref c month) rest) :finally (return (values (- rest (aref c (1- month)) -1) month year)))))))))) (defun date-to-day-number (day month year) " RETURN: the day number of the gregorian-date given by DAY, MONTH and YEAR. " (multiple-value-bind (yinc month) (floor (1- month) 12) (incf year yinc) (incf month) (multiple-value-bind (4centuries rest) (floor year 400) (multiple-value-bind (centuries rest) (floor rest 100) (multiple-value-bind (4years rest) (floor rest 4) (+ (* +days-in-fourcentury+ 4centuries) (aref #(0 36525 73049 109573) centuries) (if (zerop centuries) (+ (* +days-in-fouryears+ 4years) (aref #(0 366 731 1096) rest)) (if (zerop 4years) (+ (* +days-in-fouryears+ 4years) (aref #(0 365 730 1095) rest)) (+ (1- +days-in-fouryears+) (* +days-in-fouryears+ (1- 4years)) (aref #(0 366 731 1096) rest)))) (aref (days-in-year year) (1- month)) (1- day))))))) (defun check-day-number (&key trace-day print-all (start 0) (end +days-in-fourcentury+)) (loop :for i :from start :below end :do (multiple-value-bind (d m y) (date-from-day-number i) (when (or print-all (and trace-day (<= (abs (- trace-day i)) 10))) (format t "~%~6D ~4,'0D-~2,'0D-~2,'0D" i y m d)) (assert (= i (date-to-day-number d m y)) (i y m d) "~%~6D ~4,'0D-~2,'0D-~2,'0D ~6D" i y m d (date-to-day-number d m y))))) ;; (CHECK-DAY-NUMBER :start (- +days-in-fourcentury+) :print-all nil) (defgeneric timezone (date) (:documentation "RETURN: The timezone of a date = number of seconds from Greenwich; East positive.")) (defgeneric weekday (date) (:documentation "RETURN: The weekday of a date.")) (defclass gregorian-calendar-date () ((year :initarg :year :accessor year :initform 1582) (month :initarg :month :accessor month :initform 10) (day :initarg :day :accessor day :initform 15) (hour :initarg :hour :accessor hour :initform 12) (minute :initarg :minute :accessor minute :initform 0) (seconde :initarg :seconde :accessor seconde :initform 0) (timezone :initarg :timezone :accessor timezone :initform nil :documentation "Number of seconds from Greenwich; East positive.") ;; Note: It would be more historically correct to define the Gregorian ;; timezone relative to Rome, but it will be less confusing if all ;; the calendars of a same planet are relative to the same longitud. (weekday :initform nil :documentation "Weekday cache.")) (:documentation "A date in the Gregorian calendar.")) (defmethod print-object ((self gregorian-calendar-date) stream) (flet ((print-it () (with-slots (timezone) self (multiple-value-bind (tzh tzm) (and timezone (floor (floor (abs timezone) 60) 60)) (format stream "~9A ~4,'0D-~2,'0D-~2,'0D ~2,'0D:~2,'0D:~2,'0D ~ ~:[local timezone~;~:[+~;-~]~2,'0D~2,'0D~]" (english-name-of-julian-weekday (weekday self)) (year self) (month self) (day self) (hour self) (minute self) (seconde self) timezone (and timezone (minusp timezone)) tzh tzm))))) (if *print-escape* (print-unreadable-object (self stream :identity nil :type t) (print-it)) (progn (format stream "Gregorian ") (print-it)))) self) (defun gregorian (&key (year 1582 yearp) (month +october+ monthp) (day 15 dayp) (hour 0 hourp) (minute 0 minutep) (seconde 0 secondep) (timezone nil) (universal-time nil)) " RETURN: A new Gregorian date. YEAR: The year (historically, should be greater or equal to 1582). MONTH: The month. DAY: The day. HOUR: The hour. MINUTE: The minute. SECONDE: The second. TIMEZONE: The timezone. UNIVERSAL-TIME: The date expressed in universal-time. NOTE: UNIVERSAL-TIME when present gives a base date with default values for the other fields. " (if universal-time (multiple-value-bind (se mi ho da mo ye) (apply (function decode-universal-time) universal-time (when timezone (list timezone))) (gregorian :year (if yearp year ye) :month (if monthp month mo) :day (if dayp day da) :hour (if hourp hour ho) :minute (if minutep minute mi) :seconde (if secondep seconde se) :timezone timezone)) (multiple-value-bind (se mi ho) (hms60-from-secondes (hms60-to-secondes seconde minute hour)) (multiple-value-bind (dinc ho) (floor ho 24) ;; Note: since we increment the day first, a null timezone, ;; denoting the current timezone, may be a different timezone ;; than the original day, for DST. (multiple-value-bind (da mo ye) (date-from-day-number (date-to-day-number (+ day dinc) month year)) (make-instance 'gregorian-calendar-date :year ye :month mo :day da :hour ho :minute mi :seconde se :timezone timezone)))))) (defconstant +1964-03-15-day-number+ 717411) ; (1+ (DATE-TO-DAY-NUMBER 15 3 1964)) (defmethod weekday ((self gregorian-calendar-date)) (or (slot-value self 'weekday) (setf (slot-value self 'weekday) (with-slots (day month year) self (mod (- (date-to-day-number day month year) +1964-03-15-day-number+) 7))))) (defgeneric as-julian-date (date) (:documentation "RETURN: The date converted to the Julian calendar.")) (defmethod as-julian-date ((self gregorian-calendar-date)) (with-slots (seconde minute hour day month year) (to-timezone self 0) (julian-date seconde minute hour (julian-day-number/gregorian day month year)))) ;; (gregorian :year 2007 :month 6 :day 13 :hour 12 :timezone 0) ;; 2454264. ;; June 13, 2007 (UTC) the JDN is (defgeneric to-timezone (date timezone) (:documentation "RETURN: A new date equal to the DATE, but in the given TIMEZONE.")) (defmethod to-timezone ((self gregorian-calendar-date) timezone) (let* ((new-timezone (or timezone (current-timezone))) (my-timezone (or (timezone self) (current-timezone)))) (with-slots (seconde minute hour day month year) self (gregorian :seconde (+ seconde (- new-timezone my-timezone)) :minute minute :hour hour :day day :month month :year year :timezone new-timezone)))) (defmethod as-list-of-numbers ((self gregorian-calendar-date)) (with-slots (year month day hour minute seconde) (to-timezone self 0) (list year month day hour minute seconde))) (defgeneric units-of-list-of-numbers (date)) (defmethod units-of-list-of-numbers ((self gregorian-calendar-date)) (declare (ignorable self)) (list :year :month :day :hour :minute :seconde)) (define-date-compare-methods gregorian-calendar-date) (defgeneric as-universal-time (date) (:documentation "RETURN: The date converted to universal-time.")) (defmethod as-universal-time ((self gregorian-calendar-date)) (with-slots (year month day hour minute seconde timezone) self (apply (function encode-universal-time) seconde minute hour day month year (when timezone (list (/ timezone -3600)))))) (defgeneric next-day (date &optional increment) (:documentation "RETURN: A new date that is INCREMENT days after DATE.")) (defgeneric increment-day (date &optional increment) (:documentation "DO: Changes the DATE to INCREMENT days after DATE.")) (defgeneric previous-day (date &optional increment) (:documentation "RETURN: A new date that is INCREMENT days before DATE.")) (defgeneric decrement-day (date &optional increment) (:documentation "DO: Changes the DATE to INCREMENT days before DATE.")) (defmethod next-day ((self gregorian-calendar-date) &optional (increment 1)) (with-slots (year month day hour minute seconde timezone) self (gregorian :year year :month month :day (+ day increment) :hour hour :minute minute :seconde seconde :timezone timezone))) (defmethod increment-day ((self gregorian-calendar-date) &optional (increment 1)) (with-slots (year month day weekday) self (multiple-value-bind (da mo ye) (date-from-day-number (com.informatimago.common-lisp.cesarum.gregorian-calendar:date-to-day-number (+ day increment) month year)) (setf year ye month mo day da weekday nil) self))) (defmethod previous-day ((self gregorian-calendar-date) &optional (increment 1)) (next-day self (- increment))) (defmethod decrement-day ((self gregorian-calendar-date) &optional (increment 1)) (increment-day self (- increment))) (defmethod duration-between ((end gregorian-calendar-date) (start gregorian-calendar-date)) (with-slots ((eye year) (emo month) (eda day) (eho hour) (emi minute) (ese seconde)) (to-timezone end 0) (with-slots ((sye year) (smo month) (sda day) (sho hour) (smi minute) (sse seconde)) (to-timezone start 0) (let ((ye (- eye sye)) (mo (- emo smo)) (da (- eda sda)) (ho (- eho sho)) (mi (- emi smi)) (se (- ese sse))) (apply (function duration) (append (unless (zerop ye) (list :year ye)) (unless (zerop mo) (list :month mo)) (unless (zerop da) (list :day da)) (unless (zerop ho) (list :hour ho)) (unless (zerop mi) (list :minute mi)) (unless (zerop se) (list :seconde se)))))))) (defmethod date-after ((self gregorian-calendar-date) (duration duration)) (multiple-value-bind (se mi ho da mo ye) (collapse-julian-duration duration) (with-slots (seconde minute hour day month year) self (gregorian :seconde (+ se seconde) :minute (+ mi minute) :hour (+ ho hour) :day (+ da day) :month (+ mo month) :year (+ ye year) :timezone (timezone self))))) (defmethod date-before ((self gregorian-calendar-date) (duration duration)) (date-after self (duration- (duration :seconde 0) duration))) ;; (let ((day (gregorian :year 2007 :month 3 :day 24 :hour 12))) ;; (duration-between (date-after day (duration :day 1)) day)) ;; #<DURATION 1 day> ;; (let ((day (gregorian :year 2007 :month 3 :day 24 :hour 12))) ;; (- (as-universal-time (date-after day (duration :day 1))) ;; (as-universal-time day))) ;; 82800 ;; (gregorian :year 1582 :month +october+ :day 15) ;; first monday of the month ;; (defun julian-date-now () ;; " ;; RETURN: The julian-DATE of now. ;; " ;; (error "Not implemented yet.") ;; (get-universal-time)) ;; ;; ;; (defun today () ;; " ;; RETURN: The DATE of today, that is, the time 00:00:00 in the same day as now. ;; " ;; (make-instance 'date :date (now) :hour 0 :minute 0 :seconde 0)) ;; ;; ;; (defmethod monday-before ((date date)) ;; " ;; RETURN: The DATE of the Monday before date. ;; " ;; (let ((day (make-instance 'date :date date :hour 0 :minute 0 :seconde 0))) ;; (date-before day (make-instance 'duration ;; :secondes (* *day* (day-of-week today)))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; #| On the surface of the same planet, the time flows about the same speed everywhere. (There are some places where gravitation anomalities make time flow at different speeds, but they're very localized). On the other hand, on the surfaces of different planets (with different gravity, if only that of the Sun), or on different orbits, time flows at different speeds, which gives macroscopic offsets over time periods of about a year, and which are very significant for GPS like applications. Proper times flow at different (and possibly varying) speed depending on the speed and gravity of the clocks. Therefore we'd need to keep track of several proper times and of the coordinate times, and be able to convert from one to the other with relativistic formulas. For now we just ignore this layer, and will use the CL universal-time, which is a kind of proper time. +-----------------------------------------------------+ | proper time | coordinate time | cl:universal-time | +-----------------------------------------------------+ TT TCG Terrestrial Geocentric Time Coordinate Time MT Martian Time Another layer is that of the calendars. Calendars are naming schemes for time intervals, relatively to some place and some political entity. Calendars may be "classes" of naming schemes, for example when dealing with time zones. Note that time zones are recent invention (since trains), and before them there was a continuum of times all around the planet. NASA defines for Mars a sol (= martian day) as 24 martian hours of 60 martian minutes of 60 martian secondes. These martian seconds aren't the same length as Earth seconds (first because a martian day is 24 hours 39 minutes 35.244 secondes, and then because of relativistic time dilation, one second on Mars is different than one second on Earth). The Darian calendar defines the naming scheme for martian sols. In Gregorian calendar, day Tuesday June 12th 2007 CEST (= at that time UTC+2), starts from 3390588000 seconds (cl:universal-time) and ends at 3390674400 seconds (cl:universal-time). Time intervals, or durations, can be defined physically as the difference between two times expressed in the time unit (second). Calendar time intervals or durations are defined in terms of calendar. These intervals may correspond to variable physical durations, depending on which calendar day they're counted from. One Gregorian "month" may be 2419200, 2505600, 2592000, 2678400, or even 2566800 or 2700000 (when summer/winter shifts occur) seconds long. Gregorian legal "days" may be 23, 24 or 25 hours (summer/winter). When leap seconds occur, one second may be added or subtracted from the day length. For these reasons, calendar calculations cannot be done in general as calculation on the physical time, but need to be done symbolically, in the context of each calendar. Some calculations can be done generically for the whole calendar class, but when computing times, it is in general needed to consider the time zone and the political entity relative to the calendar to get precise results. For example, the number of hours between two calendar datetimes may depend on whether a summer/winter time transition occurs in between and these transition dates depend on the country and time zone. Historical calendars Days were divided in 12 hours of variable length according to the length of the diurn period. Calendar day used to started at noon, since it was the stable easily measurable time. See JULIAN-DATE too. Given a Julian-Date (TT), and a place (or political authority), we can determine the calendar used, and the name of the day and time, and vice-versa. (day-precedes (julian :year 1582 :month +october+ :day 4) (gregorian :year 1582 :month +october+ :day 15)) (adoted-calendar ("Spain" "Spain Territories" "Portugal" "Polish-Lithuanian Commonwealth" "Italy") (gregorian :year 1582 :month +october+ :day 15)) (adoted-calendar ("France") (gregorian :year 1582 :month +december+ :day 20)) (adoted-calendar ("Protestant Dutch Provinces of Holand and Zeeland") (gregorian :year 1582 :month +december+ :day :unknwon)) (adopted-calendar ("British Empire") (gregorian :year 1752 :month )) |# #| (defconstant +sun-mass+ 1.989e+30) (defconstant +earth-mass+ 5.9736e+24) (defconstant +mars-mass+ 6.419e+23) (defconstant +earth-semimajor-axis+ 149600000.0) (defconstant +mars-semimajor-axis+ 227900000.0) (defconstant +earth-radius-mean+ 6371000.0) (defconstant +earth-equatorial-radius+ 6378100.0) (defconstant +mars-equatorial-radius+ 3397000.0) (defconstant +earth-sidereal-orbit-period+ (* 365.256D0 24 60 60)) (defconstant +mars-sidereal-orbit-period+ (* 686.98D0 24 60 60)) (defconstant +G+ 6.672D-11 "Gravitational constant") (defconstant +c+ 299792458.0D0 "Speed of light") (declaim (inline square)) (defun square (x) (* x x)) (defun time-in-gravitational-field (time mass distance) ;; http://en.wikipedia.org/wiki/Gravitational_time_dilation#Important_things_to_stress ;; (= t0 (* tf (sqrt (- 1 (/ (* 2 G M) (* r (square c))))))) ;; ;; * t0 is the proper time between events A and B for a slow-ticking ;; observer within the gravitational field, ;; ;; * tf is the proper time between events A and B for a fast-ticking ;; observer distant from the massive object (and therefore outside of ;; the gravitational field), ;; ;; * G is the gravitational constant, ;; ;; * M is the mass of the object creating the gravitational field, ;; ;; * r is the radial coordinate of the observer (which is analogous to ;; the classical distance from the center of the object, but is ;; actually a Schwarzschild coordinate), ;; ;; * c is the speed of light, and ;; ;; * r0 = 2GM / c² is the called the Schwarzschild Radius of M. If a mass ;; collapses so that its surface lies at less than this radial ;; coordinate (or in other words covers an area of less than 16πG²M²/c⁴), ;; then the object exists within a black hole. (* time (sqrt (- 1D0 (/ (* 2D0 +G+ mass) (* distance (square +c+))))))) (defun time-in-rotational-field (time distance angular-velocity) ;; http://en.wikipedia.org/wiki/Gravitational_time_dilation#Important_things_to_stress ;; td = (sqrt (- 1 (/ (* (square r) (square omega)) (square c)))) ;; ;; * r is the distance from the center of the disk (which is the ;; location of the base observer), and ;; ;; * ω is the angular velocity of the disk. (* time (sqrt (- 1d0 (square (/ (* distance angular-velocity) +c+)))))) ;;; Time dilation between Earth and Mars due to the gravitational ;;; field of the Sun: ;; (let ((m (time-in-gravitational-field 1 +sun-mass+ +mars-semimajor-axis+)) ;; (e (time-in-gravitational-field 1 +sun-mass+ +earth-semimajor-axis+))) ;; (/ (- m e) e)) ;; 3.391119529856771d-6 ;; (* 365 24 60 60 3.391119529856771d-6) = 106.94234549356312d0 ;; or 1 minute and 46 secondes of difference each year... ;;; Time dilation between Earth and Mars due to the gravitational ;;; field on the surface of each planet: ;; (let ((m (time-in-gravitational-field 1 +mars-mass+ +mars-equatorial-radius+)) ;; (e (time-in-gravitational-field 1 +earth-mass+ +earth-equatorial-radius+))) ;; (/ (- m e) e)) ;; 5.550024887974419d-10 ;;; Time dilation between Earth and Mars due to the rotation of the planets ;;; around the Sun: ;; (let ((m (time-in-rotational-field ;; 1 +mars-semimajor-axis+ (/ (* 2D0 pi) +mars-sidereal-orbit-period+))) ;; (e (time-in-rotational-field ;; 1 +earth-semimajor-axis+ (/ (* 2D0 pi) +earth-sidereal-orbit-period+)))) ;; (/ (- m e) e)) ;; 1.697589551569186946L-15 (defconstant +mars-tropical-year+ 668.5921 "sol") (loop repeat 100 for year from 0 for i = 0 then (+ i 0.5921) do (format t "~&~4D ~8,6F " year i) do (when (<= 1 i) (decf i) (princ "bisextile" ))) |# ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;; Timezone file reading. ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;;; Authored by Daniel Lowe <[email protected]> ;; ;;; ;; ;;; Copyright (c) 2005-2006 Daniel Lowe ;; ;;; ;; ;;; Permission is hereby granted, free of charge, to any person obtaining ;; ;;; a copy of this software and associated documentation files (the ;; ;;; "Software"), to deal in the Software without restriction, including ;; ;;; without limitation the rights to use, copy, modify, merge, publish, ;; ;;; distribute, sublicense, and/or sell copies of the Software, and to ;; ;;; permit persons to whom the Software is furnished to do so, subject to ;; ;;; the following conditions: ;; ;;; ;; ;;; The above copyright notice and this permission notice shall be ;; ;;; included in all copies or substantial portions of the Software. ;; ;;; ;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;; ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;; ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;; ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE ;; ;;; LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION ;; ;;; OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ;; ;;; WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; (defstruct timezone ;; (transitions nil :type list) ;; (subzones nil :type list) ;; (leap-seconds nil :type list) ;; (path nil) ;; (name "anonymous" :type string) ;; (loaded nil :type boolean)) ;; ;; ;; (defun read-binary-integer (stream byte-count &optional (signed nil)) ;; "Read BYTE-COUNT bytes from the binary stream STREAM, and ;; return an integer which is its representation in network byte order (MSB). ;; If SIGNED is true, interprets the most significant bit as a sign indicator." ;; (loop for offset from (* (1- byte-count) 8) downto 0 by 8 ;; with result = 0 ;; do (setf (ldb (byte 8 offset) result) (read-byte stream)) ;; finally (if (and signed (< #x80000000 result)) ;; (return (- result #x100000000)) ;; (return result)))) ;; ;; ;; (defun string-from-unsigned-vector (vector offset) ;; "Returns a string created from the vector of unsigned bytes VECTOR ;; starting at OFFSET which is terminated by a 0." ;; (let ((null-pos (or (position 0 vector :start offset) (length vector)))) ;; (with-output-to-string (str) ;; (loop for idx from offset upto (1- null-pos) ;; do (princ (code-char (aref vector idx)) str))))) ;; ;; ;; (defun realize-timezone (zone &optional reload) ;; "If timezone has not already been loaded or RELOAD is non-NIL, ;; loads the timezone information from its associated unix file." ;; (when (or reload (not (timezone-loaded zone))) ;; (with-open-file (inf (timezone-path zone) ;; :direction :input ;; :element-type 'unsigned-byte) ;; ;; read and verify magic number ;; (let ((magic-buf (make-array 4 :element-type 'unsigned-byte))) ;; (read-sequence magic-buf inf :start 0 :end 4) ;; (when (string/= (map 'string #'code-char magic-buf) "TZif" :end1 4) ;; (error "~a is not a timezone file." (timezone-path zone)))) ;; ;; skip 16 bytes for "future use" ;; (let ((ignore-buf (make-array 16 :element-type 'unsigned-byte))) ;; (read-sequence ignore-buf inf :start 0 :end 16)) ;; ;; read header values ;; (let ((utc-indicator-count (read-binary-integer inf 4)) ;; (wall-indicator-count (read-binary-integer inf 4)) ;; (leap-count (read-binary-integer inf 4)) ;; (transition-count (read-binary-integer inf 4)) ;; (type-count (read-binary-integer inf 4)) ;; (abbrev-length (read-binary-integer inf 4))) ;; (let ((timezone-transitions ;; ;; read transition times ;; (loop for idx from 1 upto transition-count ;; collect (read-binary-integer inf 4 t))) ;; ;; read local time indexes ;; (local-time-indexes ;; (loop for idx from 1 upto transition-count ;; collect (read-binary-integer inf 1))) ;; ;; read local time info ;; (local-time-info ;; (loop for idx from 1 upto type-count ;; collect (list (read-binary-integer inf 4 t) ;; (/= (read-binary-integer inf 1) 0) ;; (read-binary-integer inf 1)))) ;; ;; read leap second info ;; (leap-second-info ;; (loop for idx from 1 upto leap-count ;; collect (list (read-binary-integer inf 4) ;; (read-binary-integer inf 4)))) ;; (abbreviation-buf (make-array abbrev-length :element-type 'unsigned-byte))) ;; (read-sequence abbreviation-buf inf :start 0 :end abbrev-length) ;; (let ((wall-indicators ;; ;; read standard/wall indicators ;; (loop for idx from 1 upto wall-indicator-count ;; collect (read-binary-integer inf 1))) ;; ;; read UTC/local indicators ;; (local-indicators ;; (loop for idx from 1 upto utc-indicator-count ;; collect (read-binary-integer inf 1)))) ;; (setf (timezone-transitions zone) ;; (nreverse ;; (mapcar ;; (lambda (info index) ;; (list info index)) ;; timezone-transitions ;; local-time-indexes))) ;; (setf (timezone-subzones zone) ;; (mapcar ;; (lambda (info wall utc) ;; (list (first info) ;; (second info) ;; (string-from-unsigned-vector abbreviation-buf (third info)) ;; (/= wall 0) ;; (/= utc 0))) ;; local-time-info ;; wall-indicators ;; local-indicators)) ;; (setf (timezone-leap-seconds zone) ;; leap-second-info))))) ;; (setf (timezone-loaded zone) t)) ;; zone) ;; ;; ;; (defparameter +utc-zone+ (make-timezone :subzones '((0 nil "UTC" nil nil)) ;; :name "UTC" ;; :loaded t) ;; "The zone for Coordinated Universal Time.") ;; ;; ;; (defmacro define-timezone (zone-name zone-file &key (load nil)) ;; "Define zone-name (a symbol or a string) as a new timezone, ;; lazy-loaded from zone-file (a pathname designator relative to the ;; zoneinfo directory on this system. If load is true, load immediately." ;; (declare (type (or string symbol) zone-name)) ;; (let ((zone-sym (if (symbolp zone-name) zone-name (intern zone-name)))) ;; `(prog1 ;; (defparameter ,zone-sym ;; (make-timezone :path ,zone-file ;; :name ,(if (symbolp zone-name) ;; (string-downcase (symbol-name zone-name)) ;; zone-name))) ;; ,@(when load ;; `((realize-timezone ,zone-sym)))))) ;; ;; ;; (defvar *default-timezone*) ;; (eval-when (:load-toplevel :execute) ;; (let ((default-timezone-file #p"/etc/localtime")) ;; (if (probe-file default-timezone-file) ;; (define-timezone *default-timezone* default-timezone-file :load t) ;; (defparameter *default-timezone* +utc-zone+)))) ;; ;; ;; (defparameter *timezone-repository* nil ;; "A list of (list \"Europe/Budapest\" timezone) entries") ;; (defparameter *timezone-offset->timezone* (make-hash-table)) ;; ;; (eval-when (:load-toplevel :execute) ;; (defun reread-timezone-repository () ;; (let* ((root-directory "/usr/share/zoneinfo/" ;; #| (merge-pathnames "zoneinfo/" *project-home-directory*) |#) ;; (cutoff-position (length (princ-to-string root-directory))) ;; (visitor ;; (lambda (file) ;; (let* ((full-name (subseq (princ-to-string file) cutoff-position)) ;; (name (pathname-name file)) ;; (timezone (realize-timezone ;; (make-timezone :path file :name name)))) ;; (push (list full-name timezone) *timezone-repository*) ;; ;; TODO this entire *timezone-offset->timezone* is probably ;; ;; useless this way, we can't reverse map a +01:30 ;; ;; offset to a timezone struct, or can we? ;; (dolist (subzone (timezone-subzones timezone)) ;; (pushnew timezone (gethash (first subzone) ;; *timezone-offset->timezone*))))))) ;; (setf *timezone-repository* nil) ;; (setf *timezone-offset->timezone* (make-hash-table)) ;; (walk-directory root-directory visitor :directories nil ;; :test (lambda (file) ;; (not (find "Etc" (pathname-directory file) ;; :test #'string=)))) ;; ;; walk the Etc dir last, so they will be the first entries in ;; ;; the *timezone-offset->timezone* map ;; (walk-directory (merge-pathnames "Etc/" root-directory) visitor ;; :directories nil) ;; (setf *timezone-repository* ;; (sort *timezone-repository* #'string< :key #'first))))) ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; (defclass julian-calendar-day (calendar-day) ;; ()) ;; ;; (defclass coptic-calendar-day (calendar-day) ;; ()) ;; ;; (defclass ethiopian-calendar-day (calendar-day) ;; ()) ;; ;; (defclass revised-julian-calendar-day (calendar-day) ;; ()) ;; ;; (defclass chinese-calendar-day (calendar-day) ;; ()) ;; ;; (defclass hebrew-calendar-day (calendar-day) ;; ()) ;; ;; (defclass islamic-calendar-day (calendar-day) ;; ()) ;; ;; (defclass hindu-calendar-day (calendar-day) ;; ()) ;; ;; (defclass iranian-calendar-day (calendar-day) ;; ()) ;; # Aztec Calendar ;; # Bahá'í calendar ;; # Bengali calendar ;; # Buddhist calendar ;; # Calendar of saints ;; # Chinese calendar ;; # Christian calendar ;; # Discordian calendar ;; # Eastern Orthodox liturgical calendar ;; # Ethiopian calendar ;; # French Republican Calendar ;; # Gregorian calendar ;; # Hebrew calendar ;; # Hindu calendar ;; # Samvat ;; # Iranian calendar ;; # Islamic calendar ;; # Julian calendar ;; # Liturgical year ;; # Maya calendar ;; # Malayalam calendar ;; # Nanak Shahi calendar ;; # Pawukon calendar of Bali ;; # Perpetual calendar ;; # Runic calendar ;; # Wall calendar ;; # Zoroastrian calendar #|| (loop :with day = (gregorian :year 2007 :month 1 :day 1 :hour 12) :repeat 365 :do (princ day) (terpri) (increment-day day)) (com.informatimago.common-lisp.cesarum.date.utility:as-list-of-numbers (gregorian :year 2007 :month 9 :day 30)) (list (COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DATE.UTILITY:JULIAN-DAY-NUMBER/julian 30 9 2007) (COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DATE.UTILITY:JULIAN-DAY-NUMBER/GREGORIAN 30 9 2007) (COM.INFORMATIMAGO.COMMON-LISP.CESARUM.GREGORIAN-CALENDAR:DATE-TO-DAY-NUMBER 30 9 2007) ) ||# ;;;; THE END ;;;;
63,740
Common Lisp
.lisp
1,354
41.008863
105
0.600735
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
5aa02b48ccc55bcc2823de51a94a45bdc5a9517c58f2fd7d6cca537390c0c816
5,098
[ -1 ]
5,099
sparse-vector-test.lisp
informatimago_lisp/common-lisp/cesarum/sparse-vector-test.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: sparse-vector-test.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Test sparse-vector.lisp ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2015-03-25 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SPARSE-VECTOR.TEST" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SIMPLE-TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SPARSE-VECTOR") (:export "TEST/ALL")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SPARSE-VECTOR.TEST") ;; (let* ((size 1000000) ;; (primes (com.informatimago.common-lisp.arithmetic.primes:compute-primes-to size))) ;; (loop :for node :in '(2 5 7 8 13 16 29 32 64 128 256 1000 1024 2048) ;; :do (let ((v (make-vector-tree node size :element-type 'fixnum :initial-element -1))) ;; (loop :for i :below (length primes) ;; :do (setf (vector-ref v i) (* i i))) ;; (format t "n=~4D len=~8D cnt=~8D spc=~8D l/s=~5,3F c/l=~5,3F c/s=~5,3F~%" ;; node ;; (vector-length v) ;; (vector-count v) ;; (vector-storage-size v) ;; (float (/ (vector-storage-size v) ;; (vector-length v))) ;; (float (/ (vector-count v) ;; (vector-length v))) ;; (float (/ (vector-count v) ;; (vector-storage-size v))))))) ;; ;; n= 2 len= 1000000 cnt= 78498 spc= 157033 l/s=0.157 c/l=0.078 c/s=0.500 ;; n= 5 len= 1000000 cnt= 78498 spc= 98171 l/s=0.098 c/l=0.078 c/s=0.800 ;; n= 7 len= 1000000 cnt= 78498 spc= 91621 l/s=0.092 c/l=0.078 c/s=0.857 ;; n= 8 len= 1000000 cnt= 78498 spc= 89782 l/s=0.090 c/l=0.078 c/s=0.874 ;; n= 13 len= 1000000 cnt= 78498 spc= 85119 l/s=0.085 c/l=0.078 c/s=0.922 ;; n= 16 len= 1000000 cnt= 78498 spc= 83836 l/s=0.084 c/l=0.078 c/s=0.936 ;; n= 29 len= 1000000 cnt= 78498 spc= 81497 l/s=0.081 c/l=0.078 c/s=0.963 ;; n= 32 len= 1000000 cnt= 78498 spc= 81178 l/s=0.081 c/l=0.078 c/s=0.967 ;; n= 64 len= 1000000 cnt= 78498 spc= 80096 l/s=0.080 c/l=0.078 c/s=0.980 ;; n= 128 len= 1000000 cnt= 78498 spc= 79509 l/s=0.080 c/l=0.078 c/s=0.987 ;; n= 256 len= 1000000 cnt= 78498 spc= 79819 l/s=0.080 c/l=0.078 c/s=0.983 ;; n=1000 len= 1000000 cnt= 78498 spc= 80921 l/s=0.081 c/l=0.078 c/s=0.970 ;; n=1024 len= 1000000 cnt= 78498 spc= 80819 l/s=0.081 c/l=0.078 c/s=0.971 ;; n=2048 len= 1000000 cnt= 78498 spc= 83929 l/s=0.084 c/l=0.078 c/s=0.935 ;; ;; ;; (let ((size 1000000)) ;; (loop :for node :in '(2 5 7 8 13 16 29 32 64 128 256 1000 1024 2048) ;; :do (let ((v (make-vector-tree node size :element-type 'fixnum :initial-element -1))) ;; (loop :for i :below 1000 ;; :do (setf (vector-ref v i) (* i i))) ;; (loop :for i :from 900000 :by 7 :repeat 1000 ;; :do (setf (vector-ref v i) (* i i))) ;; (format t "n=~4D len=~8D cnt=~8D spc=~8D l/s=~5,3F c/l=~5,3F c/s=~5,3F~%" ;; node ;; (vector-length v) ;; (vector-count v) ;; (vector-storage-size v) ;; (float (/ (vector-storage-size v) ;; (vector-length v))) ;; (float (/ (vector-count v) ;; (vector-length v))) ;; (float (/ (vector-count v) ;; (vector-storage-size v))))))) ;; ;; n= 2 len= 1000000 cnt= 2000 spc= 11326 l/s=0.011 c/l=0.002 c/s=0.177 ;; n= 5 len= 1000000 cnt= 2000 spc= 8491 l/s=0.008 c/l=0.002 c/s=0.236 ;; n= 7 len= 1000000 cnt= 2000 spc= 9485 l/s=0.009 c/l=0.002 c/s=0.211 ;; n= 8 len= 1000000 cnt= 2000 spc= 9281 l/s=0.009 c/l=0.002 c/s=0.215 ;; n= 13 len= 1000000 cnt= 2000 spc= 8843 l/s=0.009 c/l=0.002 c/s=0.226 ;; n= 16 len= 1000000 cnt= 2000 spc= 8725 l/s=0.009 c/l=0.002 c/s=0.229 ;; n= 29 len= 1000000 cnt= 2000 spc= 8726 l/s=0.009 c/l=0.002 c/s=0.229 ;; n= 32 len= 1000000 cnt= 2000 spc= 8538 l/s=0.009 c/l=0.002 c/s=0.234 ;; n= 64 len= 1000000 cnt= 2000 spc= 8828 l/s=0.009 c/l=0.002 c/s=0.227 ;; n= 128 len= 1000000 cnt= 2000 spc= 9022 l/s=0.009 c/l=0.002 c/s=0.222 ;; n= 256 len= 1000000 cnt= 2000 spc= 9694 l/s=0.010 c/l=0.002 c/s=0.206 ;; n=1000 len= 1000000 cnt= 2000 spc= 9992 l/s=0.010 c/l=0.002 c/s=0.200 ;; n=1024 len= 1000000 cnt= 2000 spc= 11255 l/s=0.011 c/l=0.002 c/s=0.178 ;; n=2048 len= 1000000 cnt= 2000 spc= 14331 l/s=0.014 c/l=0.002 c/s=0.140 (define-test test/vector-tree (&key verbose) (flet ((report (v) (when verbose (format *trace-output* "~&length=~3D, count=~3D, space=~3D, ratio=~5,2F~%" (vector-length v) (vector-count v) (vector-storage-size v) (/ (vector-count v) (vector-storage-size v)))))) ;; with fixnum: (let* ((element-type 'fixnum) (default -1) (length 18) (node-size 4) (v (make-vector-tree node-size length :initial-element default :element-type element-type)) (e (make-array length :initial-element default :element-type element-type)) (s 0)) (check equal (vector-element-type v) element-type) (check equal (vector-length v) length) (check equal (vector-element-type e) element-type) (check equal (vector-length e) length) (check equalp (vector-elements v) e) (check = (vector-count v) (count default e :test-not (function eql)) (v) "f0") (check < s (vector-storage-size v)) (setf s (vector-storage-size v)) (report v) (loop :for i :from 3 :by 7 :to 18 :do (setf (vector-ref v i) i (vector-ref e i) i)) (check equalp (vector-elements v) e) (check = (vector-count v) (count default e :test-not (function eql)) (v) "f1") (check < s (vector-storage-size v)) (setf s (vector-storage-size v)) (report v) (loop :for i :from 0 :to 6 :do (setf (vector-ref v i) i (vector-ref e i) i)) (check equalp (vector-elements v) e) (check = (vector-count v) (count default e :test-not (function eql)) (v) "f2") (check < s (vector-storage-size v)) (setf s (vector-storage-size v)) (report v) (loop :for i :from 16 :to 17 :do (setf (vector-ref v i) i (vector-ref e i) i)) (check equalp (vector-elements v) e) (check = (vector-count v) (count default e :test-not (function eql)) (v) "f3") (check <= s (vector-storage-size v)) (setf s (vector-storage-size v)) (report v) (loop :for i :from 0 :to 7 :do (setf (vector-ref v i) default (vector-ref e i) default)) (check equalp (vector-elements v) e) (check = (vector-count v) (count default e :test-not (function eql)) (v) "f4") (check > s (vector-storage-size v)) (setf s (vector-storage-size v)) (report v)) ;; with characters: (let* ((element-type 'character) (default #\space) (length 128) (node-size 11) (v (make-vector-tree node-size length :initial-element default :element-type element-type)) (e (make-array length :initial-element default :element-type element-type))) (check equal (vector-element-type v) element-type) (check equal (vector-length v) length) (check equal (vector-element-type e) element-type) (check equal (vector-length e) length) (check equalp (vector-elements v) e) (check = (vector-count v) (count default e :test-not (function eql)) (v) "c0") (report v) (loop :for i :from 33 :by 7 :to 127 :do (setf (vector-ref v i) (code-char i) (vector-ref e i) (code-char i))) (check equal (vector-elements v) e) (check = (vector-count v) (count default e :test-not (function eql)) (v) "c1") (report v) (loop :for i :from 33 :to 63 :do (setf (vector-ref v i) (code-char i) (vector-ref e i) (code-char i))) (check equal (vector-elements v) e) (check = (vector-count v) (count default e :test-not (function eql)) (v) "c2") (report v) (loop :for i :from 64 :to 95 :do (setf (vector-ref v i) (code-char i) (vector-ref e i) (code-char i))) (check equal (vector-elements v) e) (check = (vector-count v) (count default e :test-not (function eql)) (v) "c3") (report v)))) (define-test test/all () (test/vector-tree)) ;;;; THE END ;;;;
10,311
Common Lisp
.lisp
198
47.520202
102
0.537906
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
052b50ac385ffd89f290a053f47d1e6aa1a3a98dbc9614bea778f6781029ad9a
5,099
[ -1 ]
5,100
sparse-vector.lisp
informatimago_lisp/common-lisp/cesarum/sparse-vector.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: sparse-vector.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Implement a sparse vector abstraction, allowing for big ;;;; vectors, optimizing storage from empty to full vector. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2015-03-23 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SPARSE-VECTOR" (:use "COMMON-LISP") (:export ;; Conditions: "OUT-OF-BOUNDS" "OUT-OF-BOUNDS-VECTOR" "OUT-OF-BOUNDS-INDEX" ;; Generic interface: "VECTOR-LENGTH" "VECTOR-ELEMENT-TYPE" "VECTOR-REF" "VECTOR-ELEMENTS" "VECTOR-COUNT" "VECTOR-STORAGE-SIZE" ;; Vector-tree: "MAKE-VECTOR-TREE" "VECTOR-TREE" "VECTOR-TREE-P" ;; Sparse-vector: "MAKE-SPARSE-VECTOR" "SPARSE-VECTOR" "SPARSE-VECTOR-P" "SPARSE-VECTOR-COUNT" "SPARSE-VECTOR-LENGTH" "SPARSE-VECTOR-MINIMUM-INDEX" "SPARSE-VECTOR-MAXIMUM-INDEX" "SPARSE-VECTOR-REF")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SPARSE-VECTOR") ;;; ;;; Conditions ;;; (define-condition out-of-bounds (error) ((vector :initarg :vector :reader out-of-bounds-vector) (index :initarg :index :reader out-of-bounds-index)) (:report (lambda (stream condition) (let ((vector (out-of-bounds-vector condition))) (format stream "Index ~D is out of bounds for the ~S of size ~D" (out-of-bounds-index condition) (let ((type (type-of vector))) (if (listp type) (first type) type)) (vector-length vector)))))) ;;; ;;; Generic interface: ;;; (defgeneric vector-length (vector) (:documentation "RETURN: the length of the vector.") (:method ((v vector)) (length v))) (defgeneric vector-count (vector) (:documentation "RETURN: the number of elements in the vector that are not the default element.") (:method ((v vector)) (length v))) (defgeneric vector-storage-size (vector) (:documentation "RETURN: a number proportional to the storage used by the vector.") (:method ((v vector)) (length v))) (defgeneric vector-element-type (vector) (:documentation "RETURN: the element-type of the vector.") (:method ((v vector)) (array-element-type v))) (defgeneric vector-default-element (vector) (:documentation " RETURN: the default element of the vector. NOTE: It is the INITIAL-ELEMENT. ")) (defgeneric vector-ref (vector index) (:documentation " RETURN: the element in the VECTOR at the given INDEX. SIGNAL: OUT-OF-BOUNDS error if INDEX is negative or not less than the vector length. ") (:method :before (v index) (when (or (minusp index) (<= (vector-tree-length v))) (error 'out-of-bounds :vector v :index index))) (:method ((v vector) index) (aref v index))) (defgeneric (setf vector-ref) (new-value vector index) (:documentation " DO: Sets the VECTOR element at INDEX to be the NEW-VALUE. RETURN: NEW-VALUE SIGNAL: OUT-OF-BOUNDS error if INDEX is negative or not less than the vector length. TYPE-ERROR if NEW-VALUE is not of the vector element-type. ") (:method :before (new-value v index) (when (or (minusp index) (<= (vector-length v) index)) (error 'out-of-bounds :vector v :index index)) (unless (typep new-value (vector-element-type v)) (error 'type-error :datum new-value :expected-type (vector-element-type v)))) (:method (new-value (v vector) index) (setf (aref v index) new-value))) (defgeneric vector-elements (vector) (:documentation " RETURN: a CL:VECTOR of same element-type and same length containing all the elements of the vector. ") (:method ((v vector)) v)) ;;; ;;; Vector tree ;;; (defvar %none% '#:none "Internal value used in place of unallocated nodes in vector trees.") (defstruct (vector-tree (:constructor %make-vector-tree) (:copier nil)) length element-type default-element node-size root-subnode-width root) (defun make-vector-tree (node-size length &key (element-type t) (initial-element nil)) " RETURN: A new VECTOR-TREE NOTE: The new vector-tree is empty, which means that all slot have as value the initial-element (saved in vector-tree-default-element), and only the root node (a vector of size NODE-SIZE) is allocated. " (%make-vector-tree :node-size node-size :length length :element-type element-type :default-element initial-element :root-subnode-width (expt node-size (1- (ceiling (log length node-size)))) :root (make-array node-size :initial-element %none%))) (defmethod vector-length ((v vector-tree)) (vector-tree-length v)) (defmethod vector-element-type ((v vector-tree)) (vector-tree-element-type v)) (defmethod vector-default-element ((v vector-tree)) (vector-tree-default-element v)) (defmethod vector-count ((v vector-tree)) (let ((node-size (vector-tree-node-size v)) (default (vector-default-element v))) (labels ((count-elements (node subnode-size) (cond ((eql node %none%) 0) ((= subnode-size 1) (count default node :test-not (function eql))) (t (let ((subnode-size (/ subnode-size node-size))) (loop :for subnode :across node :sum (count-elements subnode subnode-size))))))) (count-elements (vector-tree-root v) (vector-tree-root-subnode-width v))))) (defmethod vector-storage-size ((v vector-tree)) (let ((node-size (vector-tree-node-size v))) (labels ((storage-size (node subnode-size) (cond ((eql node %none%) 1) ((= subnode-size 1) (length node)) (t (let ((subnode-size (/ subnode-size node-size))) (+ (length node) (loop :for subnode :across node :sum (storage-size subnode subnode-size)))))))) (storage-size (vector-tree-root v) (vector-tree-root-subnode-width v))))) (defmethod vector-ref ((v vector-tree) index) (let ((node-size (vector-tree-node-size v))) (labels ((node-ref (node subnode-width index) (let* ((subindex (truncate index subnode-width)) (val (aref node subindex))) (cond ((eql val %none%) (vector-default-element v)) ((= 1 subnode-width) val) (t (node-ref val (/ subnode-width node-size) (- index (* subindex subnode-width)))))))) (node-ref (vector-tree-root v) (vector-tree-root-subnode-width v) index)))) (defmethod (setf vector-ref) (new-value (v vector-tree) index) (let ((node-size (vector-tree-node-size v)) (default (vector-default-element v))) (labels ((node-set (node subnode-width index) (if (= 1 subnode-width) (progn (setf (aref node index) new-value) (if (and (eql new-value default) (every (lambda (element) (eql element default)) node)) %none% new-value)) (let* ((subindex (truncate index subnode-width)) (subnodes (aref node subindex))) (when (eql subnodes %none%) ; so far (setf subnodes (setf (aref node subindex) (if (= node-size subnode-width) (make-array node-size :element-type (vector-tree-element-type v) :initial-element default) (make-array node-size :element-type t :initial-element %none%))))) (let ((result (node-set subnodes (/ subnode-width node-size) (- index (* subindex subnode-width))))) (if (eql result %none%) (progn (setf (aref node subindex) %none%) (if (every (lambda (element) (eql element default)) node) %none% new-value)) result)))))) (node-set (vector-tree-root v) (vector-tree-root-subnode-width v) index)))) (defmethod vector-elements ((v vector-tree)) (let* ((node-size (vector-tree-node-size v)) (length (vector-length v)) (result (make-array length :element-type (vector-element-type v) :initial-element (vector-default-element v))) (pos 0) (default (vector-default-element v))) (labels ((node-copy (node subnode-width) (if (= 1 subnode-width) (progn (replace result node :start1 pos) (incf pos node-size)) (loop :for subnode :across node :while (< pos length) :do (if (eql subnode %none%) (progn (fill result default :start pos :end (min length (+ pos subnode-width))) (incf pos subnode-width)) (node-copy subnode (/ subnode-width node-size))))))) (node-copy (vector-tree-root v) (vector-tree-root-subnode-width v)) result))) ;;; ;;; Sparse vector ;;; ;; 1114112 (defstruct (sparse-vector (:constructor %make-sparse-vector)) data length count default-element minimum-index maximum-index) (setf (documentation 'sparse-vector-p 'function) "RETURN: whether the object is a SPARSE-VECTOR." (documentation 'sparse-vector-length 'function) "RETURN: The size of the sparse vector." (documentation 'sparse-vector-count 'function) "RETURN: The number of non-default-element elements in the sparse vector." (documentation 'sparse-vector-default-element 'function) "RETURN: The default-element of the sparse vector." (documentation 'sparse-vector-minimum-index 'function) "RETURN: The index of the first non-default-element in the sparse vector." (documentation 'sparse-vector-maximum-index 'function) "RETURN: The index of the last non-default-element in the sparse vector.") (defmethod vector-length ((v sparse-vector)) (sparse-vector-length v)) (defun make-sparse-vector (size &key initial-element) " RETURN: a new sparse vector, able to contain up to SIZE elements, filled with the INITIAL-ELEMENT value as default sparse value. " (%make-sparse-vector :data nil :length size :count 0 :default-element initial-element :minimum-index -1 :maximum-index -1)) #| While count is less than 5-35 we use an alist. node size overhead collection size overhead vector: 1/1 3 llrbtree: 4/5 3 a-list: 1/2 0 hashtable: 1/2 (ccl) 80 (ccl (default)) n-tree: 1/n n |# (defun make-k-tree-size-function (k) (lambda (count fill-ratio) (declare (ignore fill-ratio)) (let ((h (log count k))) (values (* k (truncate (1- (expt k h)) (1- k))) h)))) (defparameter *structures* ;; node size collection size ;; overhead overhead ;; access time fn ;; number of collections fn `((vector ,(lambda (count fill-ratio) (declare (ignore fill-ratio)) (values (+ 3 count) 1))) (llrbtree ,(lambda (count fill-ratio) (values (+ 3 (* 5 (* count fill-ratio))) (log count 2)))) (a-list ,(lambda (count fill-ratio) (values (* 2 (* count fill-ratio)) count))) (hashtable #+ccl ,(lambda (count fill-ratio) (values (+ 80 (* 2 (* count fill-ratio))) 1)) #-ccl ,(lambda (count fill-ratio) (values (+ 100 (* 2 count)) 1))) (2-tree ,(make-k-tree-size-function 2)) (4-tree ,(make-k-tree-size-function 4)) (8-tree ,(make-k-tree-size-function 8)) (16-tree ,(make-k-tree-size-function 16)) (32-tree ,(make-k-tree-size-function 32)) (64-tree ,(make-k-tree-size-function 64)))) (defun best-structure (block-size fill-ratio) (let ((nodes (* fill-ratio block-size))) (declare (ignore nodes)) (sort (map 'vector (lambda (struct) (destructuring-bind (name size-fn) struct (cons name (multiple-value-list (funcall size-fn block-size fill-ratio))))) *structures*) (function <) :key (function second)))) #-(and) (map nil 'print (best-structure 1000000 0.3)) (defun local-density (vector page-size default-element) (let ((density (make-array (ceiling (length vector) page-size) :initial-element 0))) (loop :for i :below (length density) :do (setf (aref density i) (/ (loop :for j :from (* i page-size) :below (min (length vector) (* (1+ i) page-size)) :sum (if (eql default-element (aref vector j)) 0 1)) page-size))) density)) #-(and) (map 'vector (lambda (x) (if (< 1/6 x) 1 0)) (local-density #(0 0 1 1 ; 2/4 0 0 0 0 0 0 1 2 ; 2/4 0 0 0 0 1 3 0 4 ; 3/4 0 0 0 0 0 0 0 0 0 0 0 5 ; 1/4 0 0 0 0 0 0 0 0) 6 0)) (defun get-cell (sparse-vector index) (unless (<= 0 index (1- (sparse-vector-length sparse-vector))) (error 'out-of-bounds :vector sparse-vector :index index)) (cond () ((not (<= (sparse-vector-minimum-index sparse-vector) index (sparse-vector-maximum-index sparse-vector))) (error "~S: out of bound index ~D length: ~D" 'sparse-vector-ref index (sparse-vector-length sparse-vector))))) (defun sparse-vector-ref (sparse-vector index) "RETURN: the value at the given index; whether it was not a default value. SIGNALS: out" (let ((cell (get-cell sparse-vector index))) (if cell (values (cell-value cell) t) (values (sparse-vector-default-element sparse-vector) nil)))) (defun (setf sparse-vector-ref) (new-value sparse-vector index) (if (eql new-value (sparse-vector-default-element sparse-vector)) (remove-cell sparse-vector index) (let ((cell (get-cell-create sparse-vector index))) (setf (cell-value cell) new-value)))) ;;;; THE END ;;;;
16,892
Common Lisp
.lisp
383
34.101828
103
0.553059
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
df0f24a16ccb42a9d74ab9c66d99506f2353ba22f6b1f85c6133374141e05806
5,100
[ -1 ]
5,101
character.lisp
informatimago_lisp/common-lisp/cesarum/character.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: character.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; See package docstring. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2021-05-22 <PJB> Removed dependency to .ascii, and added dependency to .ecma048 ;;;; 2013-07-27 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2013 - 2021 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.CHARACTER" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.ECMA048") (:shadowing-import-from "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.ECMA048" "ED") (:export "STANDARD-CHARACTER-IS-ASCII-CODED-P" "STANDARD-CHARACTERS" "HAS-ASCII-CODE-P" "HAS-CHARACTER-NAMED-P" "PUSH-FEATURE-FOR-CHARACTER-NAMED") (:documentation " Define features (both at compilation time, load time and execute) for present semi-standard character names and other ASCII features. #+has-rubout can read #\rubout #+has-page can read #\page #+has-tab can read #\tab #+has-backspace can read #\backspace #+has-return can read #\return #+has-linefeed can read #\linefeed #+has-escape can read #\escape #+has-bell can read #\bell #+has-vt can read #\vt #+has-null can read #\null #+has-ascii-standard-characters The characters in the STANDARD-CHARACTER set are encoded with the ASCII code by CHAR-CODE; #+has-ascii-code The characters in the STANDARD-CHARACTER set are encoded with the ASCII code by CHAR-CODE; and the codes between 0 and 31 inclusive plus 127 have a bijection with other characters, thru CODE-CHAR and char-code; and the optional named characters have codes matching their ASCII control code: (= (CHAR-CODE #\Return) CR), etc. #+newline-is-return <=> (CHAR= #\Newline #\Return) #+newline-is-linefeed <=> (CHAR= #\Newline #\Linefeed) License: AGPL3 Copyright Pascal J. Bourguignon 2013 - 2021 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.CHARACTER") #+mocl (setf *features* (append '(:newline-is-linefeed :has-ascii-code :has-vt :has-bell :has-escape :has-linefeed :has-return :has-backspace :has-tab :has-page :has-rubout) *features*)) (eval-when (:compile-toplevel :load-toplevel :execute) (defparameter *standard-characters* #.(concatenate 'string " !\"#$%&'()*+,-./0123456789:;<=>?" "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" "`abcdefghijklmnopqrstuvwxyz{|}~") "A string containing all the STANDARD-CHARACTER. Notice: it's the same character set as COM.INFORMATIMAGO.COMMON-LISP.CESARUM.ASCII:*ASCII-CHARACTERS*.") (defun standard-characters () "Return a string containing all the standard-characters." (copy-seq *standard-characters*)) (defun has-character-named-p (name) " NAME: A case-insensitive string designator for the semi-standard character names: Rubout The rubout or delete character. Page The form-feed or page-separator character. Tab The tabulate character. Backspace The backspace character. Return The carriage return character. Linefeed The line-feed character. Return: Whether reading #\{name} will not produce an error. " (ignore-errors (read-from-string (format nil "#\\~A" name)))) (defun push-feature-for-character-named (name) " NAME: A case-insensitive string designator for the semi-standard character names: Rubout The rubout or delete character. Page The form-feed or page-separator character. Tab The tabulate character. Backspace The backspace character. Return The carriage return character. Linefeed The line-feed character. DO: If the implementation has the semi standard character named NAME, then push a feature :HAS-{NAME}, with NAME upcased. " (when (has-character-named-p name) (pushnew (intern (format nil "~:@(HAS-~A~)" name) (load-time-value (find-package"KEYWORD"))) *features*))) #-mocl (dolist (name '("Rubout" "Page" "Tab" "Backspace" "Return" "Linefeed" ;; Non standard character names: "Escape" "Bell" "Vt" "Null")) (push-feature-for-character-named name)) ) ;;eval-when ;; Must be a separate form: (eval-when (:compile-toplevel :load-toplevel :execute) (defconstant SP #x20 " Code of ASCII Character SPACE") (defun standard-character-is-ascii-coded-p () "Whether the char-code of the standard-characters are their ASCII codes. This exclude testing the presence or encoding of ASCII control codes." (load-time-value (ignore-errors (flet ((ascii-code (ch) " RETURN: The ASCII code of the character ch, or NIL if the character has no ascii code. Only printable characters are accepted. No control code. " (let ((code (position ch *standard-characters*))) (when code (+ SP code))))) (every (lambda (ch) (equal (char-code ch) (ascii-code ch))) *standard-characters*))))) (defun has-ascii-code-p () "Whether it looks like ASCII is implemented by char-code and code-char. Including control codes from 0 to 31 and 127." (let ((codes (cons 127 (loop :for code :from 0 :to 31 :collect code)))) (and ;; printable characters are ASCII-CODED: (standard-character-is-ascii-coded-p) ;; all control-codes have characters that map back to the code: (ignore-errors (every (lambda (code) (let ((char (code-char code))) (when char (equal (char-code char) code)))) codes)) ;; the mapping between control codes and characters is a bijection: (let ((chars (delete-duplicates (mapcar (function code-char) codes) :test (function equal)))) (and (not (member nil chars)) (= 33 (length chars)))) ;; The optional character names match the ASCII codes they represent: #+has-bell (= BEL (char-code #\bell)) #+has-backspace (= BS (char-code #\backspace)) #+has-tab (= HT (char-code #\tab)) #+has-linefeed (= LF (char-code #\linefeed)) #+has-vt (= VT (char-code #\vt)) #+has-page (= FF (char-code #\page)) #+has-return (= CR (char-code #\return)) #+has-escape (= ESC (char-code #\escape)) #+has-rubout (= DEL (char-code #\rubout))))) #-mocl (progn (when (standard-character-is-ascii-coded-p) (pushnew :has-ascii-standard-characters *features*)) (when (has-ascii-code-p) (pushnew :has-ascii-code *features*)) #+has-return (when (char= #\newline #\return) (pushnew :newline-is-return *features*)) #+has-linefeed (when (char= #\newline #\linefeed) (pushnew :newline-is-linefeed *features*))) ) ;;eval-when ;;;; THEN END ;;;;
9,431
Common Lisp
.lisp
203
38.413793
87
0.605882
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
e66426aeb066879effbf6c4c0ee3bfdae62436aa6c85c060fa36a9718f3fd018
5,101
[ -1 ]
5,102
queue.lisp
informatimago_lisp/common-lisp/cesarum/queue.lisp
;;;; -*- coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: queue.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: None ;;;;DESCRIPTION ;;;; ;;;; This module exports a queue type. This is a structure optimized for ;;;; FIFO operations, keeping a pointer to the head and the tail of a list. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2012-04-28 <PJB> Added QUEUE-ELEMENTS. ;;;; 2005-08-31 <PJB> Added QUEUE-DELETE. ;;;; 2004-02-26 <PJB> Formated for publication. ;;;; 2001-12-31 <PJB> Added pjb-queue-requeue. ;;;; Corrected the return value of some methods. ;;;; 2001-11-12 <PJB> Creation. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2001 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.QUEUE" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY") (:export "QUEUE-TEST" "QUEUE-INVARIANT" "QUEUE-DELETE" "QUEUE-REQUEUE" "QUEUE-DEQUEUE" "QUEUE-ENQUEUE" "QUEUE-LAST-ELEMENT" "QUEUE-FIRST-ELEMENT" "QUEUE-EMPTY-P" "QUEUE-LENGTH" "MAKE-QUEUE" "QUEUE" "QUEUE-ELEMENTS" "QUEUE-APPEND") (:import-from "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY" "WHILE") (:documentation " This module exports a queue type. This is a structure optimized for FIFO operations, keeping a pointer to the head and the tail of a list. The structure of a queue is as follow: queue | V +------+------+ | head | tail |--------------------------+ +------+------+ | | | V V +------+------+ +------+------+ +------+------+ | car | cdr |--->| car | cdr |--->| car | cdr |--->nil +------+------+ +------+------+ +------+------+ | | | V V V +------+ +------+ +------+ | elem | | elem | | elem | +------+ +------+ +------+ License: AGPL3 Copyright Pascal J. Bourguignon 2001 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.QUEUE") (defstruct (queue (:constructor %make-queue)) "The queue structure." (head nil :type list) (tail nil :type list)) (declaim (inline queue-elements)) (defun queue-elements (queue) "RETURN: The list of elements in the queue." (queue-head queue)) (defun queue-invariant (queue) " DO: Check the invariant of the QUEUE structure. " (check-type queue queue) (assert (or (and (null (queue-head queue)) (null (queue-tail queue))) (and (queue-head queue) (queue-tail queue)))) (when (queue-head queue) (assert (list-length (queue-head queue))) ; not a circular list. (assert (search (queue-tail queue) (queue-head queue) :test (function eq))) (assert (null (cdr (queue-tail queue)))))) (defun make-queue () "RETURN: A new empty queue." (%make-queue)) (defun queue-length (queue) " PRE: (queue-p queue) RETURN: The number of elements in the queue. " (check-type queue queue) (length (queue-head queue))) (defun queue-empty-p (queue) " RETURN: (= 0 (queue-length queue)) " (check-type queue queue) (null (queue-head queue))) (defun queue-first-element (queue) " PRE: (queue-p queue) RETURN: The first element of the queue. " (check-type queue queue) (first (queue-head queue))) (defun queue-last-element (queue) " PRE: (queue-p queue) RETURN: The last element of the queue. " (check-type queue queue) (first (queue-tail queue))) (defun queue-enqueue (queue element) " PRE: (queue-p queue) l=(queue-length queue) POST: (eq (queue-last-element queue) element), (queue-p queue), l+1=(queue-length queue) RETURN: queue " (check-type queue queue) ;; (car q) = head (cdr q) = tail (if (queue-head queue) (progn ;; There's already an element, just add to the tail. (setf (cdr (queue-tail queue)) (cons element nil)) (setf (queue-tail queue) (cdr (queue-tail queue)))) (progn ;; The queue is empty, let's set the head. (setf (queue-head queue) (cons element nil)) (setf (queue-tail queue) (queue-head queue)))) queue) (defun queue-append (queue elements) " DO: appends the elements to the queue. PRE: (queue-p queue) ql=(queue-length queue) el=(length elements) POST: (< 0 el) ⇒ (eq (queue-last-element queue) (first (last elements))) (queue-p queue), ql+el=(queue-length queue) RETURN: queue " (check-type queue queue) ;; (car q) = head (cdr q) = tail (if (queue-head queue) (progn ;; There's already an element, just add to the tail. (setf (cdr (queue-tail queue)) (copy-list elements)) (setf (queue-tail queue) (last (queue-tail queue)))) (progn ;; The queue is empty, let's set the head. (setf (queue-head queue) (copy-list elements)) (setf (queue-tail queue) (last (queue-head queue))))) queue) (defun queue-delete (queue element &key (test (function eql))) " POST: (not (member element queue :test test)) RETURN: queue " (setf (queue-head queue) (delete element (queue-head queue) :test test) (queue-tail queue) (last (queue-head queue))) queue) (defun queue-dequeue (queue) " PRE: (queue-p queue) l=(queue-length queue) f=(queue-first-element queue) POST: l>0 ==> l-1=(queue-length queue) l=0 ==> 0=(queue-length queue) RETURN: f " (check-type queue queue) (prog1 (pop (queue-head queue)) (when (null (queue-head queue)) (setf (queue-tail queue) nil)))) (defun queue-requeue (queue element) " DO: Insert the element at the beginning of the queue. PRE: (queue-p queue) l=(queue-length queue) POST: (eq (queue-first-element queue) element) (queue-p queue), l+1=(queue-length queue) RETURN: queue " (check-type queue queue) (push element (queue-head queue)) (when (null (queue-tail queue)) (setf (queue-tail queue) (queue-head queue))) queue) (defun queue-test () " DO: Test the queue data type. Insert test log at the point. " (let (q) (flet ((check (q) (queue-invariant q) (if (not (queue-p q)) (format t " NOT A QUEUE !~%~S~%" q) (progn (format t " Length=~2D~%" (queue-length q)) (when (< 0 (queue-length q)) (format t " Head=~S~% Tail=~S~%" (queue-first-element q) (queue-last-element q)) "") (format t " Queue=~S~%" q) )))) (format t "Creating a queue~%") (setq q (make-queue)) (check q) (format t "Dequeuing empty queue~%") (format t "~S~%" (queue-dequeue q)) (check q) (format t "Enqueuing...~%") (queue-enqueue q '(:first)) (check q) (format t "Enqueuing...~%") (queue-enqueue q '(:second)) (check q) (format t "Enqueuing...~%") (queue-enqueue q '(:third)) (check q) (format t "Enqueuing...~%") (queue-enqueue q '(:fourth)) (check q) (format t "Requeuing...~%") (queue-requeue q '(:zeroeth)) (check q) (while (< 0 (queue-length q)) (format t "Dequeuing queue~%") (format t "~S~%" (queue-dequeue q)) (check q)) (format t "Requeuing empty queue...~%") (queue-requeue q '(:first)) (check q) (format t "Requeuing...~%") (queue-requeue q '(:second)) (check q) (format t "Enqueuing...~%") (queue-enqueue q '(:last)) (check q) (while (< 0 (queue-length q)) (format t "Dequeuing queue~%") (format t "~S~%" (queue-dequeue q)) (check q))))) ;;;; THE END ;;;;
9,942
Common Lisp
.lisp
271
31.269373
85
0.567492
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
bf2b4cc374cacd733291087d1062b1b05ee60ce0db4d1e090427de0341334f90
5,102
[ -1 ]
5,103
xoroshiro128.lisp
informatimago_lisp/common-lisp/cesarum/xoroshiro128.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: xoroshiro128.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Implements Xoroshiro128+ PRNG ;;;; https://en.wikipedia.org/wiki/Xoroshiro128%2B ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2018-06-02 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2018 - 2018 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.XOROSHIRO128" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY") (:shadow "RANDOM-STATE" "RANDOM-STATE-P" "MAKE-RANDOM-STATE" "*RANDOM-STATE*" "RANDOM") (:export "RANDOM-STATE" "RANDOM-STATE-P" "MAKE-RANDOM-STATE" "*RANDOM-STATE*" "RANDOM") (:documentation " Implements the Xoroshiro128+ Pseudo Random Number Generator. (Not cryptographically secure). AGPL3 Copyright Pascal J. Bourguignon 2018 - 2018 ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.XOROSHIRO128") (deftype uint64 () '(unsigned-byte 64)) (defconstant +max-uint64+ #xFFFFFFFFFFFFFFFF) (defun uint64 (word) (the uint64 (logand +max-uint64+ word))) (defun rotl64 (word k) (declare (type uint64 word) (type fixnum k)) (the uint64 (let ((p (- 64 k))) (dpb (ldb (byte k 0) word) (byte k p) (ldb (byte p k) word))))) (defstruct (random-state (:constructor %make-random-state) (:conc-name %rs-)) s0 s1) (defvar *random-state*) (defun jump () "This is the jump function for the generator. It is equivalent to 2^64 calls to next(); it can be used to generate 2^64 non-overlapping subsequences for parallel computations." (let ((j #*00111111100000000100110011010010111110111010011000010000111010001010010100101010101011110001101100101001010000000000100111111011) (s0 0) (s1 0)) (loop :for b :below 128 :do (when (aref j b) (setf s0 (logxor s0 (%rs-s0 *random-state*)) s1 (logxor s1 (%rs-s1 *random-state*)))) (next)) (setf (%rs-s0 *random-state*) s0 (%rs-s1 *random-state*) s1) *random-state*)) (defun next () (let* ((s0 (%rs-s0 *random-state*)) (s1 (%rs-s1 *random-state*)) (result (uint64 (+ s0 s1)))) (setf s1 (logxor s1 s0) (%rs-s0 *random-state*) (uint64 (logxor (rotl64 s0 24) (logxor s1 (ash s1 16)))) (%rs-s1 *random-state*) (the uint64 (rotl64 s1 37))) result)) (defun make-random-state (&optional (state nil)) "As an extension, the state can also be a (unsigned-byte 128) used to initialize the random-state. The first random-state is initialized with get-universal-time and get-internal-real-time, the next time (make-random-state t) is called, the random state obtained with JUMP is returned. " (check-type state (or (member nil t) random-state (unsigned-byte 128))) (case state ((nil) (make-random-state *random-state*)) ((t) (if (boundp '*random-state*) (let ((*random-state* (copy-random-state *random-state*))) (jump)) (%make-random-state :s0 (uint64 (get-universal-time)) :s1 (uint64 (get-internal-real-time))))) (otherwise (if (integerp state) (%make-random-state :s0 (ldb (byte 64 64) state) :s1 (ldb (byte 64 0) state)) (%make-random-state :s0 (%rs-s0 state) :s1 (%rs-s1 state)))))) (defparameter *random-state* (make-random-state t)) (defun random (limit &optional (*random-state* *random-state*)) (etypecase limit ((integer 1) (loop :with drop := -4 :with max := (ash +max-uint64+ drop) :with m := (* limit (truncate max limit)) :for r := (if (<= limit max) (ash (next) drop) (loop :named bignum :for p :below (ceiling (log limit (1+ max))) :for r := (ash (next) drop) :then (dpb (ash (next) drop) (byte (+ 64 drop) (* (+ 64 drop) p)) r) :finally (return r))) :while (and (plusp m) (< m r)) :finally (return (mod r limit)))) ((float 0.0) (assert (plusp limit)) ; exclude 0. (let ((m (expt 2 (float-digits limit)))) (* limit (/ (float (random m) limit) (float m limit))))))) (defmacro with-specific-random-state (&body body) `(let ((*random-state* (make-random-state 321047098306122495840621590880868556385))) ,@body)) (defun test () (assert (equalp (with-specific-random-state (list (loop repeat 10 collect (random 100)) (loop repeat 10 collect (random 100.0s0)) (loop repeat 10 collect (random 100.0d0)))) '((93 63 20 52 61 21 92 28 20 90) (41.85024 2.6022136 5.2173853 95.012344 44.178146 92.49861 97.987236 78.110275 53.780884 30.602669) (61.45277314022255D0 26.579989800929106D0 28.86112251909987D0 91.21929348679451D0 76.0525998133693D0 26.43927281798557D0 0.22559720367546499D0 94.67635880985642D0 75.968619819787D0 62.1822518499491D0)))) :success) #-clisp(test) ;;;; THE END ;;;;
6,288
Common Lisp
.lisp
151
35.205298
209
0.597611
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
c7310272b45f10189a13b23e76d42f577edb42139656adeca861afd883295479
5,103
[ -1 ]
5,104
sequence.lisp
informatimago_lisp/common-lisp/cesarum/sequence.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: sequence.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; This module exports sequence functions. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2021-05-16 <PJB> Made mapconcat work on sequences of sequences. ;;;; 2021-05-15 <PJB> Added test/split-sequence-if ;;;; 2012-06-24 <PJB> Added REPLACE-SUBSEQ. ;;;; 2012-02-19 <PJB> Extracted from list.lisp and some other code. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2012 - 2021 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SEQUENCE" (:use "COMMON-LISP") (:export "HASHED-SET-REMOVE-DUPLICATES" "HASHED-REMOVE-DUPLICATES" "HASHED-DELETE-DUPLICATES" "DUPLICATES" "REPLACE-SUBSEQ" "DELETEF" "GROUP-BY" "PARSE-SEQUENCE-TYPE" "CONCATENATE-SEQUENCES" "PREFIXP" "SUFFIXP" "MAPCONCAT" "SPLIT-SEQUENCE-IF" "SPLIT-SEQUENCE-ON-INDICATOR") (:documentation " This package exports sequence processing functions. License: AGPL3 Copyright Pascal J. Bourguignon 2004 - 2021 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SEQUENCE") (defun item-delete (sequence item &rest keys &key from-end test test-not start end count key) (declare (ignore from-end test test-not start end count key)) (apply (function delete) item sequence keys)) (define-modify-macro deletef (item &rest keys) item-delete "Delete the item from the sequence in PLACE.") (defun duplicates (sequence &key (test 'eql) (key 'identity)) " RETURN: A sequence of items appearing in SEQUENCE in duplicate. There are no duplicates in the result, a single representant is included. " (remove-duplicates (if (or (member test '(eq eql equal equalp)) (member test (list (function eq) (function eql) (function equal) (function equalp)))) (let ((table (make-hash-table :test test))) (map nil (lambda (item) (incf (gethash (funcall key item) table 0))) sequence) (remove 1 sequence :key (lambda (item) (gethash (funcall key item) table 0)) :test '=)) (let ((table '())) (map nil (lambda (item) (let ((entry (assoc item table :test test :key key))) (if entry (incf (cdr entry)) (push (cons item 1) table)))) sequence) (remove 1 sequence :key (lambda (item) (or (cdr (assoc item table :test test :key key)) 0)) :test '=))) :test test :key key)) (defun hashed-set-remove-duplicates (sequence &key (test (function eql)) (key (function identity))) " DO: Remove duplicates from the SEQUENCE, using a hash-table. RETURN: A list of unique elements from the SEQUENCE. SEQUENCE: A sequence. TEST: A comparison function. Default: EQL. KEY: A key function. Default: IDENTITY. " (let ((table (make-hash-table :test test :size (length sequence))) (result '())) (map nil (lambda (item) (setf (gethash (funcall key item) table) item)) sequence) (maphash (lambda (key value) (declare (ignore key)) (push value result)) table) result)) (defun hashed-remove-duplicates (sequence &key (test (function eql)) test-not (start 0) (end (length sequence)) (key (function identity)) (from-end nil)) "Like REMOVE-DUPLICATES but implemented using a HASH-TABLE." (when test-not (warn ":TEST-NOT is deprecated.") (setf test (complement test-not))) (let ((table (make-hash-table :test test :size (- end start)))) (map nil (if from-end (lambda (item) (let ((item-key (funcall key item))) (multiple-value-bind (val pre) (gethash item-key table) (declare (ignore val)) (unless pre (setf (gethash item-key table) item))))) (lambda (item) (setf (gethash (funcall key item) table) item))) (if (or (/= start 0) (/= end (length sequence))) (subseq sequence start end) sequence)) (if (eq (type-of sequence) 'cons) (let ((result '())) (maphash (lambda (key value) (declare (ignore key)) (push value result)) table) (if (or (/= start 0) (/= end (length sequence))) (nconc (subseq sequence 0 start) result (subseq sequence end)) result)) (if (or (/= start 0) (/= end (length sequence))) (let ((result (make-sequence (type-of sequence) (+ start (hash-table-count table) (- (length sequence) end)))) (i start)) (replace result sequence :end2 start) (maphash (lambda (key value) (declare (ignore key)) (setf (aref result i) value) (incf i)) table) (replace result sequence :start2 end :start1 i) result) (let ((result (make-sequence (type-of sequence) (hash-table-count table))) (i 0)) (maphash (lambda (key value) (declare (ignore key)) (setf (aref result i) value) (incf i)) table) result))))) (defun hashed-delete-duplicates (sequence &key (test (function eql)) test-not (start 0) (end (length sequence)) (key (function identity)) (from-end nil)) "Like DELETE-DUPLICATES but implemented using a HASH-TABLE." (hashed-remove-duplicates sequence :test test :test-not test-not :start start :end end :key key :from-end from-end)) (defgeneric replace-subseq (insert sequence start &optional end) ;; Note: we could add a filler parameter and not adjust the size ;; when reduced, but this would make a different behavior than ;; when increasing the size. Would still be nice for some ;; applications. Perhaps also a truncatep parameter? ;; BUG: we should use the fill-pointer before trying to adjust. (:documentation " DO: Destructively (if possible) replace the (subseq sequence start end) with the elements from INSERT. If START and END don't specify a strict subseq of SEQUENCE then an error is signaled. INSERT: A sequence. SEQUENCE: A sequence. If it is a list or an adjustable vector, or if the subseq is of same length as INSERT then it will be destructively modified and returned. Otherwise a fresh adjustable vector will be returned. START: Bounding index designator of SEQUENCE. END: Bounding index designator of SEQUENCE. The default for end is NIL, which means (LENGTH SEQUENCE). RETURN: Either the modified SEQUENCE, or a fresh sequence of the same type with the specified subseq replaced by elements from INSERT. ") (:method (insert (sequence null) start &optional end) (let ((end (or end 0))) (assert (<= 0 start end 0)) (map 'list (function identity) insert))) (:method (insert (sequence list) start &optional end) (let* ((length (length sequence)) (end (or end length)) (excise (- end start)) (incise (length insert))) (assert (<= 0 start end length)) (cond ((= incise excise) (replace sequence insert :start1 start)) ((< incise excise) ;; reducing the length of sequence (let* ((guarded (cons nil sequence)) (previous (nthcdr start guarded))) (map nil (lambda (item) (setf previous (cdr previous) (car previous) item)) insert) (loop :repeat (- excise incise) :do (pop (cdr previous))) (cdr guarded))) (t ;; increasing the length of sequence (let* ((guarded (cons nil sequence)) (previous (nthcdr start guarded))) (loop :repeat (- incise excise) :do (push nil (cdr previous))) (replace (cdr previous) insert) (cdr guarded)))))) (:method (insert (sequence vector) start &optional end) (let* ((length (length sequence)) (end (or end length)) (excise (- end start)) (incise (length insert))) (assert (<= 0 start end length)) (cond ((= incise excise) (replace sequence insert :start1 start)) ((not (adjustable-array-p sequence)) (let* ((new-length (- (+ length incise) excise)) (new-sequence (make-array new-length :element-type (array-element-type sequence) :adjustable t :fill-pointer new-length))) (replace new-sequence sequence :end2 start) (replace new-sequence insert :start1 start) (replace new-sequence sequence :start1 (+ start incise) :start2 end))) ((< incise excise) ;; reducing the length of sequence (replace sequence insert :start1 start) (replace sequence sequence :start1 (+ start incise) :start2 end) (if (array-has-fill-pointer-p sequence) (decf (fill-pointer sequence) excise) ;; adjust-array cannot add a fill-pointer to an array, ;; even adjustable, that doesn't have one already. (adjust-array sequence (- (+ length incise) excise))) sequence) (t ;; increasing the length of sequence (cond ((< (array-dimension sequence 0) (- (+ length incise) excise)) (adjust-array sequence (- (+ length incise) excise) :fill-pointer (not (not (array-has-fill-pointer-p sequence))))) ((array-has-fill-pointer-p sequence) (incf (fill-pointer sequence) (- incise excise)))) (replace sequence sequence :start1 (+ end (- incise excise)) :start2 end) (replace sequence insert :start1 start)))))) (defgeneric group-by (sequence n) (:documentation "Returns a list of subsequences of SEQUENCE of length N, whose concatenation is equal to SEQUENCE.") (:method ((sequence vector) n) (check-type n (integer 1)) (loop :with length := (length sequence) :for i :from 0 :by n :while (< i length) :collect (subseq sequence i (min length (+ i n))))) (:method ((sequence list) n) (check-type n (integer 1)) (loop :for sub := sequence :then rest :for rest := (nthcdr #+sbcl #| is idiotic! |# (min (length sub) n) #-sbcl n sub) :while sub :collect (ldiff sub rest)))) (defun parse-sequence-type (type) "Parses the type which is expected to be a sequence subtype RETURN: the base type (list or vector), the element-type and the length (or nil). " (cond ((eq type 'list) (values 'list t nil)) ((eq type 'vector) (values 'vector t nil)) ((atom type) (error "Unrecognized sequence type ~S" type)) ((eq (first type) 'vector) ;; vector [{element-type | *} [{size | *}] (destructuring-bind (vector &optional element-type size) type (declare (ignore vector)) (values 'vector (if (member element-type '(nil *)) t element-type) (if (eq size '*) nil size)))) ((eq (first type) 'array) ;; array [{element-type | *} [dimension-spec]] ;; dimension-spec::= rank | * | ({dimension | *}*) (destructuring-bind (array &optional element-type dimension-spec) type (declare (ignore array)) (when (member dimension-spec '(nil * (*)) :test (function equal)) (error "Not a sequence subtype: ~S" type)) (values 'array (if (member element-type '(nil *)) t element-type) (cond ((eql 1 dimension-spec) nil) ((and (listp dimension-spec) (= 1 (length dimension-spec)) (integerp (first dimension-spec))) (first dimension-spec)) (t (error "Not a sequence subtype: ~S" type)))))) (t (error "Unrecognized sequence type ~S" type)))) (defun concatenate-sequences (result-type sequence-of-sequences &key (adjustable nil) (fill-pointer nil)) " RESULT-TYPE: Indicates the type of resulting sequence. If LIST, then ADJUSTABLE and FILL-POINTER are ignored. SEQUENCE-OF-SEQUENCES: EACH element may be either a string-designator, or a list containing a string-designator, and a start and end position denoting a substring. ADJUSTABLE: Whether the result must be adjustable. FILL-POINTER: The result fill pointer. RETURN: A vector containing all the elements of the vectors in sequence-of-vectors, in order. " (cond ((eq result-type 'list) (let* ((result (cons nil nil)) (tail result)) (map nil (lambda (seq) (map nil (lambda (item) (setf (cdr tail) (cons item nil) tail (cdr tail))) seq)) sequence-of-sequences) (cdr result))) (t (multiple-value-bind (base-type element-type size) (parse-sequence-type result-type) (declare (ignore base-type)) (let* ((lengths (map 'list (function length) sequence-of-sequences)) (total-size (reduce (function +) lengths)) (result (make-array (if (and size (< total-size size)) size total-size) :element-type element-type :adjustable adjustable :fill-pointer (if fill-pointer t nil))) (start 0)) (map nil (lambda (seq length) (replace result seq :start1 start) (incf start length)) sequence-of-sequences lengths) (when (integerp fill-pointer) (setf (fill-pointer result) fill-pointer)) result))))) (defgeneric prefixp (prefix sequence &key start end test) (:documentation " PREFIX: A sequence designator. STRING: A sequence designator. START: The start of the subsequence of SEQUENCE to consider. Default: 0. END: The end of the subsequence of SEQUENCE to consider. Default: NIL. TEST: A function to compare the elements of the SEQUENCE. RETURN: Whether PREFIX is a prefix of the (subseq SEQUENCE START END). ")) (defgeneric suffixp (suffix string &key start end test) (:documentation " SUFFIX: A sequence designator. STRING: A sequence designator. START: The start of the subsequence of SEQUENCE to consider. Default: 0. END: The end of the subsequence of SEQUENCE to consider. Default: NIL. TEST: A function to compare the elements of the SEQUENCE. RETURN: Whether SUFFIX is a suffix of the (subseq SEQUENCE START END). ")) (defmethod prefixp ((prefix sequence) (sequence sequence) &key (start 0) (end nil) (test (function eql))) (let ((mis (mismatch prefix sequence :start2 start :end2 end :test test))) (or (null mis) (<= (length prefix) mis)))) (defmethod suffixp ((suffix sequence) (sequence sequence) &key (start 0) (end nil) (test (function eql))) (zerop (or (mismatch suffix sequence :start2 start :end2 end :test test :from-end t) 0))) ;; We need to define methods for nil, because cesarum.string defines ;; methods for string-designators, so (null string) would be handled ;; differently. (defmethod prefixp ((prefix null) (sequence sequence) &key (start 0) (end nil) (test (function eql))) (declare (ignore start end test)) t) (defmethod suffixp ((suffix null) (sequence sequence) &key (start 0) (end nil) (test (function eql))) (declare (ignore start end test)) t) (defun type-union (a b) (cond ((subtypep a b) b) ((subtypep b a) a) (t `(or ,a ,b)))) (defun type-of-elements (sos) (reduce (lambda (type seq) (type-union ;; Note: we cannot use array-element-type because #(#\f #\o #\o) is a vector of T. (reduce (lambda (type element) (type-union (type-of element) type)) seq :initial-value 'nil) type)) sos :initial-value 'nil)) (defun mapconcat (function sequences separator) "Concatenate the sequences in SEQUENCES, mapped by FUNCTION, separated with the elements from the SEPARATOR sequence, into a vector. The element-type of the resulting vector is the union of all the element types." (if (or (consp sequences) (plusp (length sequences))) (let* ((items (map 'vector function sequences)) (element-type (type-union (type-of-elements items) (type-of-elements (list separator)))) (ssepa separator) (size (+ (reduce (function +) items :key (function length)) (* (length ssepa) (1- (length items))))) (result (make-array size :element-type element-type)) (start 0)) (replace result (aref items 0) :start1 start) (incf start (length (aref items 0))) (loop :for i :from 1 :below (length items) :for item := (aref items i) :do (replace result ssepa :start1 start) (incf start (length ssepa)) (replace result item :start1 start) (incf start (length item))) result) (make-array 0 :element-type (type-of-elements (list separator))))) (defun remove-empty-subseqs (subsequences remove-empty-subseqs) (if remove-empty-subseqs (delete-if (lambda (seq) (typecase seq (vector (zerop (length seq))) (null t) (t nil))) subsequences) subsequences)) (defun split-sequence-if (predicate sequence &key remove-empty-subseqs) " PREDICATE: A predicate on elements of the SEQUENCE sequence. When returning true, the sequence is split before and after the element, which are removed from the resulting subsequences. SEQUENCE: A sequence. REMOVE-EMPTY-SUBSEQS: A boolean. If true, empty subsequences are removed from the result. RETURN: A list of subsequences of SEQUENCE, split upon any element for which the PREDICATE is true. EXAMPLES: (split-sequence-if (function zerop) '(1 2 0 3 4 5 0 6 7 8 0 9)) --> ((1 2) (3 4 5) (6 7 8) (9)) (split-sequence-if (function zerop) #(1 2 0 3 4 5 0 6 7 8 0 9)) --> (#(1 2) #(3 4 5) #(6 7 8) #(9)) (split-sequence-if (lambda (x) (find x #(#\\space #\\0))) \"1 2 0 3 4 5 0 6 7 8\" ) --> (\"1\" \"2\" \"\" \"\" \"3\" \"4\" \"5\" \"\" \"\" \"6\" \"7\" \"8\") " (let ((chunks '())) (etypecase sequence (vector (loop :with position := 0 :with nextpos := 0 :with length := (length sequence) :while (< position length) :do (loop :while (and (< nextpos length) (not (funcall predicate (aref sequence nextpos)))) :do (incf nextpos)) (push (subseq sequence position nextpos) chunks) (setf position (1+ nextpos) nextpos position) (when (= position length) (push (subseq sequence 0 0) chunks)))) (cons (loop :with start := sequence :while start :do (let ((end (loop :with current := start :while (and current (not (funcall predicate (car current)))) :do (pop current) :finally (return current)))) (push (ldiff start end) chunks) (setf start (cdr end))))) (null)) (remove-empty-subseqs (nreverse chunks) remove-empty-subseqs))) (defun split-sequence-on-indicator (sequence indicator) " RETURN: a list of subsequence of SEQUENCE, the SEQUENCE is splited between consecutive items A and B for which (funcall INDICATOR A B) returns true. " (declare (type (function (t t) t) indicator)) (let ((chunks '())) (etypecase sequence (vector (loop :with start := 0 :with length := (length sequence) :for i :from 1 :below length :for a := (aref sequence 0) :then b :for b := (aref sequence i) :if (funcall indicator a b) :do (push (subseq sequence start i) chunks) (setf start i) :finally (when (< start length) (push (subseq sequence start length) chunks)))) (cons (loop :with sublist := sequence :with current := sequence :with next := (cdr current) :while next :if (funcall indicator (car current) (car next)) :do ;; split (setf (cdr current) nil) (push sublist chunks) (setq current next) (setq next (cdr current)) (setq sublist current) :else :do ;; keep (setq current next) (setq next (cdr current)) :finally (push sublist chunks))) (null)) ;; There cannot be empty subseqs, since they contain at list the indicator items. (nreverse chunks))) ;;;; THE END ;;;;
24,633
Common Lisp
.lisp
518
36.285714
134
0.562258
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
5ea5f1ad218b7e999458da1cd722818ce2ff43802ec430931d3bd1f9c12c15ad
5,104
[ -1 ]
5,105
priority-queue.lisp
informatimago_lisp/common-lisp/cesarum/priority-queue.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: priority-queue.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Priority queues are lists ordered on a key of each element. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2011-05-29 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2011 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.PRIORITY-QUEUE" (:use "COMMON-LISP") (:export "PQ" "MAKE-PQ" "PQ-P" "COPY-PQ" "PQ-LESSP" "PQ-EMPTYP" "PQ-LENGTH" "PQ-ELEMENTS" "PQ-ELEMENTS" "PQ-FIRST" "PQ-POP" "PQ-POP*" "PQ-INSERT" "PQ-INSERT*" "PQ-REMOVE" "PQ-KEY")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.PRIORITY-QUEUE") (defstruct pq "Defines a priority queue data structure. We keep the %queue sorted in a stubbed list. The pq structure may be initialized with a LESSP function (default is <) and with a KEY function (default is IDENTITY)." (%queue (list 'head)) (lessp (function <)) (key (function identity))) (defun pq-emptyp (pq) "Whether the priority queue is empty. [O(1)]" (null (rest (pq-%queue pq)))) (defun pq-length (pq) "The number of elements in the priority queue. [O(length(pq))]" (length (rest (pq-%queue pq)))) (defun pq-elements (pq) "Returns a list containing the sorted elements in the priority queue. [O(length(pq))]" (mapcar (function car) (rest (pq-%queue pq)))) (defun (setf pq-elements) (new-elements pq) "Replaces all the elements of PQ by the NEW-ELEMENTS (need not be sorted). Returns NEW-ELEMENTS." (let ((key (pq-key pq))) (setf (pq-%queue pq) (cons 'head (sort (map 'list (lambda (x) (cons x (funcall key x))) new-elements) (pq-lessp pq) :key (function cdr))))) new-elements) (defun pq-first (pq) "Returns the first element of the priority queue." (let ((%queue (pq-%queue pq))) (if (rest %queue) (car (second %queue)) (error "PQ-FIRST: The priority queue is empty.")))) (defun pq-pop (pq) "Removes and returns the first element of the priority queue." (let ((%queue (pq-%queue pq))) (if (rest %queue) (car (pop (rest %queue))) (error "PQ-POP: The priority queue is empty.")))) (defun pq-pop* (pq) "Removes and returns the first element of the priority queue." (let ((%queue (pq-%queue pq))) (if (rest %queue) (prog1 (rest %queue) (setf (rest %queue) (rest (rest %queue)))) (error "PQ-POP: The priority queue is empty.")))) (defun pq-insert (pq element) "Inserts the element in order in the priority queue [O(length(pq))]. Returns the PQ." (let ((lessp (pq-lessp pq)) (key (pq-key pq))) (loop :with ekey = (funcall key element) :for current = (pq-%queue pq) :then (rest current) :while (and (rest current) (funcall lessp (cdr (second current)) ekey)) :finally (setf (rest current) (acons element ekey (rest current)))) pq)) (defun pq-insert* (pq element) "Inserts the ((element . key)) in order in the priority queue [O(length(pq))]. Returns the PQ." (let ((lessp (pq-lessp pq)) (key (pq-key pq))) (loop :with ekey = (funcall key (caar element)) :for current = (pq-%queue pq) :then (rest current) :while (and (rest current) (funcall lessp (cdr (second current)) ekey)) :finally (setf (cdar element) ekey (cdr element) (rest current) (rest current) element)) pq)) (defun pq-remove (pq element) "Removes the first occurence of the element from the priority queue [O(length(pq))] O(pq-remove pq (pq-first pq)) = O(1) Returns the ELEMENT." (loop :for current = (pq-%queue pq) :then (rest current) :while (and (rest current) (not (eql element (car (second current))))) :finally (when (rest current) (setf (rest current) (rest (rest current))))) element) ;;;; THE END ;;;;
5,139
Common Lisp
.lisp
121
37.867769
99
0.61291
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
388e8f9d81a75654d4c4d6e12350e35d30192b76752b1986c87f7076a328f5eb
5,105
[ -1 ]
5,106
array.lisp
informatimago_lisp/common-lisp/cesarum/array.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: array.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; See defpackage documentation string. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2012-06-09 <PJB> Added ARRAY-EQUAL-P. ;;;; 2011-08-03 <PJB> Added POSITIONS and VECTOR-DELETE. ;;;; 2006-10-20 <PJB> Added nudge-displaced-vector. ;;;; Moved in displaced-vector from ;;;; com.informatimago.common-lisp.cesarum.string ;;;; 2005-05-02 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2005 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.ARRAY" (:use "COMMON-LISP") #+mocl (:shadowing-import-from "COM.INFORMATIMAGO.MOCL.KLUDGES.MISSING" "*TRACE-OUTPUT*" "*LOAD-VERBOSE*" "*LOAD-PRINT*" "ARRAY-DISPLACEMENT" "CHANGE-CLASS" "COMPILE" "COMPLEX" "ENSURE-DIRECTORIES-EXIST" "FILE-WRITE-DATE" "INVOKE-DEBUGGER" "*DEBUGGER-HOOK*" "LOAD" "LOGICAL-PATHNAME-TRANSLATIONS" "MACHINE-INSTANCE" "MACHINE-VERSION" "NSET-DIFFERENCE" "SUBSTITUTE-IF" "TRANSLATE-LOGICAL-PATHNAME" "PRINT-NOT-READABLE" "PRINT-NOT-READABLE-OBJECT") (:export "POSITIONS" ; should go to a sequence package... "POSITIONS-OF-SUBSEQUENCE" "VECTOR-EMPTYP" "VECTOR-FIRST" "VECTOR-LAST" "VECTOR-REST" "VECTOR-BUTLAST" "VECTOR-DELETE" "NUDGE-DISPLACED-VECTOR" "DISPLACED-VECTOR" "ARRAY-TO-LIST" "COPY-ARRAY" "ARRAY-EQUAL-P") (:documentation " This package exports a few array utility functions. License: AGPL3 Copyright Pascal J. Bourguignon 2005 - 2018 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.ARRAY") (defun positions (item vector &key (from-end nil) (test 'eql) (test-not nil) (start 0) (end nil) (count nil) (key 'identity)) " RETURN: A list of indices of the occurences of ITEM in the VECTOR. The occurences are defined by the ITEM, TEST, TEST-NOT, KEY, START, END, FROM-END and COUNT parameters as in DELETE. EXAMPLE: (positions 'a #(a door a window a big hole and a bucket) :start 1) ==> (2 4 8) " (let ((args (list :key key (if test-not :test-not :test) (if test-not test-not test)))) (if from-end (loop :with result = '() :for cur-end = end :then p :for p = (apply (function position) item vector :from-end t :start start :end cur-end args) :while (and p (or (null count) (<= 0 (decf count)))) :do (push p result) :finally (return result)) (loop :for cur-start = start :then (1+ p) :for p = (apply (function position) item vector :start cur-start :end end args) :while (and p (or (null count) (<= 0 (decf count)))) :collect p)))) (defun positions-of-subsequence (subsequence vector &key (from-end nil) (test 'eql) (test-not nil) (start1 0) (end1 nil) (start2 0) (end2 nil) (count nil) (key 'identity)) " RETURN: A list of cons cells containing the start and end of the occurences of (subseq SUBSEQUENCE START1 END1) in the VECTOR between START2 and END2. The occurences are defined by the SUBSEQUENCE, START1, START2, TEST, TEST-NOT, KEY, START2, END2, as in SEARCH, and the FROM-END and COUNT parameters as in DELETE. " (let* ((end1 (or end1 (length subsequence))) (len1 (- end1 start1)) (args (list :key key (if test-not :test-not :test) (if test-not test-not test)))) (if (zerop len1) (if count (if from-end (loop :repeat count :with result := '() :for i :from end2 :downto start2 :do (push (cons i i) result) :finally (return result)) (loop :repeat count :for i :from start2 :to end2 :collect (cons i i))) (loop :for i :from start2 :to end2 :collect (cons i i))) (if from-end (loop :with result = '() :for cur-end = end2 :then p :for p = (apply (function search) subsequence vector :start1 start1 :end1 end1 :start2 start2 :end2 cur-end :from-end t args) :while (and p (or (null count) (<= 0 (decf count)))) :do (push (cons p (+ p len1)) result) :finally (return result)) (loop :for cur-start = start2 :then (+ p len1) :for p = (apply (function search) subsequence vector :start1 start1 :end1 end1 :start2 cur-start :end2 end2 args) :while (and p (or (null count) (<= 0 (decf count)))) :collect (cons p (+ p len1))))))) (defun vector-emptyp (vector) " RETURN: Whether the vector is empty. " (zerop (length vector))) (defun vector-first (vector) " RETURN: The first element of the vector, or 0 values if empty. " (if (plusp (length vector)) (aref vector 0) (values))) (defun vector-last (vector) " RETURN: The last element of the vector, or 0 values if empty. " (if (plusp (length vector)) (aref vector (1- (length vector))) (values))) (defun vector-rest (vector) " RETURN: A displaced, adjustable array, with fill-pointer, covering all the elements of the VECTOR but the first. " (let* ((emptyp (vector-emptyp vector)) (size (if emptyp 0 (1- (length vector))))) (make-array size :element-type (array-element-type vector) :displaced-to vector :displaced-index-offset (if emptyp 0 1) :adjustable t :fill-pointer size))) (defun vector-butlast (vector) " RETURN: A displaced, adjustable array, with fill-pointer, covering all the elements of the VECTOR but the last. " (let* ((emptyp (vector-emptyp vector)) (size (if emptyp 0 (1- (length vector))))) (make-array size :element-type (array-element-type vector) :displaced-to vector :displaced-index-offset 0 :adjustable t :fill-pointer size))) (defun vector-delete (item vector &rest keys &key (from-end nil) (test 'eql) (test-not nil) (start 0) (end nil) (count nil) (key 'identity)) " DO: Delete occurences of ITEM from the VECTOR. The occurences are defined by the ITEM, TEST, TEST-NOT, KEY, START, END, FROM-END and COUNT parameters as in DELETE. The deletion is performed by moving the elements down, and updating the fill-pointer of the VECTOR. If the VECTOR doesn't have a fill-pointer, then DELETE is called instead. RETURN: VECTOR if it has a fill-pointer, or the result of DELETE otherwise. EXAMPLE: (let ((v (make-array 10 :initial-contents #(a door a window a big hole and a bucket) :fill-pointer t))) (list v (vector-delete 'a v :count 3) (fill-pointer v))) --> (#1=#(door window big hole and a bucket) #1# 7) " (declare (ignorable from-end test test-not start end count key)) (if (array-has-fill-pointer-p vector) (let ((positions (apply (function positions) item vector keys))) (if positions (loop :with dst-start = (pop positions) :for src-start = (1+ dst-start) :then (1+ src-end) :for src-end = (pop positions) :for src-end2 = (or src-end (length vector)) ;; :do (print (list :dst-start dst-start ;; :src-start src-start ;; :src-end src-end ;; :src-end2 src-end2)) :do (when (< src-start src-end2) ;; (print `(replace vector vector ;; :start1 ,dst-start ;; :start2 ,src-start :end2 ,src-end2)) (replace vector vector :start1 dst-start :start2 src-start :end2 src-end2) (incf dst-start (- src-end2 src-start)) (setf src-start (1+ src-end2))) :while src-end :finally (progn (setf (fill-pointer vector) dst-start) (return vector))) vector)) ;; No fill pointer, fall back to CL:DELETE: (apply (function delete) item vector keys))) (defun copy-array (array &key copy-fill-pointer copy-adjustable copy-displacement) " RETURN: A copy of the ARRAY. ARRAY: An array. COPY-FILL-POINTER: Indicate whether the copy must have the same FILL-POINTER as the ARRAY. COPY-ADJUSTABLE: Indicate whether the copy must be an adjustable array when the ARRAY is adjustable. COPY-DISPLACEMENT: Indicate whether the copy must be an array displaced to the same array as the ARRAY. " (when copy-displacement (multiple-value-bind (disto disoff) (array-displacement array) (when disto (return-from copy-array (make-array (array-dimensions array) :element-type (array-element-type array) :displaced-to disto :displaced-index-offset disoff :adjustable (when copy-adjustable (adjustable-array-p array)) :fill-pointer (when copy-fill-pointer (fill-pointer array))))))) (let ((copy (make-array (array-dimensions array) :adjustable (when copy-adjustable (adjustable-array-p array)) :fill-pointer (when copy-fill-pointer (fill-pointer array)) :element-type (array-element-type array)))) (dotimes (i (array-total-size copy)) (setf (row-major-aref copy i) (row-major-aref array i))) copy)) (defun array-to-list (array) " RETURN: A list (of list)* containing the elements of the array. EXAMPLE: (array-to-list #3A(((1 2 3) (4 5 6)) ((a b c) (d e f)))) --> (((1 2 3) (4 5 6)) ((a b c) (d e f))) " (if (= 1 (length (array-dimensions array))) (coerce array 'list) (loop :with subarray = (make-array (rest (array-dimensions array)) :adjustable t :element-type (array-element-type array) :displaced-to array :displaced-index-offset 0) :for i :from 0 :below (array-dimension array 0) :collect (progn (adjust-array subarray (array-dimensions subarray) :displaced-to array :displaced-index-offset (apply (function *) i (rest (array-dimensions array)))) (array-to-list subarray))))) (defun displaced-vector (array &optional start end fill-pointer) " DO: When array is a vector, same as SUBSEQ but with a displaced array. When the rank of array is different from 1, then creates a displaced vector onto ARRAY. In that case the optional arguments are ignored. RETURN: A new displaced vector. SEE ALSO: COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY:NSUBSEQ " (if (= 1 (array-rank array)) (progn (setf end (or end (length array))) (assert (<= 0 start (length array)) (start) "START should be an integer between 0 and ~D, not ~D" (length array) start) (assert (<= start end (length array)) (end) "END should be an integer between ~D and ~D, not ~D" start (length array) end) (make-array (list (- end start)) :element-type (array-element-type array) :adjustable t :fill-pointer fill-pointer :displaced-to array :displaced-index-offset start)) (make-array (array-total-size array) :element-type (array-element-type array) :displaced-to array))) (defun nudge-displaced-vector (displaced-vector &key (start nil startp) (start+ nil start+p) (start- nil start-p) (end nil endp) (end+ nil end+p) (end- nil end-p) (length nil lengthp) (length+ nil length+p) (length- nil length-p) (fill-pointer nil)) " DO: Changes the displacement of the DISPLACED-VECTOR. START: Indicates the new absolute displacement offset. START+: Indicates an increment of the displacement offset. START-: Indicates a decrement of the displacement offset. END: Indicates the new absolute end of the DISPLACED-VECTOR. END+: Indicates an increment of the DISPLACED-VECTOR end. END-: Indicates a decrement of the DISPLACED-VECTOR end. LENGTH: Indicates the new absolute length of the DISPLACED-VECTOR. LENGTH+: Indicates an increment of the length of the DISPLACED-VECTOR. LENGTH-: Indicates a decrement of the length of the DISPLACED-VECTOR. FILL-POINTER: Indicates the new fill pointer for the DISPLACED-VECTOR. NOTES: START, START+ and START- are mutually exclusive. END, END+, END-, LENGTH, LENGTH+ and LENGTH- are mutually exclusive. START and END are expressed as indices in the displaced-to array. RETURN: The adjusted array. EXAMPLE: (let* ((s #(a door a window a big hole and a bucket)) (v (displaced-vector s 0 3 t))) (show v) (show (nudge-displaced-vector v :end+ 1)) (show (nudge-displaced-vector v :fill-pointer 2)) (show (nudge-displaced-vector v :start+ 3 :end+ 3)) (show (nudge-displaced-vector v :start- 1 :end- 1)) (show (nudge-displaced-vector v :fill-pointer 1))) prints: v = #(a door a) (nudge-displaced-vector v :end+ 1) = #(a door a) (nudge-displaced-vector v :fill-pointer 2) = #(a door) (nudge-displaced-vector v :start+ 3 :end+ 3) = #(window a) (nudge-displaced-vector v :start- 1 :end- 1) = #(a window) (nudge-displaced-vector v :fill-pointer 1) = #(a) #(a) " (assert (<= (count-if (function identity) (list startp start+p start-p)) 1)) (assert (<= (count-if (function identity) (list endp end+p end-p lengthp length+p length-p)) 1)) (multiple-value-bind (vector old-start) (array-displacement displaced-vector) (let* ((old-length (array-dimension displaced-vector 0)) (old-end (+ old-start old-length)) (new-start (cond (startp start) (start+p (+ old-start start+)) (start-p (- old-start start-)) (t old-start))) (new-length (cond (endp (- end new-start)) (end+p (- (+ old-end end+) new-start)) (end-p (- (- old-end end-) new-start)) (lengthp length) (length+p (+ old-length length+)) (length-p (- old-length length-)) (t (- old-end new-start)))) (fill-pointer (if (eq 't fill-pointer) new-length fill-pointer))) (adjust-array displaced-vector (list new-length) :element-type (array-element-type vector) :fill-pointer (and (array-has-fill-pointer-p displaced-vector) fill-pointer) :displaced-to vector :displaced-index-offset new-start)))) (defun array-equal-p (a1 a2) "RETURN: A1 and A2 have the same dimensions (or the same length in case of vectors) and their elements in the same position are = if numbers, or equal otherwise." (if (and (vectorp a1) (vectorp a2)) (and (= (length a1) (length a2)) (flet ((same (i) (let ((x1 (aref a1 i)) (x2 (aref a2 i))) (if (and (numberp x1) (numberp x2)) (= x1 x2) (equal x1 x2))))) (declare (inline same)) (loop :for i :below (length a1) :always (same i)))) (and (equal (array-dimensions a1) (array-dimensions a2)) (flet ((same (i) (let ((x1 (row-major-aref a1 i)) (x2 (row-major-aref a2 i))) (if (and (numberp x1) (numberp x2)) (= x1 x2) (equal x1 x2))))) (loop :for i :below (array-total-size a1) :always (same i)))))) (defun array-to-lists (array) (labels ((atl (array dimensions) (if (null (rest dimensions)) (loop :with max := (pop dimensions) :for i :below max :collect (funcall array i)) (loop :with max := (pop dimensions) :for i :below max :collect (atl (lambda (&rest indices) (apply array i indices)) dimensions))))) (let ((dimensions (array-dimensions array))) (case (length dimensions) ((0) (aref array)) ((1) (coerce array 'list)) (otherwise (atl (lambda (&rest indices) (apply (function aref) array indices)) dimensions)))))) ;;;; THE END ;;;;
21,484
Common Lisp
.lisp
456
33.686404
171
0.517185
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
322db58650a4682d1d81e45c1e9d97e04edab92ad4d56544252bef3305f9c70a
5,106
[ -1 ]
5,107
string-test.lisp
informatimago_lisp/common-lisp/cesarum/string-test.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: string-test.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Tests string.lisp. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2015-02-25 <PJB> Extracted from string.lisp. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STRING.TEST" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SIMPLE-TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STRING")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STRING.TEST") (define-test test/string-designator () (assert-true (typep "toto" 'string-designator)) (assert-true (typep 'toto 'string-designator)) (assert-true (typep #\t 'string-designator)) (assert-true (not (typep 42 'string-designator))) (assert-true (not (typep #(#\a #\b) 'string-designator))) (assert-true (not (typep '(#\a #\b) 'string-designator))) (assert-true (typep "t" '(string-designator 1))) (assert-true (typep 't '(string-designator 1))) (assert-true (typep #\t '(string-designator 1))) (assert-true (typep "toto" '(string-designator 4))) (assert-true (typep 'toto '(string-designator 4))) (assert-true (not (typep "toto" '(string-designator 2)))) (assert-true (not (typep 'toto '(string-designator 2)))) (assert-true (not (typep #\t '(string-designator 2)))) (assert-true (not (typep 42 '(string-designator 1)))) (assert-true (not (typep #(#\a #\b) '(string-designator 2)))) (assert-true (not (typep '(#\a #\b) '(string-designator 2))))) (define-test test/character-designator () (assert-true (typep "t" 'character-designator)) (assert-true (typep 't 'character-designator)) (assert-true (typep #\t 'character-designator)) (assert-true (not (typep "toto" 'character-designator))) (assert-true (not (typep 'toto 'character-designator))) (assert-true (not (typep 42 'character-designator))) (assert-true (not (typep #(#\a) 'character-designator))) (assert-true (not (typep '(#\a) 'character-designator)))) (define-test test/concatenate-strings () (assert-true (equal "" (concatenate-strings '()))) (assert-true (equal "" (concatenate-strings '("")))) (assert-true (equal "" (concatenate-strings '("" "" "")))) (assert-true (equal "" (concatenate-strings '(("" 0 0) ("abc" 0 0) ("abc" 1 1) (#\a 0 0))))) (assert-true (equal "abc" (concatenate-strings '("abc")))) (assert-true (equal "abc" (concatenate-strings '("a" "b" "c")))) (assert-true (equal "abc" (concatenate-strings '((#\a #\b) "c")))) (assert-true (equal "abc" (concatenate-strings '(#\a #\b #\c)))) (assert-true (equal "abc" (concatenate-strings '(|a| |b| |c|)))) (assert-true (equal "abc" (concatenate-strings '(|a| "b" #\c)))) (assert-true (equal "abcdef" (concatenate-strings '("ab" "cd" "ef")))) (assert-true (equal "abcdef" (concatenate-strings '(("abcdef" 0 2) ("abcdef" 2 4) ("abcdef" 4 6))))) (assert-true (equal "abcdef" (concatenate-strings '(((#\a #\b #\c #\d #\e #\f) 0 2) ("abcdef" 2 4) ("abcdef" 4 6))))) (assert-true (equal "abcdef" (concatenate-strings '(#\a #\b #\c "def"))))) (define-test test/implode-explode () ;; implode-string (assert-true (string= "" (implode-string ""))) (assert-true (string= "" (implode-string #()))) (assert-true (string= "" (implode-string '()))) #-sbcl (assert-true (null (ignore-errors (implode-string 42)))) (assert-true (string= "ABC" (implode-string "ABC"))) (assert-true (string= "ABC" (implode-string #(#\A #\B #\C)))) (assert-true (string= "ABC" (implode-string '(#\A #\B #\C)))) (assert-true (null (ignore-errors (implode-string '(42))))) ;; explode-string (assert-true (eq (explode-string "") nil)) (assert-true (eq (explode-string "" 'list) nil)) (assert-true (string= (explode-string "" 'string) "")) (assert-true (equalp (explode-string "" 'vector) #())) (assert-true (equal (explode-string "ABC") '(#\A #\B #\C))) (assert-true (equal (explode-string "ABC" 'list) '(#\A #\B #\C))) (assert-true (and (every 'char= (explode-string "ABC" 'vector) #(#\A #\B #\C)) (= (length (explode-string "ABC" 'vector)) (length #(#\A #\B #\C))))) (assert-true (string= (explode-string "ABC" 'string) "ABC")) ;; implode a string (assert-true (eq (implode "" 'symbol "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STRING") 'com.informatimago.common-lisp.cesarum.string::||)) (assert-true (eq (implode "ABC" 'symbol "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STRING") 'com.informatimago.common-lisp.cesarum.string::abc)) (assert-true (eq (implode "ABC" 'symbol :keyword) ':ABC)) (assert-true (string= (implode "" 'string) "")) (assert-true (string= (implode "ABC" 'string) "ABC")) (assert-true (equal (implode "(1 2 3)" 'list) '(1 2 3))) (assert-true (equal (implode "NIL" 'list) '())) (assert-true (equalp (implode "#(1 2 3)" 'vector) #(1 2 3))) ;; implode a vector (assert-true (eq (implode #() 'symbol "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STRING") 'com.informatimago.common-lisp.cesarum.string::||)) (assert-true (eq (implode #(#\A #\B #\C) 'symbol "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STRING") 'com.informatimago.common-lisp.cesarum.string::abc)) (assert-true (eq (implode #(#\A #\B #\C) 'symbol :keyword) ':ABC)) (assert-true (string= (implode #() 'string) "")) (assert-true (string= (implode #(#\A #\B #\C) 'string) "ABC")) (assert-true (equal (implode #(#\( #\1 #\space #\2 #\space #\3 #\)) 'list) '(1 2 3))) (assert-true (equal (implode #(#\N #\I #\L) 'list) '())) (assert-true (equalp (implode #(#\# #\( #\1 #\space #\2 #\space #\3 #\)) 'vector) #(1 2 3))) ;; implode a list (assert-true (eq (implode '() 'symbol "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STRING") 'com.informatimago.common-lisp.cesarum.string::||)) (assert-true (eq (implode '(#\A #\B #\C) 'symbol "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STRING") 'com.informatimago.common-lisp.cesarum.string::abc)) (assert-true (eq (implode '(#\A #\B #\C) 'symbol :keyword) ':ABC)) (assert-true (string= (implode '() 'string) "")) (assert-true (string= (implode '(#\A #\B #\C) 'string) "ABC")) (assert-true (equal (implode '(#\( #\1 #\space #\2 #\space #\3 #\)) 'list) '(1 2 3))) (assert-true (equal (implode '(#\N #\I #\L) 'list) '())) (assert-true (equalp (implode '(#\# #\( #\1 #\space #\2 #\space #\3 #\)) 'vector) #(1 2 3))) ;; explode (assert-true (equal (explode 'hello) '(#\H #\E #\L #\L #\O))) (assert-true (equal (explode 'hello 'list) '(#\H #\E #\L #\L #\O))) (assert-true (equalp (explode 'hello 'vector) #(#\H #\E #\L #\L #\O))) (assert-true (equalp (explode 'hello 'string) "HELLO")) (assert-true (equal (explode "HELLO") '(#\H #\E #\L #\L #\O))) (assert-true (equal (explode "HELLO" 'list) '(#\H #\E #\L #\L #\O))) (assert-true (equalp (explode "HELLO" 'vector) #(#\H #\E #\L #\L #\O))) (assert-true (equalp (explode "HELLO" 'string) "HELLO")) (assert-true (equalp (explode #(#\H #\E #\L #\L #\O)) '(#\H #\E #\L #\L #\O))) (assert-true (equalp (explode #(#\H #\E #\L #\L #\O) 'list) '(#\H #\E #\L #\L #\O))) (assert-true (equalp (explode #(#\H #\E #\L #\L #\O) 'vector) #(#\H #\E #\L #\L #\O))) (assert-true (equalp (explode #(#\H #\E #\L #\L #\O) 'string) "HELLO"))) (defun as-symbol (string) (make-symbol string)) (define-test test/prefixp () (loop :for pf :in '(identity as-symbol) :do (loop :for sf :in '(identity as-symbol) :do (loop :for (p s) :in '(("" #\H) (#\H #\H) (#\H "H") ("H" #\H) (#\H "HELLO") ("" "") ("" "HELLO") ("HELLO" "HELLO") ("HELLO" "HELLO WORLD")) :do (assert-true (prefixp (funcall pf p) (funcall sf s)))) (loop :for (p s) :in '((#\H "") (#\H #\A) (#\A #\H) ("HELLO" #\H) ("HELLO" "") ("HELLO" "HELL") ("HELLO" "SAY HELLO WORLD") ("HELLO" "SAY HELLO")) :do (assert-false (prefixp (funcall pf p) (funcall sf s))))))) (define-test test/suffixp () (loop :for pf :in '(identity as-symbol ) :do (loop :for sf :in '(identity as-symbol) :do (loop :for (p s) :in '(("" #\H) (#\H #\H) (#\H "H") ("H" #\H) (#\O "HELLO") ("" "") ("" "HELLO") ("HELLO" "HELLO") ("WORLD" "HELLO WORLD")) :do (assert-true (suffixp (funcall pf p) (funcall sf s)))) (loop :for (p s) :in '((#\H "") (#\H #\A) (#\A #\H) ("HELLO" #\H) ("HELLO" "ELLO") ("HELLO" "SAY HELLO WORLD") ("HELLO" "SAY WORLD")) :do (assert-false (suffixp (funcall pf p) (funcall sf s))))))) (define-test test/split-string () (check equalp (split-string '(1 2 0 3 4 5 0 6 7 8 0 9) '(0)) '((1 2) (3 4 5) (6 7 8) (9))) (check equalp (split-string #(1 2 0 3 4 5 0 6 7 8 0 9) #(0)) '(#(1 2) #(3 4 5) #(6 7 8) #(9))) (check equalp (split-string "1 2 0 3 4 5 0 6 7 8" '(#\space #\0)) '("1" "2" "" "" "3" "4" "5" "" "" "6" "7" "8")) (check equalp (split-string "hello world" "*") '("hello world")) (check equalp (split-string "hello world*" "*") '("hello world" "")) (check equalp (split-string "hello world*" "*" :remove-empty) '("hello world")) (check equalp (split-string "hello world***" "*" :remove-empty) '("hello world")) (check equalp (split-string "hello world*x" "*") '("hello world" "x")) (check equalp (split-string "hello*world" "*") '("hello" "world")) (check equalp (split-string "hello*world*" "*") '("hello" "world" "")) (check equalp (split-string "hello*world*" "*" :remove-empty) '("hello" "world")) (check equalp (split-string "hello*world***" "*" :remove-empty) '("hello" "world")) (check equalp (split-string "hello*world*x" "*") '("hello" "world" "x"))) (define-test test/all () (test/string-designator) (test/character-designator) (test/concatenate-strings) (test/implode-explode) (test/prefixp) (test/suffixp) (test/split-string)) ;;;; THE END ;;;;
12,682
Common Lisp
.lisp
235
44.217021
119
0.515369
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
45c80ff3bd16618e913b1e8c77f6b7f9cac7c08b3db836231fa107773ab6655e
5,107
[ -1 ]
5,108
file-test.lisp
informatimago_lisp/common-lisp/cesarum/file-test.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: file-test.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Tests file.list. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2015-02-25 <PJB> Extracted from file.list. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.FILE.TEST" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SIMPLE-TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.FILE")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.FILE.TEST") (define-test test/accessors (path) (let ((data '(a b c 1 2 3 #(a 1)))) (setf (sexp-file-contents path) data) (assert-true (equalp data (sexp-file-contents path))) (push 0 (sexp-file-contents path)) (assert-true (equalp (cons 0 data) (sexp-file-contents path)))) (delete-file path) (let ((data " DO: Modifies the file at path FILE-NAME, removing the LINE-COUNT first lines. WARNING: There's no backup: if the COPY-OVER fails, the file will be left in an unspecified state. ")) (setf (text-file-contents path) data) (assert-true (string= data (text-file-contents path))) (setf (text-file-contents path :if-exists :append) "A new line") (assert-true (string= (concatenate 'string data "A new line") (text-file-contents path)))) (delete-file path) (let ((data '("" "DO: Modifies the file at path FILE-NAME, " " removing the LINE-COUNT first lines." "WARNING: There's no backup: if the COPY-OVER fails, the file will be left" " in an unspecified state." ""))) (setf (string-list-text-file-contents path) data) (assert-true (equal data (string-list-text-file-contents path))) (setf (string-list-text-file-contents path :if-exists :append) '("A new line" "And another one")) (assert-true (equal (append data '("A new line" "And another one")) (string-list-text-file-contents path)))) (delete-file path) (let ((data #(1 2 3 4 5 6 9 0 11 12 13))) (setf (binary-file-contents path) data) (assert-true (equalp data (binary-file-contents path))) (setf (binary-file-contents path :if-exists :append) data) (assert-true (equalp (concatenate 'vector data data) (binary-file-contents path)))) (delete-file path)) (define-test test/all () (test/accessors #P"/tmp/file-test.data")) ;;;; THE END ;;;;
3,669
Common Lisp
.lisp
80
41.65
96
0.615857
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
f5fdcc49a0f09a21fb717ad44a460d53eecae1ba3b4d72bbca342fcadb5d88c6
5,108
[ -1 ]
5,109
a-star-test.lisp
informatimago_lisp/common-lisp/cesarum/a-star-test.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: a-star-test.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Tests a-star.lisp. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2015-02-25 <PJB> Extracted from a-star.lisp ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.A-STAR.TEST" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SIMPLE-TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.A-STAR") (:export "TEST/ALL")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.A-STAR.TEST") (defun g1-successors (node) "Represents the graph http://gabrielgambetta.com/path1.html" (ecase node (a '(b f)) (b '(a c)) (c '(b)) (d '()) (e '(j)) (f '(a k)) (g '()) (h '()) (j '(e o)) (k '(f l)) (l '(k m q)) (m '(l n)) (n '(m o)) (o '(n j t)) (p '()) (q '(l v)) (r '()) (s '()) (t '(o y)) (u '()) (v '(q w)) (w '(v x)) (x '(w y)) (y '(x t)))) (defun g1-coordinates (node) (ecase node (a #c(0 0)) (b #c(1 0)) (c #c(2 0)) (d #c(3 0)) (e #c(4 0)) (f #c(0 1)) (g #c(1 1)) (h #c(2 1)) (i #c(3 1)) (j #c(4 1)) (k #c(0 2)) (l #c(1 2)) (m #c(2 2)) (n #c(3 2)) (o #c(4 2)) (p #c(0 3)) (q #c(1 3)) (r #c(2 3)) (s #c(3 3)) (t #c(4 3)) (u #c(0 4)) (v #c(1 4)) (w #c(2 4)) (x #c(3 4)) (y #c(4 4)))) (defun g1-distance (a b) (abs (- (g1-coordinates a) (g1-coordinates b)))) (defun test/g1 (&key (start 'a) (goal 't)) (multiple-value-call (function find-path) (function g1-successors) (let ((p (make-hash-table))) (values (lambda (node) (gethash node p)) (lambda (new-previous node) (setf (gethash node p) new-previous)))) (let ((c (make-hash-table))) (values (lambda (node) (gethash node c +infinity+)) (lambda (new-cost node) (setf (gethash node c) new-cost)))) (function g1-distance) (lambda (node) (eql node goal)) start goal)) (define-test test/g1-paths () (assert-true (equal (test/g1 :start 'a :goal 'x) '(a f k l q v w x))) (assert-true (equal (test/g1 :start 'a :goal 'y) '(a f k l m n o t y)))) (define-test test/all () (test/g1)) ;; (test)
3,505
Common Lisp
.lisp
117
25.948718
83
0.53138
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
c880b90ad9312bbe906a99981201cbd02bc89d92541c923f392d6cb80c93714f
5,109
[ -1 ]
5,110
float-binio.lisp
informatimago_lisp/common-lisp/cesarum/float-binio.lisp
;;;; -*- mode:lisp; coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: float-binio.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; This package encodes and decodes arrays of float into arrays ;;;; of signed-byte 32 in order to do binary I/O. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2003-06-05 <PJB> Created. ;;;;BUGS ;;;; Handling of SHORT-FLOAT and LONG-FLOAT is not complete. ;;;; Notably, for SHORT-FLOAT, (and for exponents), we may want to ;;;; encode into an array of (signed-byte 8). ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2003 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.FLOAT-BINIO" (:use "COMMON-LISP") (:documentation " This package encodes and decodes arrays of float into arrays of signed-byte 32 in order to do binary I/O. BUGS: Handling of SHORT-FLOAT and LONG-FLOAT is not complete. License: AGPL3 Copyright Pascal J. Bourguignon 2003 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ") (:export "BIOFA-DECODE" "BIOFA-ENCODE" "BIOFA-SETREF" "BIOFA-REF" "BIOFA-COUNT")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.FLOAT-BINIO") ;;; (defparameter seq (make-array '(1000) ;;; :element-type '(signed-byte 32) ;;; :initial-element 123456789));;seq ;;; (time ;;; (with-open-file (out "/tmp/file.dat" ;;; :direction :output ;;; :if-exists :supersede :if-does-not-exist :create ;;; :element-type '(signed-byte 32)) ;;; (dotimes (i 1000) ;;; (write-sequence seq out)))) ;;; (time ;;; (with-open-file (in "/tmp/file.dat" ;;; :direction :input ;;; :if-does-not-exist :create ;;; :element-type '(signed-byte 32)) ;;; (dotimes (i 1000) ;;; (read-sequence seq in)))) ;; integer-decode-float (eval-when (:compile-toplevel :load-toplevel :execute) (defconstant +header-size+ 2 "NUMBER OF HEADER ELEMENTS IN A BIOFA ARRAY")) (defun biofa-float-size (biofa-array) " PRIVATE RETURN: THE NUMBER OF (SIGNED-BYTE 32) NEEDED TO STORE THE MANTISSA OF THE FLOATS STORED IN BIOFA-ARRAY. " (declare (type (array (signed-byte 32)) biofa-array)) (aref biofa-array 0)) (defun biofa-set-float-size (biofa-array float-size) " PRIVATE POST: (= (BIOFA-FLOAT-SIZE BIOFA-ARRAY) FLOAT-SIZE) " (declare (type (array (signed-byte 32)) biofa-array)) (setf (aref biofa-array 0) float-size)) (defun biofa-radix (biofa-array) " PRIVATE RETURN: The radix used to decode/encode that BIOFA-ARRAY. " (declare (type (array (signed-byte 32)) biofa-array)) (aref biofa-array 1)) (defun biofa-set-radix (biofa-array radix) " PRIVATE RETURN: The radix used to decode/encode that BIOFA-ARRAY. " (declare (type (array (signed-byte 32)) biofa-array)) (setf (aref biofa-array 1) radix)) (defun float-size (fvalue) " PRIVATE RETURN: THE NUMBER OF (SIGNED-BYTE 32) NEEDED TO STORE THE MANTISSA OF FVALUE. " (values (truncate (+ 31 (float-precision fvalue)) 32))) (defun biofa-count (biofa-array) " RETURN: The number of floats encoded into the biofa-array. " (declare (type (array (signed-byte 32)) biofa-array)) (/ (- (length biofa-array) +header-size+) (1+ (biofa-float-size biofa-array)))) (defvar +float-types+ '((1 . single-float) (2 . double-float)) ;; SHORT-FLOAT SINGLE-FLOAT DOUBLE-FLOAT LONG-FLOAT "AN A-LIST MAPPING FLOAT-SIZE TO FLOAT TYPE.") ;;+FLOAT-TYPES+ (defmacro biofa-fetch (biofa-array radix float-size type base) " PRIVATE " `(let* ((exps (prog1 (aref ,biofa-array ,base) (incf ,base))) (nega (oddp exps)) (expo (truncate (- exps (if nega 1 0)) 2)) (mant (case ,float-size (1 (prog1 (aref ,biofa-array ,base) (incf ,base))) (2 (let ((l (prog1 (aref ,biofa-array ,base) (incf ,base))) (h (prog1 (aref ,biofa-array ,base) (incf ,base)))) (dpb h (byte 32 32) l) )) (otherwise (do ((i 0 (1+ i)) (b 0 (+ b 32)) (m) (r 0)) ((< i fs) r) (setq m (aref ,biofa-array ,base)) (incf ,base) (dpb m (byte 32 b) r))))) (fvalue (* (coerce mant ,type) (expt (coerce ,radix ,type) expo)))) (if nega (- fvalue) fvalue))) (defmacro biofa-stash (biofa-array float-size base fvalue) " PRIVATE " `(multiple-value-bind (mant expo sign) (integer-decode-float ,fvalue) (setq expo (+ (* 2 expo) (if (< sign 0) 1 0))) (setf (aref ,biofa-array ,base) expo) (incf ,base) (case ,float-size (1 (setf (aref ,biofa-array ,base) mant) (incf ,base)) (2 (setf (aref ,biofa-array ,base) (ldb (byte 32 0) mant)) (incf ,base) (setf (aref ,biofa-array ,base) (ldb (byte 32 32) mant)) (incf ,base)) (otherwise (do ((i 0 (1+ i)) (b 0 (+ b 32))) ((< i ,float-size)) (setf (aref ,biofa-array ,base) (ldb (byte 32 b) mant)) (incf ,base)))))) (defun biofa-ref (biofa-array index) " RETURN: The float at INDEX. " (declare (type (array (signed-byte 32)) biofa-array) (type integer index)) (assert (and (<= 0 index) (< index (biofa-count biofa-array)))) (let* ((radix (biofa-radix biofa-array)) (fs (biofa-float-size biofa-array)) (type (or (cdr (assoc fs +float-types+)) 'long-float)) (base (+ +header-size+ (* (1+ fs) index))) ) (biofa-fetch biofa-array radix fs type base))) (defun biofa-setref (biofa-array index fvalue) " POST: (= (biofa-ref biofa-array index) fvalue) " (declare (type (array (signed-byte 32)) biofa-array) (type integer index) (type float fvalue)) (assert (and (<= 0 index) (< index (biofa-count biofa-array)))) (let* ((fs (biofa-float-size biofa-array)) (base (+ +header-size+ (* (1+ fs) index)))) (biofa-stash biofa-array fs base fvalue))) (defun biofa-encode (float-array) " RETURN: An array of (SIGNED-BYTE 32) or of containing the data from FLOAT-ARRAY. " (declare (type (array float) float-array)) (let* ((fs (apply (function max) (map 'list (function float-size) float-array))) (size (+ +header-size+ (* (1+ fs) (length float-array)))) (biofa (make-array (list size) :element-type '(signed-byte 32))) (base +header-size+)) (dotimes (i (length float-array)) (let ((fvalue (aref float-array i))) (biofa-stash biofa fs base fvalue))) (biofa-set-radix biofa (float-radix (aref float-array 0))) (biofa-set-float-size biofa fs) biofa)) (defun biofa-decode (biofa-array) " RETURN: AN ARRAY OF FLOAT (DEPENDING ON BIOFA-FLOAT-SIZE AND +FLOAT-TYPE+) CONTAINING THE SAME VALUE AS ENCODED INTO BIOFA-ARRAY. " (declare (type (array (signed-byte 32)) biofa-array)) (let* ((radix (biofa-radix biofa-array)) (fs (biofa-float-size biofa-array)) (type (or (cdr (assoc fs +float-types+)) 'long-float)) (base +header-size+) (float-array (make-array (list (biofa-count biofa-array)) :element-type type))) (dotimes (i (length float-array)) (setf (aref float-array i) (biofa-fetch biofa-array radix fs type base))) float-array)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; TESTS (defparameter lstest '( 0.0 1.0 -1.0 2.0 -2.0 3.141592 -3.141592 1.0e1 -1.0e1 2.0e1 -2.0e1 3.141592e1 -3.141592e1 1.0e-1 -1.0e-1 2.0e-1 -2.0e-1 3.141592e-1 -3.141592e-1 1.0e20 -1.0e20 2.0e20 -2.0e20 3.141592e20 -3.141592e20 1.0e-20 -1.0e-20 2.0e-20 -2.0e-20 3.141592e-20 -3.141592e-20)) (defparameter fstest (make-array (list (length lstest)) :initial-contents lstest)) (defparameter ldtest '( 0.0d0 1.0d0 -1.0d0 2.0d0 -2.0d0 3.1415926535897932385d0 -3.1415926535897932385d0 1.0d1 -1.0d1 2.0d1 -2.0d1 3.1415926535897932385d1 -3.1415926535897932385d1 1.0d-1 -1.0d-1 2.0d-1 -2.0d-1 3.1415926535897932385d-1 -3.1415926535897932385d-1 1.0d20 -1.0d20 2.0d20 -2.0d20 3.1415926535897932385d20 -3.1415926535897932385d20 1.0d-20 -1.0d-20 2.0d-20 -2.0d-20 3.1415926535897932385d-20 -3.1415926535897932385d-20)) (defparameter fdtest (make-array (list (length ldtest)) :initial-contents ldtest)) (defvar estest) (defvar dstest) (defvar edtest) (defvar ddtest) (defun test () (setq estest (biofa-encode fstest)) (setq dstest (biofa-decode estest)) (format t "~&SINGLE: ~A~%" (equalp dstest fstest)) (setq edtest (biofa-encode fdtest)) (setq ddtest (biofa-decode edtest)) (format t "~&DOUBLE: ~A~%" (equalp ddtest fdtest)) (assert (and (equalp dstest fstest) (equalp ddtest fdtest)))) ;;; <http://www.mail-archive.com/[email protected]/msg00547.html>. ;;; Please excuse the rather lame temporary filename generation :) ;;; ;;; (defpackage #:faslstore ;;; (:export #:bindump #:binload) ;;; (:nicknames #:fs) ;;; (:use :cl)) ;;; ;;; (in-package #:faslstore) ;;; ;;; (defparameter *hook* nil) ;;; ;;; (defun gentempname nil ;;; "Generate a rather unlikely filename." ;;; (format nil "~Afaslize.lisp" (get-universal-time))) ;;; ;;; (defun bindump (data fname) ;;; (let ((tmp (gentempname))) ;;; (setq *hook* data) ;;; (with-open-file (str tmp ;;; :direction :output ;;; :if-exists :supersede) ;:error) ;;; (format str "(in-package #:faslstore)~%~ ;;; (let (c)~%~ ;;; (defun returner nil~%~ ;;; (cond ((not c) (setf c t) '#.*hook*)~%~ ;;; (t nil))))~%")) ;;; (compile-file tmp :output-file fname) ;;; (delete-file tmp))) ;;; ;;; (defun returner nil nil) ;;; ;;; (defun binload (fname) ;;; (load fname) ;;; (returner)) ;;; ;;; ;;;; float-binio.lisp -- -- ;;;;
11,975
Common Lisp
.lisp
301
35.196013
83
0.600793
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
d196c717ecaa735f0909cf34a7ed609c1d3c34d2b4e63a4c3c7392a884fa3a07
5,110
[ -1 ]
5,111
pmatch.lisp
informatimago_lisp/common-lisp/cesarum/pmatch.lisp
;;;; -*- coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: pmatch.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Sexp Pattern Matcher. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2012-02-03 <PJB> Added match-case*. ;;;; 2003-12-17 <PJB> Created. ;;;;BUGS ;;;; - pattern matcher and instantiation won't work with arrays/matrices, ;;;; structures... ;;;; - ?/ alternative is not implemented. ;;;; - ?* and ?+ may lead to infinite recursion, ;;;; eg: (match '(a (?* (?n n b))) '(a b b b)) ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2003 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.PMATCH" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY") (:export "MATCH-CASE" "MATCH-CASE*" "COLLECT-VARIABLES" ":" "?/" "?*" "?+" "??" "?N" "?X" "?C" "?V" "?AX" "?AC" "?AV" "MATCH-DICT-MAP" "MATCH-STATE-DICT" "MATCH-STATE-FAILED-P" "MATCH") (:import-from "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY" "WITH-GENSYMS") (:documentation " Sexp Pattern Matcher License: AGPL3 Copyright Pascal J. Bourguignon 2003 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.PMATCH") (defun make-match-state (&key dict) dict) (defun match-state-dict (ms) "RETURN: The dictionary of MATCH-STATE." ms) (defun match-state-fail (ms raison) "PRIVATE" (make-match-state :dict (list* :failed raison (match-state-dict ms)))) (defun match-state-failed-p (ms) " RETURN: Whether the match failed. " (eq :failed (car (match-state-dict ms))) ) (defun match-state-retry (ms) "PRIVATE" (if (match-state-failed-p ms) (make-match-state :dict (cdr (match-state-dict ms))) ms)) (defun match-dict-map (ms function) " DO: Calls FUNCTION (lambda (symbol value) ...) with all successive bindings, (unless matching state is failed). RETURN: The list of results of the FUNCTION. " (unless (match-state-failed-p ms) (mapcar (lambda (binding) (funcall function (first binding) (second binding))) (match-state-dict ms)))) (defun match-dict-add-binding (ms pat exp) "PRIVATE" (let* ((var (second (car pat))) (val (car exp)) (ass (assoc var (match-state-dict ms)))) (cond ((null ass) ; a new binding: (make-match-state :dict (cons (cons var val) (match-state-dict ms)))) ((equalp (cdr ass) val) ; already there, same ms) (t ; already there, different (match-state-fail ms `(:mismatching-binding ,ass ,val)))))) (defmacro defpattern (name pattern) (if (symbolp pattern) `(defun ,name (pat) ;; (?ac ...) "PRIVATE" (and (listp pat) (symbolp (car pat)) (string= ',pattern (car pat)))) `(defun ,name (pat) ;; ((?n ...)...) "PRIVATE" (and (listp pat) (listp (car pat)) (symbolp (caar pat)) (string= ',(car pattern) (caar pat)))))) (defpattern pat-anonymous-variable-p ?av) (defpattern pat-anonymous-constant-p ?ac) (defpattern pat-anonymous-expression-p ?ax) (defpattern pat-named-p (?n)) (defpattern pat-variable-p (?v)) (defpattern pat-constant-p (?c)) (defpattern pat-expression-p (?x)) (defpattern pat-optional-p (??)) (defpattern pat-repeat-p (?+)) (defpattern pat-optional-repeat-p (?*)) (defpattern pat-alternative-p (?/)) (defpattern pat-squeleton-eval-p |:|) (defun exp-variable-p (exp) "PRIVATE" (and (consp exp) (symbolp (car exp)))) (defun exp-constant-p (exp) "PRIVATE" (and (consp exp) (atom (car exp)) (not (symbolp (car exp))))) ;; (?n n ?v) == (?v n) ;; (match '((?+ a b c)) '(a b c a b c)) ;; pattern ::= term | ( pattern-seq ) . ;; pattern-seq ::= | pattern pattern-seq . ;; pattern-lst ::= | pattern pattern-lst . ;; ;; term ::= ?av | ?ac | ?ax -- anonymous terms ;; | (?v name) | (?c name) | (?x name) -- named terms ;; | (?n name pattern-seq) -- named sequence ;; | (?? pattern-seq ) -- optional sequence ;; | (?+ pattern-seq ) -- repeat sequence ;; | (?* pattern-seq ) -- optional repeat sequence ;; | (?/ pattern-lst ) -- alternative ;; | atom | compound . ;; ;; name ::= symbol . ;; ;; atom ::= symbol | string | character | number . ;; compound ::= list | array | structure . ;; list ::= ( pattern-seq ) . ;; array ::= #A( pattern-seq ) ;; | #1A( pattern-seq ) ;; | #2A( (pattern-seq)... ) ;; | #3A( ((pattern-seq)...)... ) ;; | ... . (defun generate-all-follows (exp) " RETURN: a list of possible follows from shortest to longuest. " (do ((rest exp (cdr rest)) ;; what should match after (list '()) ;; what we match (reversed), ;; we reverse only in the final result [F]. (frame '())) ((null rest) (push (list list rest) frame) frame) (push (list list rest) frame) (push (car rest) list))) (defun match (pat exp &optional (ms (make-match-state))) " DO: A pattern matcher accepting the following syntax: ?av expects a symbol (variable). ?ac expects a constant (non symbol atom). ?ax expects anything (one item). (?v n) expects a symbol (variable) and bind it. (?c n) expects a constant (non symbol atom) and bind it. (?x n) expects anything (one item) and bind it. (?n n ...) expects anything (several item) and bind them. (?+ ...) expects anything (one or more times). AOB (?* ...) expects anything (zero or more times). AOB (?? ...) expects anything (zero or one time). ... expects exactly ... (can be a sublist). AOB = All occurences bind. RETURN: A match-state structure. SEE ALSO: match-state-failed-p to check if the matching failed. match-state-dict to get the binding dictionary. " ;; The pattern and the expression may be atoms or lists, ;; but usually we process (car pat) and (car exp), to be able ;; to match several items (?+ and ?*). (cond ((match-state-failed-p ms) ms) ((atom pat) (if (equal pat exp) ms (match-state-fail ms `(:different ,pat ,exp)))) ((pat-anonymous-constant-p pat) (if (exp-constant-p exp) (match (cdr pat) (cdr exp) ms) (match-state-fail ms `(:not-constant ,exp)))) ((pat-anonymous-variable-p pat) (if (exp-variable-p exp) (match (cdr pat) (cdr exp) ms) (match-state-fail ms `(:not-variable ,exp)))) ((pat-anonymous-expression-p pat) (if (null exp) (match-state-fail ms `(:missing-expression)) (match (cdr pat) (cdr exp) ms))) ((pat-constant-p pat) (if (exp-constant-p exp) (match (cdr pat) (cdr exp) (match-dict-add-binding ms pat exp)) (match-state-fail ms `(:not-constant ,exp)))) ((pat-variable-p pat) (if (exp-variable-p exp) (match (cdr pat) (cdr exp) (match-dict-add-binding ms pat exp)) (match-state-fail ms `(:not-variable ,exp)))) ((pat-expression-p pat) (if (null exp) (match-state-fail ms `(:missing-expression)) (match (cdr pat) (cdr exp) (match-dict-add-binding ms pat exp)) )) ((pat-named-p pat) (loop for (list rest) in (generate-all-follows exp) for soe = (match (cdr pat) rest ms) for nms = (if (match-state-failed-p soe) soe (let* ((list (reverse list)) (nms (match (cddar pat) list soe))) (if (match-state-failed-p nms) nms (match-dict-add-binding nms pat (list list))))) while (match-state-failed-p nms) finally (return nms))) ((and (pat-repeat-p pat) (null exp)) (match-state-fail ms `(:missing-repeat ,pat))) ((or (pat-repeat-p pat) (pat-optional-repeat-p pat) (pat-optional-p pat)) (loop for (list rest) in (generate-all-follows exp) for soe = (match (cdr pat) rest ms) for nms = (if (match-state-failed-p soe) soe (cond ((pat-repeat-p pat) ;; at least one (...2... already matches) ;; ((?+ ...1...) ...2...) ;; --> (...1... (?* ...1...) ...2...) (match (append (cdar pat) (list (cons '?* (cdar pat)))) (reverse list) soe)) ((pat-optional-repeat-p pat) ;; zero or more (...2... already matches) ;; ((?* ...1...) ...2...) ;; --> (...1... (?* ...1...) ...2...) ;; --> (...2...) (let ((nms (match (append (cdar pat) (list (car pat))) (reverse list) soe))) (if (match-state-failed-p nms) (match nil list soe) nms))) ((pat-optional-p pat) ;; zero or one (...2... already matches) ;; ((?? ...1...) ...2...) ;; --> (...1... ...2...) ;; --> (...2...) (let ((nms (match (cdar pat) (reverse list) soe))) (if (match-state-failed-p nms) (match nil list soe) nms))))) while (match-state-failed-p nms) finally (return nms))) ((atom exp) (match-state-fail ms `(:unexpected-atom ,exp))) (t ;; both cars are sublists. (match (cdr pat) (cdr exp) (match (car pat) (car exp) ms))))) (defun evaluate (instance) "PRIVATE" (cond ((atom instance) instance) ((and (atom (car instance)) (string= :|| (car instance))) (eval (evaluate (second instance)))) (t (mapcar (function evaluate) instance)))) (defun dict-value (dict name) "PRIVATE" (second (assoc name dict :test (function string=)))) (defun dict-boundp (dict name) "PRIVATE" (and (or (symbolp name) (stringp name)) (assoc name dict :test (function string=)))) (defun subst-bindings (expr dict) "PRIVATE" (cond ((atom expr) (list expr)) ((and (atom (first expr)) (string= :|| (first expr))) (if (and (atom (second expr)) (dict-boundp dict (second expr))) (list (dict-value dict (second expr))) (list (mapcan (lambda (subexpr) (subst-bindings subexpr dict)) expr)))) ((and (atom (first expr)) (string= :|@| (first expr))) (copy-seq (dict-value dict (second expr)))) (t (list (mapcan (lambda (subexpr) (subst-bindings subexpr dict)) expr))))) (defun instanciate (ms skeleton) "PRIVATE PRE: (not (match-state-failed-p ms)) DO: Instanciate the skeleton, substituting all occurence of (: var) with the value bound to var in the binding dictionary of MS, Occurences of (:@ var) are split in line like ,@ in backquotes. Then all remaining (: form) are evaluated (with eval) from the deepest first. " (assert (not (match-state-failed-p ms))) (evaluate (first (subst-bindings skeleton (match-state-dict ms))))) (defun collect-variables (pat) " PAT: A symbolic expression with the following syntax: (?v v) expects a symbol (variable). (?c c) expects a constant (non symbol atom). (?x x) expects anything (one item). (?+ l) expects anything (one or more items). (?* l) expects anything (zero or more items). other expects exactly other (can be a sublist). RETURN: A list of the symbol used in the various (?. sym) items, in no particular order, but with duplicates deleted. " (delete-duplicates (cond ((atom pat) nil) ((and (atom (car pat)) (member (car pat) '(?v ?c ?x ?+ ?*) :test (function string=))) (list (cadr pat))) (t (nconc (collect-variables (car pat)) (collect-variables (cdr pat))))))) (defun match-case* (sexp clauses) " SEXP: A symbolic expression, evaluated. CLAUSES: A list of (pattern func) or (otherwise ofunc) The functions FUNC is called with one BINDINGS argument. The function OFUNC is called with no argument. DO: Call the function of the clause whose pattern matches the SEXP, or whose pattern is a symbol string-equal to OTHERWISE. RETURN: The result of the called function, and the pattern that matched. EXAMPLE: (match-case* expr `(((add (?x a) to (?x b)) ,(lambda (bindings) `(+ ,(aget bindings 'a) ,(aget bindings 'b))) ((multiply (?x a) with (?x b)) ,(lambda (bindings) `(* ,(aget bindings 'a) ,(aget bindings 'b)))) ((substract (?x a) from (?x a)) ,(constantly 0)) (otherwise ,(lambda () (error \"No matching pattern\")))))) " (loop :for (pattern func) :in clauses :do (if (and (symbolp pattern) (string-equal "OTHERWISE" pattern)) (return (values (funcall func) pattern)) (let ((bindings (match pattern sexp))) (unless (match-state-failed-p bindings) (return (values (funcall func bindings) pattern))))))) (defmacro match-case (sexp &rest clauses) " SEXP: A symbolic expression, evaluated. CLAUSES: A list of (pattern &body body) The pattern must be litteral. Lexical variable names are extracted from it, and body is executed in a lexical environment where these names are bound to the matched subexpression of SEXP. DO: Execute the body of the clause whose pattern matches the SEXP, or whose pattern is a symbol string-equal to OTHERWISE. EXAMPLE: (match-case expr ((add (?x a) to (?x b)) `(+ ,a ,b)) ((multiply (?x a) with (?x b)) `(* ,a ,b)) ((substract (?x a) from (?x a)) 0) (otherwise :error)) " (with-gensyms (ex ms dc) `(let ((,ex ,sexp) (,ms) (,dc)) (cond ,@(mapcar (lambda (clause) (let ((pat (car clause)) (body (cdr clause))) (if (and (symbolp pat) (string-equal "OTHERWISE" pat)) `(t ,@body) `((progn (setf ,ms (match ',pat ,ex)) (not (match-state-failed-p ,ms))) (setf ,dc (match-state-dict ,ms)) (let ( ,@(mapcar (lambda (name) `(,name (cdr (assoc ',name ,dc)))) (collect-variables pat)) ) ,@body))))) clauses))))) ;;;; THE END ;;;;
17,151
Common Lisp
.lisp
396
35.55303
83
0.543783
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
7d4cd3825d68a5c28b5987c963f8f64f89adce9b16439b88dae9be5e9943b2ea
5,111
[ -1 ]
5,112
com.informatimago.common-lisp.cesarum.asd
informatimago_lisp/common-lisp/cesarum/com.informatimago.common-lisp.cesarum.asd
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: com.informatimago.common-lisp.cesarum.asd ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; ASD file to load the com.informatimago.common-lisp.cesarum library. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2018-12-30 <PJB> Added symbol.lisp ;;;; 2010-10-31 <PJB> Created this .asd file. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2010 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see http://www.gnu.org/licenses/ ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) #+clisp (unless custom:*ansi* (warn "System ~A: clisp should be used with -ansi or (setf custom:*ansi* t) in ~/.clisprc" :com.informatimago.common-lisp.cesarum))) (asdf:defsystem "com.informatimago.common-lisp.cesarum" ;; system attributes: :description "Various general data types, algorithms, utilities and standards." :long-description " This system provides various kinds of packages: - Common Lisp addendums (utility, array, sequence, list, string, package, file, stream); - Data structures (sets, relations, dictionaries, lists, queues, trees, graphs); - Standards (ascii, ecma048, iso3166, iso4217, iso693a); - Algorithms (pattern matcher, combinations, constraints, dfa, etc); all written in 100% conforming Common Lisp. " :author "Pascal J. Bourguignon <[email protected]>" :maintainer "Pascal J. Bourguignon <[email protected]>" :licence "AGPL3" ;; component attributes: :version "1.8.1" :properties ((#:author-email . "[email protected]") (#:date . "Autumn 2015") ((#:albert #:output-dir) . "/tmp/documentation/com.informatimago.common-lisp.cesarum/") ((#:albert #:formats) . ("docbook")) ((#:albert #:docbook #:template) . "book") ((#:albert #:docbook #:bgcolor) . "white") ((#:albert #:docbook #:textcolor) . "black")) #+asdf-unicode :encoding #+asdf-unicode :utf-8 :depends-on ("com.informatimago.common-lisp.lisp-sexp") #+adsf3 :in-order-to #+adsf3 ((test-op (test-op "com.informatimago.common-lisp.cesarum.test"))) :components ( ;; Simple Test Framework (:file "simple-test" :depends-on ("time")) ;; Common Lisp addendum: (:file "array" :depends-on ()) (:file "sequence" :depends-on ()) (:file "list" :depends-on ()) (:file "symbol" :depends-on ()) (:file "utility" :depends-on ("list" "symbol")) (:file "string" :depends-on ("utility" "list" "sequence" "ecma048")) (:file "package" :depends-on ("utility")) ;; Data structures: (:file "set" :depends-on ("simple-test" "utility" "array")) (:file "index-set" :depends-on ("simple-test" "utility" "array" "sequence" "set")) (:file "bset" :depends-on ("utility" "set")) (:file "brelation" :depends-on ("utility" "bset")) (:file "dictionary" :depends-on ()) (:file "dll" :depends-on ()) (:file "graph" :depends-on ("utility" "list")) (:file "llrbtree" :depends-on ()) (:file "queue" :depends-on ("utility")) (:file "message-queue" :depends-on ("queue")) (:file "priority-queue" :depends-on ()) ;; Standards: (:file "ecma048" :depends-on ("utility")) (:file "character" :depends-on ("ecma048")) (:file "ascii" :depends-on ("ecma048" "character")) (:file "character-sets" :depends-on ("string")) (:file "iso3166" :depends-on ()) (:file "iso4217" :depends-on ()) (:file "iso639a" :depends-on ()) ;; Algorithms: (:file "pmatch" :depends-on ("utility")) (:file "combination" :depends-on ()) (:file "constraints" :depends-on ("utility" "dictionary")) (:file "raiden" :depends-on ()) (:file "dfa" :depends-on ()) (:file "tea" :depends-on ()) (:file "circular" :depends-on ()) (:file "histogram" :depends-on ()) (:file "a-star" :depends-on ()) (:file "mersenne" :depends-on ()) (:file "xoroshiro128" :depends-on ()) ;; Specific stuff: (:file "time" :depends-on ()) (:file "activity" :depends-on ("time")) (:file "date" :depends-on ()) (:file "version" :depends-on ()) ;; Files: (:file "stream" :depends-on ("string")) (:file "file" :depends-on ("stream" "ascii")) (:file "peek-stream" :depends-on ()) (:file "cache" :depends-on ()) (:file "float-binio" :depends-on ()) ) #+adsf3 :in-order-to #+adsf3 ((asdf:test-op (asdf:test-op "com.informatimago.common-lisp.cesarum.test")))) ;; Would require a separate asd file... ;; Tools: ;; (:file "update-iso3166" :depends-on ()) ;; (:file "iana-character-sets" :depends-on ()) ;;;; THE END ;;;;
6,620
Common Lisp
.lisp
128
43.132813
111
0.518312
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
8b428ffa384bffc7b667501289133489cc817d8acbb4239bdea2dcef4b710a3e
5,112
[ -1 ]
5,113
version.lisp
informatimago_lisp/common-lisp/cesarum/version.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: version.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; See defpackage documentation string. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2015-01-25 <PJB> Improved parsing of lisp-implementation-version strings. ;;;; 2010-07-18 <PJB> Extracted from script.lisp (extracted from .clisprc). ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2010 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.VERSION" (:use "COMMON-LISP") (:export "VERSION" "VERSION=" "VERSION<" "VERSION<=" "VERSION/=" "VERSION>" "VERSION>=" "RT-VERSION=" "RT-VERSION<" "RT-VERSION<=" "RT-VERSION/=" "RT-VERSION>" "RT-VERSION>=" ) (:documentation " This package exports functions to get and compare lisp implementation versions. License: AGPL3 Copyright Pascal J. Bourguignon 2010 - 2015 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.VERSION") (defun version (&optional (version-string (lisp-implementation-version))) " Parse the version in the version-string or (lisp-implementation-version) This is expected to be a sequence of integers separated by dots. Return it as a list of integers. " ;; version ::= [a-z]* integer ('.' integer)* ('.' [a-z]+)? (+|[a-z]|'r' integer)? ('(' /.*/)? (let ((pos 0) (len (length version-string))) (labels ((peek (&optional (offset 0)) (when (< (+ pos offset) len) (aref version-string (+ pos offset)))) (eat (&optional (n 1)) (when (<= (+ pos n) len) (prog1 (aref version-string pos) (incf pos n)))) (spacep (ch) (and ch (char= #\space ch))) (prefix () (loop :for ch = (peek) :while (and ch (or (spacep ch) (alpha-char-p ch))) :do (eat)) '()) (word () (loop :for ch = (peek) :while (and ch (alpha-char-p ch)) :do (eat)) '()) (int () (let ((ch (peek))) (when (digit-char-p ch) (multiple-value-bind (n p) (parse-integer version-string :start pos :junk-allowed t) (setf pos p) n)))) (dot () (let ((ch (peek))) (when (and ch (char= #\. ch)) (eat)))) (rel () (let ((ch (peek))) (cond ((null ch) '()) ((char= #\+ ch) ; clisp 2.49+ --> 2.49.1 (eat) (list 1)) ((and (char= #\- ch) (char= #\r (peek 1))) ; ccl 1.10-r16196 (eat 2) (list (int))) ((alpha-char-p ch) ; cmucl 20d -> 20.3 (let ((p (position (eat) "ABCDEFGHIJKLMNOPQRSTUVWXYZ" :test (function char-equal)))) (when p (list p)))) (t '()))))) (prefix) (nconc (list (int)) (loop :with vers = '() :while (dot) :do (let ((item (int))) (if item (push item vers) (word))) :finally (return (nreverse vers))) (rel))))) (assert (equal (mapcar (function version) '("1.3.1" "Version 1.10-r16196 (LinuxX8664)" "2.49+ (2010-07-17) (built 3603386203) (memory 3603386298)" "20d (20D Unicode)" "13.5.1" "1.0.57.0.debian")) '((1 3 1) (1 10 16196) (2 49 1) (20 3) (13 5 1) (1 0 57 0)))) (defun version= (a b) "Compare versions A and B, which may be either lists of integers, or a dotted string." (let ((a (if (stringp a) (version a) a)) (b (if (stringp b) (version b) b))) (equal a b))) (defun version/= (a b) "Compare versions A and B, which may be either lists of integers, or a dotted string." (not (version= a b))) (defun version< (a b) "Compare versions A and B, which may be either lists of integers, or a dotted string." (let ((a (if (stringp a) (version a) a)) (b (if (stringp b) (version b) b))) (cond ((null a) (not (null b))) ((null b) nil) ((< (car a) (car b)) t) ((= (car a) (car b)) (version< (cdr a) (cdr b))) (t nil)))) (defun version<= (a b) "Compare versions A and B, which may be either lists of integers, or a dotted string." (let ((a (if (stringp a) (version a) a)) (b (if (stringp b) (version b) b))) (or (version= a b) (version< a b)))) (defun version> (a b) "Compare versions A and B, which may be either lists of integers, or a dotted string." (version< b a)) (defun version>= (a b) "Compare versions A and B, which may be either lists of integers, or a dotted string." (version<= b a)) (defun rt-version= (a b) "Compare versions A and B, which may be either lists of integers, or a dotted string, returning either (:AND) or (:OR), for use as a read-time feature expression. #.#+(version:rt-version= \"1.0\" (version:version)) read-only-in-version-1.0 " (if (version= a b) '(:and) '(:or))) (defun rt-version< (a b) " Compare versions A and B, which may be either lists of integers, or a dotted string, returning either (:AND) or (:OR), for use as a read-time feature expression. #.#+(version:rt-version= \"1.0\" (version:version)) read-only-in-version-1.0 " (if (version< a b) '(:and) '(:or))) (defun rt-version<= (a b) " Compare versions A and B, which may be either lists of integers, or a dotted string, returning either (:AND) or (:OR), for use as a read-time feature expression. #.#+(version:rt-version= \"1.0\" (version:version)) read-only-in-version-1.0 " (if (version<= a b) '(:and) '(:or))) (defun rt-version> (a b) " Compare versions A and B, which may be either lists of integers, or a dotted string, returning either (:AND) or (:OR), for use as a read-time feature expression. #.#+(version:rt-version= \"1.0\" (version:version)) read-only-in-version-1.0 " (rt-version< b a)) (defun rt-version>= (a b) " Compare versions A and B, which may be either lists of integers, or a dotted string, returning either (:AND) or (:OR), for use as a read-time feature expression. #.#+(version:rt-version= \"1.0\" (version:version)) read-only-in-version-1.0 " (rt-version<= b a)) ;;;; THE END ;;;;
8,720
Common Lisp
.lisp
205
34.239024
95
0.543653
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
1fcae39c58e3c67f8c874fde7b4a32ba1bf4feb45052b9ebd351012f621ccd1b
5,113
[ -1 ]
5,114
dictionary-test.lisp
informatimago_lisp/common-lisp/cesarum/dictionary-test.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: dictionary-test.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Tests dictionary.lisp. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2015-02-25 <PJB> Extracted from dictionary.lisp. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DICTIONARY.TEST" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SIMPLE-TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DICTIONARY") (:export "TEST/ALL")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DICTIONARY.TEST") (defun test/dictionary (type) (let ((d (make-dictionary type :test (function equal) :contents '(a 1 b 2 c 3)))) (assert-true (= 3 (dictionary-count d))) (assert-true (equalp (list (dictionary-get d 'a 0) (dictionary-get d 'b 0) (dictionary-get d 'c 0) (dictionary-get d 'd 0)) '(1 2 3 0))) (dictionary-set d 'a 11) (dictionary-set d 'd 4) (dictionary-set d 'c 33) (assert-true (= 4 (dictionary-count d))) (assert-true (equalp (list (dictionary-get d 'a 0) (dictionary-get d 'b 0) (dictionary-get d 'c 0) (dictionary-get d 'd 0) (dictionary-get d 'e 0)) '(11 2 33 4 0))) (setf (dictionary-get d 'a 0) 111) (setf (dictionary-get d 'd 0) 444) (setf (dictionary-get d 'c 0) 333) (assert-true (= 4 (dictionary-count d))) (assert-true (equalp (list (dictionary-get d 'a 0) (dictionary-get d 'b 0) (dictionary-get d 'c 0) (dictionary-get d 'd 0) (dictionary-get d 'e 0)) '(111 2 333 444 0))) (dictionary-delete d 'b) (assert-true (= 3 (dictionary-count d))) (assert-true (equalp (list (dictionary-get d 'a 0) (dictionary-get d 'b 0) (dictionary-get d 'c 0) (dictionary-get d 'd 0) (dictionary-get d 'e 0)) '(111 0 333 444 0))) (let ((res (dictionary-map (function cons) d))) (assert-true (and (subsetp res '((a . 111) (c . 333) (d . 444)) :test (function equalp)) (subsetp '((a . 111) (c . 333) (d . 444)) res :test (function equalp))))) (dictionary-map (lambda (key value) (declare (ignore value)) (dictionary-delete d key)) d) (assert-true (= 0 (dictionary-count d))) (loop :for i :from 1 :to 100 :do (dictionary-set d i (* 1000 i))) (assert-true (= 100 (dictionary-count d))) (assert-true (loop :for i :from 1 :to 100 :always (= (dictionary-get d i 0) (* 1000 i)))) (loop :for i :from 1 :to 96 :do (dictionary-delete d i)) (assert-true (= 4 (dictionary-count d))) (assert-true (loop :for i :from 1 :to 96 :always (null (nth-value 1 (dictionary-get d i 0))))) (assert-true (loop :for i :from 97 :to 100 :always (= (dictionary-get d i 0) (* 1000 i)))))) (define-test test/all () "Tests all the kinds of dictionary defined in this package." (dolist (type '(hash-table p-list a-list adaptating-dictionary)) (test/dictionary type))) ;;;; THE END ;;;;
4,959
Common Lisp
.lisp
110
34.281818
94
0.510128
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
59e614e45ca23dc1877bea1d5e7918cbef593f30d1ab84290a3ec58367eb0c6d
5,114
[ -1 ]
5,115
com.informatimago.common-lisp.cesarum.test.asd
informatimago_lisp/common-lisp/cesarum/com.informatimago.common-lisp.cesarum.test.asd
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: com.informatimago.common-lisp.cesarum-test.asd ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; ASD file to test the com.informatimago.common-lisp.cesarum library. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2015-01-08 <PJB> Created this .asd file. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see http://www.gnu.org/licenses/ ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) #+clisp (unless custom:*ansi* (warn "System ~A: clisp should be used with -ansi or (setf custom:*ansi* t) in ~/.clisprc" :com.informatimago.common-lisp.cesarum.test))) (asdf:defsystem "com.informatimago.common-lisp.cesarum.test" ;; system attributes: :description "Tests the cesarum library." :author "Pascal J. Bourguignon <[email protected]>" :maintainer "Pascal J. Bourguignon <[email protected]>" :licence "AGPL3" ;; component attributes: :version "1.5.0" :properties ((#:author-email . "[email protected]") (#:date . "Winter 2015") ((#:albert #:output-dir) . "/tmp/documentation/com.informatimago.common-lisp.cesarum-test/") ((#:albert #:formats) . ("docbook")) ((#:albert #:docbook #:template) . "book") ((#:albert #:docbook #:bgcolor) . "white") ((#:albert #:docbook #:textcolor) . "black")) #+asdf-unicode :encoding #+asdf-unicode :utf-8 :depends-on ("com.informatimago.common-lisp.cesarum") :components ((:file "a-star-test" :depends-on ()) (:file "array-test" :depends-on ()) (:file "cache-test" :depends-on ()) (:file "date-test" :depends-on ()) (:file "dictionary-test" :depends-on ()) (:file "file-test" :depends-on ()) (:file "list-test" :depends-on ()) (:file "llrbtree-test" :depends-on ()) (:file "peek-stream-test" :depends-on ()) (:file "priority-queue-test" :depends-on ()) (:file "sequence-test" :depends-on ()) (:file "ascii-test" :depends-on ()) (:file "string-test" :depends-on ()) (:file "set-test" :depends-on ()) (:file "index-set-test" :depends-on ("set-test"))) #+asdf3 :perform #+asdf3 (asdf:test-op (operation system) (dolist (p '("COM.INFORMATIMAGO.COMMON-LISP.CESARUM.A-STAR.TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.ARRAY.TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.CACHE.TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DATE.TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.DICTIONARY.TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.FILE.TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.LIST.TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.LLRBTREE.TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.PEEK-STREAM.TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.PRIORITY-QUEUE.TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SEQUENCE.TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STRING.TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SET.TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.INDEX-SET.TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.ASCII.TEST")) (let ((*package* (find-package p))) (uiop:symbol-call p "TEST/ALL"))))) ;;;; THE END ;;;;
5,153
Common Lisp
.lisp
90
44.711111
116
0.520166
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
0cbcf8088f4583ecfce68dfa472c1c7ea0b3cec93af53f63c5c69466c521e26e
5,115
[ -1 ]
5,116
cache.lisp
informatimago_lisp/common-lisp/cesarum/cache.lisp
;;;; -*- coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: cache.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; A generic disk-based cache. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2005-01-16 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2005 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.CACHE" (:use "COMMON-LISP") #+mocl (:shadowing-import-from "COM.INFORMATIMAGO.MOCL.KLUDGES.MISSING" "*TRACE-OUTPUT*" "*LOAD-VERBOSE*" "*LOAD-PRINT*" "ARRAY-DISPLACEMENT" "CHANGE-CLASS" "COMPILE" "COMPLEX" "ENSURE-DIRECTORIES-EXIST" "FILE-WRITE-DATE" "INVOKE-DEBUGGER" "*DEBUGGER-HOOK*" "LOAD" "LOGICAL-PATHNAME-TRANSLATIONS" "MACHINE-INSTANCE" "MACHINE-VERSION" "NSET-DIFFERENCE" "RENAME-FILE" "SUBSTITUTE-IF" "TRANSLATE-LOGICAL-PATHNAME" "PRINT-NOT-READABLE" "PRINT-NOT-READABLE-OBJECT") (:export "CACHE-EXPIRE-ALL" "CACHE-EXPIRE" "CACHE-EXPIRATION" "CACHE-GET" "SYNCHRONIZE-CACHE" "MAKE-CACHE" "CACHE-PRODUCER" "CACHE-VALUE-FILE-TYPE" "CACHE-INDEX-FILE-PATH" "CACHE-DIRECTORY-PATH" "CACHE" "CACHE-MAP-ENTRIES" "ENTRY" "ENTRY-KEY" "ENTRY-VALUE" "ENTRY-VALUE-P" "ENTRY-FILE-NAME" "ENTRY-FETCH-DATE" "ENTRY-EXPIRE-DATE") (:documentation " This package implements a generic disk-based cache. Example: (defparameter *web-cache* (make-instance 'cache :directory-path \"CACHE:WEB;\" :value-file-type \"HTML\" :producer (function get-url))) (cache-get *web-cache* \"http://www.informatimago.com/\") --> \"&lt;\!DOCTYPE html PUBLIC …\" ; :FETCHED (cache-get *web-cache* \"http://www.informatimago.com/\") --> \"&lt;\!DOCTYPE html PUBLIC …\" ; :IN-CORE License: AGPL3 Copyright Pascal J. Bourguignon 2005 - 2015 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.CACHE") ;; (make-cache directory producer &key value-file-type) --> cache ;; ;;(producer key) --> value ; expiration ;; (cache-get cache key) --> value ; (or nil :cached :fetched) ;; (cache-expiration cache key) --> expiration (or null universal-time) ;; (cache-expire cache key &key keep-file) ;; (cache-expire-all cache &key keep-files) ;; ;; key [expiration] value ;; ;; The cache index is loaded in RAM (defgeneric cache-directory-path (cache) (:documentation "Path to the directory where the cache data is stored.")) (defgeneric set-cache-directory-path (cache new-path) (:documentation " DO: Change the path of the cache directory. ")) (defgeneric touch-cache-date (cache) (:documentation " DO: Update the date of the cache in core. ")) (defgeneric cache-index-read-date (cache) (:documentation " RETURN: If the file (cache-index-file-path self) exists and is a cache index file, then the cache-date of the cache index file, else NIL. ")) (defgeneric cache-index-file-path (cache) (:documentation " RETURN: The path to the cache index file. ")) (defgeneric load-cache (cache) (:documentation " DO: Load the cache index from the file (cache-index-file-path self). ")) (defgeneric save-cache (cache) (:documentation " DO: Save the cache index to the file (cache-index-file-path self). ")) (defgeneric synchronize-cache (cache) (:documentation " DO: Ensure the cache index in core and on disk are synchronized. ")) (defgeneric old-value-file-path (cache name) (:documentation " RETURN: The file path of an existing entry named NAME in the CACHE. ")) (defgeneric new-value-file-path (cache) (:documentation " RETURN: The file path of an new entry named NAME in the CACHE. ")) (defgeneric cache-expiration (cache key) (:documentation " RETURN: NIL or the universal-time of expiration of the CACHE. ")) (defgeneric cache-expire (cache key &key keep-file) (:documentation " DO: Expire the entry KEY from the CACHE. KEEP-FILE: When true, the file is not deleted from the cache. ")) (defgeneric cache-expire-all (cache &key keep-files) (:documentation " DO: Expire all the entries from the CACHE. KEEP-FILE: When true, the files are not deleted from the cache. ")) (defgeneric cache-map-entries (cache result-type function) (:documentation " DO: Calls the FUNCTION on each entry of the CACHE, collecting the results in a sequence of type RESULT-TYPE. RESULT-TYPE: NIL --> no result is collected, NIL is returned. LIST --> the results are collected into a list. VECTOR --> the results are collected into a vector. STRING --> the results must be characters, they're collected into a string. RETURN: The collected results. " )) (defgeneric cache-producer (cache) (:documentation " RETURN: The cache producer of the cache. ")) (defgeneric cache-value-file-type (cache) (:documentation " RETURN: The type used for value files in the cache directory. ")) (defclass cache () ((cache-directory-path :reader cache-directory-path :initarg :directory-path :type pathname :initform (make-pathname :directory (append (pathname-directory (user-homedir-pathname)) '("CACHE")) :defaults (user-homedir-pathname)) :documentation "Path to the directory where the cache data is stored.") (cache-index-file-path :reader cache-index-file-path :type pathname :documentation "Path to the cache index file.") (cache-value-file-type :reader cache-value-file-type :initarg :value-file-type :type string :initform "DAT" :documentation "The type used for value files in the cache directory.") (cache-producer :reader cache-producer :initarg :producer :type (function (t) (values t (integer 0))) ;; (producer key) --> value ; expiration :documentation "The function used to get fresh data. Returns two values: the data and the expiration universal time.") (index :type hash-table :initform (make-index) :documentation "An equal hash table mapping urls to cache-entries") (date :type cons :initform (cons 0 0) :documentation "The date (universal time) and increment of last modification of the index map.")) (:documentation "A generic disk-based cache.")) ;; cache-index file: header record* ;; header: (:type :cache-index :date cache-date :value-file-type str) ;; record: (:key readable :file-name str :fetch-date int :expire-date int) (defmethod initialize-instance :after ((self cache) &rest args) (declare (ignore args)) (set-cache-directory-path self (cache-directory-path self)) self) (defmethod set-cache-directory-path ((self cache) new-path) " DO: Change the path of the cache directory. NOTE: This updates both the CACHE-DIRECTORY-PATH and the CACHE-INDEX-FILE-PATH of the cache. " (assert (typep new-path 'pathname)) (setf (slot-value self 'cache-directory-path) new-path (slot-value self 'cache-index-file-path) (make-pathname :name "CACHE" :type "IDX" :defaults new-path))) (defsetf cache-directory-path set-cache-directory-path) (defun compare-cache-date (a b) " A,B: Time stamps (cache date) are (universal-time . increment). RETURN: -1 <=> a<b, 0 <=> a=b, +1 <=> a>b " (cond ((null a) (if b -1 0)) ((null b) 1) ((< (car a) (car b)) -1) ((> (car a) (car b)) 1) (t (cond ((< (cdr a) (cdr b)) -1) ((> (cdr a) (cdr b)) 1) (t 0))))) (defmethod touch-cache-date ((self cache)) " DO: Update the date of the cache in core. " (symbol-macrolet ((date (slot-value self 'date))) (if (and date (= (car date) (get-universal-time))) (incf (cdr date)) (setf date (cons (get-universal-time) 0))))) (defstruct entry "A cache index entry, mapping a key with the date the resource was fetched and the file-name of the files where the resource and the parsed html are stored, and references to these data when they are loaded in core." (key nil) (value nil) (value-p nil :type boolean) ; value is loaded. (file-name "" :type string) ; name of the file. (fetch-date 0 :type (integer 0)) ; universal time. (expire-date 0 :type (integer 0))) ; universal time. (setf (documentation 'entry-key 'function) "RETURN: The key of the entry.") (setf (documentation 'entry-value 'function) "PRE: (entry-value-p entry) RETURN: The value of the entry.") (setf (documentation 'entry-value-p 'function) "RETURN: Whether the value of the entry is loaded.") (setf (documentation 'entry-file-name 'function) "RETURN: The name of the file where the value is stored.") (setf (documentation 'entry-fetch-date 'function) "RETURN: The universal-time when the entry was stored.") (setf (documentation 'entry-expire-date 'function) "RETURN: The universal-time when the entry expires.") (defun make-index () (make-hash-table :test (function equal))) (defun index-put (index entry) (setf (gethash (entry-key entry) index) entry)) (defun index-get (index key) (gethash key index)) (defun index-remove (index key) (remhash key index)) (defun index-map-entries (result-type fun index) (ecase result-type ((nil) (maphash (lambda (k v) (declare (ignore k)) (funcall fun v)) index) nil) ((list) (let ((result '())) (maphash (lambda (k v) (declare (ignore k)) (push (funcall fun v) result)) index) (nreverse result))) ((vector string) (let ((result (if (eq 'vector result-type) (make-array (list (hash-table-count index))) (make-string (hash-table-count index)))) (i -1)) (maphash (lambda (k v) (declare (ignore k)) (setf (aref result (incf i)) (funcall fun v))) index) result)))) (defun cache-header-p (header) " RETURN: Whether HEADER is a cache index file header. " ;; header: (:type :cache-index :date cache-date :value-file-type str) (and (listp header) (eq (getf header :type) :cache-index) (stringp (getf header :value-file-type)) (consp (getf header :date)) (typep (car (getf header :date)) '(integer 0)) (typep (cdr (getf header :date)) '(integer 0)))) (defun cache-record-p (record) " RETURN: Whether RECORD is a cache index file record. " ;; record: (:key readable :file-name str :fetch-date int :expire-date int) (and (listp record) (getf record :key) (stringp (getf record :file-name)) (integerp (getf record :fetch-date)) (integerp (getf record :expire-date)))) (defmethod cache-index-read-date ((self cache)) " RETURN: If the file (cache-index-file-path self) exists and is a cache index file, then the cache-date of the cache index file, else NIL. " (with-open-file (index (cache-index-file-path self) :direction :input :if-does-not-exist nil) (when index (with-standard-io-syntax (let* ((*read-eval* nil) (header (read index nil nil))) (and (cache-header-p header) (getf header :date))))))) (defmethod load-cache ((self cache)) " DO: Load the cache index from the file (cache-index-file-path self). " #+debug-COM.INFORMATIMAGO.COMMON-LISP.CESARUM.CACHE (format *trace-output* "~&Loading cache ~S~%" (cache-index-file-path self)) (with-open-file (file (cache-index-file-path self) :direction :input :if-does-not-exist :error) (with-standard-io-syntax (let* ((*read-eval* nil) (header (read file nil nil)) (index (make-index)) (cache-date)) (when (cache-header-p header) (setf cache-date (getf header :date)) (loop for record = (read file nil nil) while (cache-record-p record) do (index-put index (make-entry :key (getf record :key) :file-name (getf record :file-name) :fetch-date (getf record :fetch-date) :expire-date (getf record :expire-date))) finally (when record (error "Invalid cache index record: ~S" record))) (setf (slot-value self 'cache-value-file-type) (getf header :value-file-type) (slot-value self 'index) index (slot-value self 'date) cache-date)))))) (defun safe-rename-file (old-name new-name) (handler-case (rename-file old-name new-name) ;; CLISP<=2.33.2 RENAME-FILE is buggy: (file-error (err) (unless (and (equal new-name (file-error-pathname err)) (probe-file new-name)) (signal err)) (let ((old (make-pathname :type "OLD" :defaults old-name))) (when (probe-file old) (delete-file old)) (rename-file new-name old) (unwind-protect (rename-file old-name new-name) (if (and (probe-file old) (probe-file new-name)) (ignore-errors (delete-file old)) (progn (rename-file old new-name) (signal err)))))))) (defmethod save-cache ((self cache)) " DO: Save the cache index to the file (cache-index-file-path self). " #+debug-COM.INFORMATIMAGO.COMMON-LISP.CESARUM.CACHE (format *trace-output* "~&Saving cache ~S~%" (cache-index-file-path self)) (ensure-directories-exist (cache-index-file-path self)) (let ((tmp-name (make-pathname :type "NEW" :defaults (cache-index-file-path self)))) (with-open-file (file tmp-name :direction :output :if-does-not-exist :create :if-exists :supersede) (prin1 `(:type :cache-index :date ,(slot-value self 'date) :value-file-type ,(cache-value-file-type self)) file) (terpri file) (maphash (lambda (k v) (declare (ignore k)) (prin1 `(:key ,(entry-key v) :file-name ,(entry-file-name v) :fetch-date ,(entry-fetch-date v) :expire-date ,(entry-expire-date v)) file) (terpri file)) (slot-value self 'index))) (safe-rename-file tmp-name (cache-index-file-path self)))) (defmethod synchronize-cache ((self cache)) " DO: Ensure the cache index in core and on disk are synchronized. " (let ((disk-date (cache-index-read-date self))) (case (compare-cache-date (slot-value self 'date) disk-date) ((-1) (load-cache self)) ((1) (save-cache self))))) (defun value-file-path (directory name type) (make-pathname :name name :type type :directory (append (pathname-directory directory) (list (subseq name 0 1) (subseq name 1 2))) :defaults directory)) (defmethod old-value-file-path ((self cache) name) (value-file-path (cache-directory-path self) name (cache-value-file-type self))) (defmethod new-value-file-path ((self cache)) (loop with dire = (cache-directory-path self) with type = (cache-value-file-type self) for count from 0 for name = (format nil "~36,4,'0R~36,4,'0R" (random (expt 36 4)) (mod (get-universal-time) (expt 36 4))) for path = (value-file-path dire name type) until (ignore-errors (not (probe-file path))) do (when (<= 512 count) (error "Cannot come with a unique file name.")) finally (return path))) (defun make-cache (directory producer &key value-file-type) " DO: Make a new cache instance. NOTE: Send synchronize " (if value-file-type (make-instance 'cache :directory-path directory :producer producer :value-file-type value-file-type) (make-instance 'cache :directory-path directory :producer producer))) (defgeneric cache-get (cache key) (:documentation " RETURN: the value stored in the CACHE for the KEY; :FETCHED --> the value was obtained by the CACHE-PRODUCER. :IN-CORE --> the value was in memory :ON-DISK --> the value was on disk (in the disk cache). ")) (defmethod cache-get ((self cache) key) (synchronize-cache self) (let ((entry (index-get (slot-value self 'index) key))) (cond ((or (null entry) ; no entry ==> fetch (< (entry-expire-date entry) (get-universal-time))) #+debug-COM.INFORMATIMAGO.COMMON-LISP.CESARUM.CACHE (if (null entry) (format *trace-output* "~&(cache-get ~S): No cache entry ==> fetch~%" key) (format *trace-output* "~&(cache-get ~S): expired (~A<~A) ==> fetch~%" key (entry-expire-date entry) (get-universal-time))) #+(or)(invoke-debugger (make-condition 'simple-error :format-control "~&~S not in ~S~%" :format-arguments (list key (slot-value self 'index) self))) (multiple-value-bind (value expire) (funcall (cache-producer self) key) (let* ((path (if entry (old-value-file-path self (entry-file-name entry)) (new-value-file-path self))) (entry (make-entry :key key :value value :value-p t :file-name (pathname-name path) :fetch-date (get-universal-time) :expire-date expire))) (ensure-directories-exist path) (with-open-file (out path :direction :output :if-exists :supersede :if-does-not-exist :create) (with-standard-io-syntax (print value out))) (index-put (slot-value self 'index) entry) (touch-cache-date self) (synchronize-cache self) (values value :fetched)))) ((entry-value-p entry) ; ==> in core #+debug-COM.INFORMATIMAGO.COMMON-LISP.CESARUM.CACHE (format *trace-output* "~&(cache-get ~S): got it in core~%" key) (values (entry-value entry) :in-core)) (t ; ==> read from disk (with-open-file (in (old-value-file-path self (entry-file-name entry)) :direction :input :if-does-not-exist :error) (let ((value (with-standard-io-syntax (let ((*read-eval* nil)) (read in))))) (setf (entry-value entry) value (entry-value-p entry) t) #+debug-COM.INFORMATIMAGO.COMMON-LISP.CESARUM.CACHE (format *trace-output* "~&(cache-get ~S): read from disk~%" key) (values value :on-disk))))))) (defmethod cache-expiration ((self cache) key) ;; --> expiration (or null universal-time) (synchronize-cache self) (let ((entry (index-get (slot-value self 'index) key))) (when entry (entry-expire-date entry)))) (defmethod cache-expire ((self cache) key &key (keep-file nil)) (synchronize-cache self) (let* ((index (slot-value self 'index)) (entry (index-get index key))) (when entry (unless keep-file (delete-file (old-value-file-path self (entry-file-name entry)))) (index-remove index key) (touch-cache-date self) (synchronize-cache self)))) (defmethod cache-expire-all ((self cache) &key (keep-files nil)) (synchronize-cache self) (unless keep-files (cache-map-entries self nil (lambda (entry) (delete-file (old-value-file-path self (entry-file-name entry)))))) (setf (slot-value self 'index) (make-index)) (touch-cache-date self) (synchronize-cache self)) (defmethod cache-map-entries ((self cache) result-type function) (index-map-entries result-type function (slot-value self 'index))) ;;;; THE END ;;;;
23,188
Common Lisp
.lisp
523
35.453155
109
0.588874
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
b613a958222a9c97b125b9084bac952dea15f1fce96372f202660b80d8ce57da
5,116
[ -1 ]
5,117
stream.lisp
informatimago_lisp/common-lisp/cesarum/stream.lisp
;;;; -*- coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: stream.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; This package exports some stream utility functions. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2020-03-01 <PJB> Optimized CONTENTS-FROM-STREAM (avoid adjust-array when reading a whole file). ;;;; 2007-07-07 <PJB> Added CONTENTS-FROM-STREAM. ;;;; 2005-03-17 <PJB> Added COPY-OVER. ;;;; 2004-09-12 <PJB> Removed use of GRAY streams, ;;;; exported BVSTREAM-READ-BYTE and BVSTREAM-WRITE-BYTE. ;;;; 2004-08-18 <PJB> Added WITH-OUTPUT-TO-BYTE-VECTOR ;;;; and WITH-INPUT-FROM-BYTE-VECTOR. ;;;; 2004-02-28 <PJB> Extracted from utility to avoid circle ;;;; in package dependencies. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2004 - 2020 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STREAM" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STRING") (:export "BVSTREAM-READ-BYTE" "BVSTREAM-WRITE-BYTE" "BVSTREAM-POSITION" "WITH-INPUT-FROM-BYTE-VECTOR" "WITH-OUTPUT-TO-BYTE-VECTOR" "CONTENTS-FROM-STREAM" "COPY-OVER" "COPY-STREAM" "STREAM-TO-STRING-LIST" "STREAM-INPUT-STREAM" "STREAM-OUTPUT-STREAM" "BARE-STREAM") (:import-from "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STRING" "SPLIT-STRING") (:documentation " This package exports utility functions about streams. See also: COM.INFORMATIMAGO.COMMON-LISP.CESARUM.FILE License: AGPL3 Copyright Pascal J. Bourguignon 2003 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STREAM") (defun stream-to-string-list (stream) " RETURN: the list of lines collected from stream. " (typecase stream (stream (loop :for line = (read-line stream nil nil) :while line :collect line)) (string (split-string stream (format nil "~C" #\newline))) (otherwise nil))) (defun copy-stream (from to) "Copy into TO from FROM until end of the input file. Do not translate or otherwise maul anything. AUTHORS: Daniel Barlow, Xarch" (let ((buf (make-array 4096 :element-type (stream-element-type from)))) (do ((pos (read-sequence buf from) (read-sequence buf from))) ((= 0 pos) nil) (write-sequence buf to :end pos)))) (defun contents-from-stream (stream &key length (min-size 256) max-extend) " STREAM: May be a binary or character, file or non-file stream. LENGTH: NIL, or the number of stream elements to read. MIN-SIZE: Minimum pre-allocated buffer size. If LENGTH is given, or STREAM has a FILE-LENGTH, then the MIN-SIZE is ignored. MAX-EXTEND: NIL ==> double the buffer size, or double the buffer size until it's greater than MAX-EXTEND, and then increment by MAX-EXTEND. RETURN: A vector containing the elements read from the STREAM. " (let ((dirs (and (typep stream 'file-stream) (pathname-directory (pathname stream))))) (if (and dirs (eql :absolute (pop dirs)) (member (pop dirs) '("proc" "sys" "dev") :test (function string=))) ;; some implementations have problem reading those file systems with read-sequence ;; so we fallback to read-line: (if (subtypep (stream-element-type stream) 'character) (with-output-to-string (out) (loop :for line = (read-line stream nil nil) :while line :do (write-line line out))) (let* ((busize (or length (max (handler-case (file-length stream) (error () 0)) min-size))) (eltype (stream-element-type stream)) (initel (if (subtypep eltype 'integer) 0 #\space)) (buffer (make-array busize :element-type eltype :initial-element initel :adjustable t :fill-pointer 0))) (loop :for byte = (read-byte stream nil nil) :while byte :do (vector-push-extend byte buffer)) (return-from contents-from-stream buffer))) ;; normal case: (let* ((busize (or length (setf length (ignore-errors (file-length stream))) min-size)) (eltype (stream-element-type stream)) (initel (if (subtypep eltype 'integer) 0 #\space)) (buffer (make-array busize :element-type eltype :initial-element initel :adjustable t :fill-pointer t)) (start 0)) (loop (let ((end (read-sequence buffer stream :start start))) (when (or (< end busize) (and length (= length end))) ;; we got eof, or have read enough (setf (fill-pointer buffer) end) (return-from contents-from-stream buffer)) ;; no eof; extend the buffer (setf busize (if (or (null max-extend) (<= (* 2 busize) max-extend)) (* 2 busize) (+ busize max-extend)) start end)) (adjust-array buffer busize :initial-element initel :fill-pointer t)))))) (defun copy-over (stream from-pos to-pos &key (element-type 'character)) " DO: Copies elements from the FROM-POS to the end of the STREAM to the TO-POS. POST: (file-position stream) == (+ to-pos (- eof-pos from-ops)) NOTE: The file is not truncated. " (assert (< to-pos from-pos)) (do ((buffer (make-array '(1048576) :element-type element-type)) (eof nil) (length)) (eof) (file-position stream from-pos) (setf length (read-sequence buffer stream)) (setf from-pos (file-position stream)) (if (= length 0) (setf eof t) (progn (file-position stream to-pos) (write-sequence buffer stream :start 0 :end length) (setf to-pos (file-position stream)))))) (defgeneric stream-input-stream (stream) (:documentation "RETURN: A simple INPUT-STREAM.") (:method ((stream stream)) stream) #-mocl (:method ((stream concatenated-stream)) (stream-input-stream (first (concatenated-stream-streams stream)))) #-mocl (:method ((stream echo-stream)) (stream-input-stream (echo-stream-input-stream stream))) #-mocl (:method ((stream synonym-stream)) (stream-input-stream (symbol-value (synonym-stream-symbol stream)))) #-mocl (:method ((stream two-way-stream)) (stream-input-stream (two-way-stream-input-stream stream)))) (defgeneric stream-output-stream (stream) (:documentation "RETURN: A simple OUTPUT-STREAM.") (:method ((stream stream)) stream) #-mocl (:method ((stream broadcast-stream)) (stream-output-stream (first (broadcast-stream-streams stream)))) #-mocl (:method ((stream echo-stream)) (stream-input-stream (echo-stream-output-stream stream))) #-mocl (:method ((stream synonym-stream)) (stream-input-stream (symbol-value (synonym-stream-symbol stream)))) #-mocl (:method ((stream two-way-stream)) (stream-input-stream (two-way-stream-output-stream stream)))) ;; (defun stream-input-stream (stream) ;; " ;; RETURN: An input-stream. ;; " ;; (etypecase stream ;; (echo-stream (echo-stream-input-stream stream)) ;; (two-way-stream (two-way-stream-input-stream stream)) ;; (synonym-stream (stream-input-stream ;; (symbol-value (synonym-stream-symbol stream)))) ;; (concatenated-stream (stream-input-stream ;; (first (concatenated-stream-streams stream)))) ;; (t ;; (if (input-stream-p stream) ;; stream ;; (error "Stream ~S is not an input-stream." stream))))) ;; ;; ;; (defun stream-output-stream (stream) ;; " ;; RETURN: An output-stream. ;; " ;; (etypecase stream ;; (echo-stream (echo-stream-output-stream stream)) ;; (two-way-stream (two-way-stream-output-stream stream)) ;; (synonym-stream (stream-output-stream ;; (symbol-value (synonym-stream-symbol stream)))) ;; (t ;; (if (output-stream-p stream) ;; stream ;; (error "Stream ~S is not an output-stream." stream))))) (defun bare-stream (stream &key (direction :output)) " RETURN: A stream or a list of streams that are not compound streams (and therefore usable by #+clisp SOCKET:SOCKET-STATUS). " (etypecase stream #-mocl (echo-stream (ecase direction (:output (bare-stream (echo-stream-output-stream stream) :direction direction)) (:input (bare-stream (echo-stream-input-stream stream) :direction direction)))) #-mocl (two-way-stream (ecase direction (:output (bare-stream (two-way-stream-output-stream stream) :direction direction)) (:input (bare-stream (two-way-stream-input-stream stream) :direction direction)))) #-mocl (synonym-stream (bare-stream (symbol-value (synonym-stream-symbol stream)) :direction direction)) #-mocl (broadcast-stream (remove-if-not (lambda (stream) (ecase direction (:output (output-stream-p stream)) (:input (input-stream-p stream)))) (mapcar (lambda (stream) (bare-stream stream :direction direction)) (broadcast-stream-streams stream)))) (stream stream))) ;;---------------------------------------------------------------------- (defgeneric bvstream-position (bvstream position) (:documentation "Set the position of the BVSTREAM.")) (defgeneric bvstream-write-byte (bvstream byte) (:documentation "Write a byte to the BVSTREAM.")) (defgeneric bvstream-read-byte (bvstream) (:documentation "Read a byte from the BVSTREAM.")) (defclass bvstream-out () ((bytes :reader get-bytes :writer set-bytes :accessor byte-vector :initform (make-array '(1024) :element-type '(unsigned-byte 8) :adjustable t :fill-pointer 0) :initarg :bytes)) (:documentation "An output byte vector stream.")) (defmethod bvstream-position ((self bvstream-out) position) (if position (setf (fill-pointer (byte-vector self)) (min (array-dimension (byte-vector self) 0) (max 0 position))) (fill-pointer (byte-vector self)))) (defmethod bvstream-write-byte ((self bvstream-out) (byte integer)) (vector-push-extend (ldb (byte 8 0) byte) (byte-vector self) (array-dimension (byte-vector self) 0))) (defmacro with-output-to-byte-vector ((var &optional byte-vector-form &key element-type) &body body) " DO: Execute the BODY with VAR bound to an output byte vector stream. If BYTE-VECTOR-FORM is given it should produce a byte vector with a fill-pointer where the bytes written to the bvstream are stored. ELEMENT-TYPE: The type of bytes. If BYTE-VECTOR-FORM is nil, one can choose a different element-type for the byte vector. RETURN: The byte vector written. " `(let ((,var (make-instance 'bvstream-out ,@(cond (byte-vector-form `(:bytes ,byte-vector-form)) (element-type `(:bytes (make-array '(1024) :element-type ,element-type :adjustable t :fill-pointer 0))))))) (let ((,var ,var)) ,@body) (get-bytes ,var))) (defclass bvstream-in () ((bytes :reader get-bytes :writer set-bytes :accessor byte-vector :initarg :bytes) (position :reader get-position :accessor bis-position :initarg :position :initform 0) (end :initarg :end :initform nil)) (:documentation "An input byte vector stream.")) (defmethod initialize-instance ((self bvstream-in) &rest args) (declare (ignore args)) (call-next-method) (let ((len (length (byte-vector self)))) (setf (slot-value self 'end) (if (slot-value self 'end) (min (slot-value self 'end) len) len) (bis-position self) (max 0 (min (bis-position self) len)))) self) (defmethod bvstream-position ((self bvstream-in) position) (if position (setf (bis-position self) (min (bis-position self) (max 0 position))) (bis-position self))) (defmethod bvstream-read-byte ((self bvstream-in)) (if (< (bis-position self) (slot-value self 'end)) (prog1 (aref (get-bytes self) (bis-position self)) (incf (bis-position self))) :eof)) (defmacro with-input-from-byte-vector ((var byte-vector &key index start end) &body body) " DO: Execute the BODY with VAR bound to an input byte vector stream reading bytes from the BYTE-VECTOR, from START to END. If INDEX is given it should be a place into which the last position is stored. RETURN: The last position. " `(let ((,var (make-instance 'bvstream-in :bytes ,byte-vector ,@(when start `((:position ,start))) ,@(when end `((:end ,end)))))) (let ((,var ,var)) ,@body) ,(when index `(setf ,index (get-position ,var))) (get-position ,var))) ;;;; THE END ;;;;
15,834
Common Lisp
.lisp
355
36.284507
103
0.592566
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
763c57ed88e0cbb694f8bbe27979541d73fa06a2e46246903e406448d5a51dbc
5,117
[ -1 ]
5,118
sequence-test.lisp
informatimago_lisp/common-lisp/cesarum/sequence-test.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: sequence-test.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Tests sequence.lisp. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2021-05-15 <PJB> Added test/split-sequence-if ;;;; 2015-02-25 <PJB> Extracted from sequence.lisp. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2021 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SEQUENCE.TEST" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SIMPLE-TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SEQUENCE") (:export "TEST/ALL")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SEQUENCE.TEST") (define-test test/replace-subseq () (let ((*standard-output* (make-broadcast-stream))) (let ((str (make-array 10 :adjustable t :element-type 'character :initial-contents "abcdefghij"))) (print str) (assert-true (string= "abc123ghij" (print (replace-subseq "123" str 3 6)))) (assert-true (string= "abcABCij" (print (replace-subseq "ABC" str 3 8)))) (assert-true (string= "abc12345ij" (print (replace-subseq "12345" str 3 6)))) (assert-true (string= "78912345ij" (print (replace-subseq "789" str 0 3)))) (assert-true (string= "7891234501" (print (replace-subseq "01" str 8)))) (assert-true (string= "78912301" (print (replace-subseq "" str 6 8)))) (assert-true (string= "7891230123" (print (replace-subseq "23" str (length str))))) (assert-true (string= "567891230123" (print (replace-subseq "56" str 0 0)))) (assert-true (string= "123" (print (replace-subseq "123" str 0)))) (assert-true (string= "hello" (print (replace-subseq "hello" "" 0)))) (assert-true (string= "" (print (replace-subseq "" "hello" 0))))) (let ((str (list 'a 'b 'c 'd 'e 'f 'g 'h 'i 'j))) (print str) (assert-true (equal '(a b c 1 2 3 g h i j) (print (replace-subseq '(1 2 3) str 3 6)))) (assert-true (equal '(a b c A B C i j) (print (replace-subseq '(a b c) str 3 8)))) (assert-true (equal '(a b c 1 2 3 4 5 i j) (print (replace-subseq '(1 2 3 4 5) str 3 6)))) (assert-true (equal '(7 8 9 1 2 3 4 5 i j) (print (replace-subseq #(7 8 9) str 0 3)))) (assert-true (equal '(7 8 9 1 2 3 4 5 0 1) (print (replace-subseq #(0 1) str 8)))) (assert-true (equal '(7 8 9 1 2 3 0 1) (print (replace-subseq "" str 6 8)))) (assert-true (equal '(7 8 9 1 2 3 0 1 2 3) (print (replace-subseq #(2 3) str (length str))))) (assert-true (equal '(5 6 7 8 9 1 2 3 0 1 2 3) (print (replace-subseq '(5 6) str 0 0)))) (assert-true (equal '(1 2 3) (print (replace-subseq '(1 2 3) str 0)))) (assert-true (equal (coerce "hello" 'list) (print (replace-subseq "hello" '() 0)))) (assert-true (equal '() (print (replace-subseq "" '(1 2 3) 0)))))) (assert-true (nth-value 1 (ignore-errors (replace-subseq "abc" "def" -1 2)))) (assert-true (nth-value 1 (ignore-errors (replace-subseq "abc" "def" 1 4)))) (assert-true (nth-value 1 (ignore-errors (replace-subseq "abc" "def" 2 1)))) (assert-true (nth-value 1 (ignore-errors (replace-subseq "abc" "def" -2 4))))) (define-test test/group-by () (assert-true (equalp (group-by '() 3) '())) (assert-true (equalp (group-by '(1) 3) '((1)))) (assert-true (equalp (group-by '(1 2) 3) '((1 2)))) (assert-true (equalp (group-by '(1 2 3) 3) '((1 2 3)))) (assert-true (equalp (group-by '(1 2 3 4) 3) '((1 2 3) (4)))) (assert-true (equalp (group-by '(1 2 3 4 5) 3) '((1 2 3) (4 5)))) (assert-true (equalp (group-by '(1 2 3 4 5 6) 3) '((1 2 3) (4 5 6)))) (assert-true (equalp (group-by '(1 2 3 4 5 6 7) 3) '((1 2 3) (4 5 6) (7)))) (assert-true (equalp (group-by '(1 2 3 4 5 6 7 8) 3) '((1 2 3) (4 5 6) (7 8)))) (assert-true (equalp (group-by #() 3) '())) (assert-true (equalp (group-by #(1) 3) '(#(1)))) (assert-true (equalp (group-by #(1 2) 3) '(#(1 2)))) (assert-true (equalp (group-by #(1 2 3) 3) '(#(1 2 3)))) (assert-true (equalp (group-by #(1 2 3 4) 3) '(#(1 2 3) #(4)))) (assert-true (equalp (group-by #(1 2 3 4 5) 3) '(#(1 2 3) #(4 5)))) (assert-true (equalp (group-by #(1 2 3 4 5 6) 3) '(#(1 2 3) #(4 5 6)))) (assert-true (equalp (group-by #(1 2 3 4 5 6 7) 3) '(#(1 2 3) #(4 5 6) #(7)))) (assert-true (equalp (group-by #(1 2 3 4 5 6 7 8) 3) '(#(1 2 3) #(4 5 6) #(7 8))))) (define-test test/parse-sequence-type () (check equal (multiple-value-list (parse-sequence-type 'list)) '(list t nil)) (check equal (multiple-value-list (parse-sequence-type 'vector)) '(vector t nil)) (check equal (multiple-value-list (parse-sequence-type '(vector))) '(vector t nil)) (check equal (multiple-value-list (parse-sequence-type '(vector *))) '(vector t nil)) (check equal (multiple-value-list (parse-sequence-type '(vector * 42))) '(vector t 42)) (check equal (multiple-value-list (parse-sequence-type '(vector integer))) '(vector integer nil)) (check equal (multiple-value-list (parse-sequence-type '(vector integer 42))) '(vector integer 42)) (expect-condition 'error (parse-sequence-type 'array)) (expect-condition 'error (parse-sequence-type '(array))) (expect-condition 'error (parse-sequence-type '(array *))) (expect-condition 'error (parse-sequence-type '(array * 42))) (expect-condition 'error (parse-sequence-type '(array * 42))) (check equal (multiple-value-list (parse-sequence-type '(array * 1))) '(array t nil)) (check equal (multiple-value-list (parse-sequence-type '(array integer 1))) '(array integer nil)) (check equal (multiple-value-list (parse-sequence-type '(array * (42)))) '(array t 42)) (check equal (multiple-value-list (parse-sequence-type '(array integer (42)))) '(array integer 42)) (expect-condition 'error (parse-sequence-type '(array integer (1 2))))) (define-test test/concatenate-sequences () (equalp (concatenate-sequences 'list '((1 2 3) (4 5 6) (7 8 9))) '(1 2 3 4 5 6 7 8 9)) (equalp (concatenate-sequences 'list #((1 2 3) (4 5 6) (7 8 9))) '(1 2 3 4 5 6 7 8 9)) (equalp (concatenate-sequences 'vector '((1 2 3) (4 5 6) (7 8 9))) #(1 2 3 4 5 6 7 8 9)) (equalp (concatenate-sequences 'vector #((1 2 3) (4 5 6) (7 8 9))) #(1 2 3 4 5 6 7 8 9)) (equalp (concatenate-sequences '(array * 1) '((1 2 3) (4 5 6) (7 8 9))) #(1 2 3 4 5 6 7 8 9)) (equalp (concatenate-sequences '(array * 1) #((1 2 3) (4 5 6) (7 8 9))) #(1 2 3 4 5 6 7 8 9)) (equalp (concatenate-sequences 'list '(#(1 2 3) (4 5 6) #(7 8 9))) '(1 2 3 4 5 6 7 8 9)) (equalp (concatenate-sequences 'list #(#(1 2 3) (4 5 6) #(7 8 9))) '(1 2 3 4 5 6 7 8 9)) (equalp (concatenate-sequences 'vector '(#(1 2 3) (4 5 6) #(7 8 9))) #(1 2 3 4 5 6 7 8 9)) (equalp (concatenate-sequences 'vector #(#(1 2 3) (4 5 6) #(7 8 9))) #(1 2 3 4 5 6 7 8 9)) (equalp (concatenate-sequences '(array * 1) '(#(1 2 3) (4 5 6) #(7 8 9))) #(1 2 3 4 5 6 7 8 9)) (equalp (concatenate-sequences '(array * 1) #(#(1 2 3) (4 5 6) #(7 8 9))) #(1 2 3 4 5 6 7 8 9)) (expect-condition 'error (concatenate-sequences '(array *) #(#(1 2 3) (4 5 6) #(7 8 9))))) (defun as-vector (sequence) (coerce sequence 'vector)) (defun as-list (sequence) (coerce sequence 'list)) (define-test test/prefixp () (loop :for pf :in '(identity as-vector as-list) :do (loop :for sf :in '(identity as-vector as-list) :do (loop :for (p s) :in '(("" "") ("" "HELLO") ("HELLO" "HELLO") ("HELLO" "HELLO WORLD")) :do (assert-true (prefixp (funcall pf p) (funcall sf s)) (pf p sf s) "applicable methods = ~S" (compute-applicable-methods (function prefixp) (list (funcall pf p) (funcall sf s))))) (loop :for (p s) :in '(("HELLO" "HELL") ("HELLO" "SAY HELLO WORLD") ("HELLO" "SAY HELLO")) :do (assert-false (prefixp (funcall pf p) (funcall sf s)) (pf p sf s) "applicable methods = ~S" (compute-applicable-methods (function prefixp) (list (funcall pf p) (funcall sf s)))))))) (define-test test/suffixp () (loop :for pf :in '(identity as-vector as-list) :do (loop :for sf :in '(identity as-vector as-list) :do (loop :for (p s) :in '(("" "") ("" "HELLO") ("HELLO" "HELLO") ("WORLD" "HELLO WORLD")) :do (assert-true (suffixp (funcall pf p) (funcall sf s)) (pf p sf s) "applicable methods = ~S" (compute-applicable-methods (function suffixp) (list (funcall pf p) (funcall sf s))))) (loop :for (p s) :in '(("HELLO" "ELLO") ("HELLO" "SAY HELLO WORLD") ("HELLO" "SAY WORLD")) :do (assert-false (suffixp (funcall pf p) (funcall sf s)) (pf p sf s) "applicable methods = ~S" (compute-applicable-methods (function suffixp) (list (funcall pf p) (funcall sf s)))))))) (define-test test/split-sequence-if () (check equal (split-sequence-if (function digit-char-p) (coerce "aaaa0bbb23ccc456dddd" 'list)) '((#\a #\a #\a #\a) (#\b #\b #\b) nil (#\c #\c #\c) nil nil (#\d #\d #\d #\d))) (check equal (split-sequence-if (function digit-char-p) (coerce "aaaa0bbb23ccc456dddd" 'list) :remove-empty-subseqs t) '((#\a #\a #\a #\a) (#\b #\b #\b) (#\c #\c #\c) (#\d #\d #\d #\d))) (check equal (split-sequence-if (function digit-char-p) "aaaa0bbb23ccc456dddd") '("aaaa" "bbb" "" "ccc" "" "" "dddd")) (check equal (split-sequence-if (function digit-char-p) "aaaa0bbb23ccc456dddd" :remove-empty-subseqs t) '("aaaa" "bbb" "ccc" "dddd")) (check equal (split-sequence-if (function digit-char-p) "12aa45bb" :remove-empty-subseqs nil) '("" "" "aa" "" "bb")) (check equal (split-sequence-if (function digit-char-p) "12aa45bb" :remove-empty-subseqs t) '("aa" "bb")) (check equal (split-sequence-if (function digit-char-p) "12aa45" :remove-empty-subseqs nil) '("" "" "aa" "" "")) (check equal (split-sequence-if (function digit-char-p) "12aa45" :remove-empty-subseqs t) '("aa"))) (define-test test/split-sequence-on-indicator () (check equal (split-sequence-on-indicator "AAAbbbCCCddd" (lambda (a b) (or (and (upper-case-p a) (lower-case-p b)) (and (upper-case-p b) (lower-case-p a))))) '("AAA" "bbb" "CCC" "ddd")) (check equal (split-sequence-on-indicator "AAAbbbCCCddd" (lambda (a b) (and (upper-case-p b) (lower-case-p a)))) '("AAAbbb" "CCCddd")) (check equal (split-sequence-on-indicator "Hello World" (constantly t)) '("H" "e" "l" "l" "o" " " "W" "o" "r" "l" "d")) (check equal (split-sequence-on-indicator "A" (constantly t)) '("A")) (check equal (split-sequence-on-indicator "" (constantly t)) '())) (define-test test/mapconcat () (check equal (mapconcat (function identity) (list "hello" "world" #(#\f #\o #\o #\b #\a #\r)) " ") "hello world foobar") (check equal (mapconcat (lambda (seq) (map 'vector (function char-upcase) seq)) (vector "hello" "world" #(#\f #\o #\o #\b #\a #\r)) "+/-") "HELLO+/-WORLD+/-FOOBAR") (check equalp (mapconcat (lambda (seq) (map 'list (lambda (x) (* 2 x)) seq)) (vector #(11 12 13 14) '(15 16 17 18) '(21 22 23 24) #(25 26 27 28)) #(0 0)) #(22 24 26 28 0 0 30 32 34 36 0 0 42 44 46 48 0 0 50 52 54 56)) (check equalp (mapconcat (lambda (seq) (map 'list (lambda (x) (* 2 x)) seq)) #() #(0 0)) #*) (check equalp (mapconcat (lambda (seq) (map 'list (lambda (x) (* 2 x)) seq)) #() #(0 -1 0)) #()) (check equalp (mapconcat (lambda (seq) (map 'list (lambda (x) (* 2 x)) seq)) #() "") #()) (check equalp (mapconcat (lambda (seq) (map 'vector (function code-char) seq)) #((65 66 67 68) (71 72 73 74) (75 76 77 79)) "--") "ABCD--GHIJ--KLMO")) (define-test test/all () (test/replace-subseq) (test/group-by) (test/parse-sequence-type) (test/concatenate-sequences) (test/prefixp) (test/suffixp) (test/split-sequence-if) (test/split-sequence-on-indicator) (test/mapconcat)) ;;;; THE END ;;;;
15,010
Common Lisp
.lisp
245
49.567347
120
0.51734
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
06da1cbb77fd5cc69420376c0b3312839eb75e3b0a68d617331a4496cab05565
5,118
[ -1 ]
5,119
update-iso3166.lisp
informatimago_lisp/common-lisp/cesarum/update-iso3166.lisp
;;;; -*- mode:lisp; coding:utf-8 -*- (defparameter new '( ( 004 afg af t "Afghanistan") ( 248 ala ax t "Áland Islands") ( 008 alb al t "Albania") ( 012 dza dz t "Algeria") ( 016 asm as t "American Samoa") ( 020 and ad t "Andorra") ( 024 ago ao t "Angola") ( 660 aia ai t "Anguilla") ( 010 ata aq t "Antarctica") ( 028 atg ag t "Antigua and Barbuda") ( 032 arg ar t "Argentina") ( 051 arm am t "Armenia") ( 533 abw aw t "Aruba") ( 036 aus au t "Australia") ( 040 aut at t "Austria") ( 031 aze az t "Azerbaijan") ( 044 bhs bs t "Bahamas") ( 048 bhr bh t "Bahrain") ( 050 bgd bd t "Bangladesh") ( 052 brb bb t "Barbados") ( 112 blr by t "Belarus") ( 056 bel be t "Belgium") ( 084 blz bz t "Belize") ( 204 ben bj t "Benin") ( 060 bmu bm t "Bermuda") ( 064 btn bt t "Bhutan") ( 068 bol bo t "Bolivia") ( 070 bih ba t "Bosnia and Herzegovina") ( 072 bwa bw t "Botswana") ( 074 bvt bv t "Bouvet Island") ( 076 bra br t "Brazil") ( 092 iot io t "British Indian Ocean Territory") ( 096 brn bn t "Brunei Darussalam") ( 100 bgr bg t "Bulgaria") ( 854 bfa bf t "Burkina Faso") ( 108 bdi bi t "Burundi") ( 116 khm kh t "Cambodia") ( 120 cmr cm t "Cameroon") ( 124 can ca t "Canada") ( 132 cpv cv t "Cape Verde") ( 136 cym ky t "Cayman Islands") ( 140 caf cf t "Central African Republic") ( 148 tcd td t "Chad") ( 152 chl cl t "Chile") ( 156 chn cn t "China, mainland") ( 162 cxr cx t "Christmas Island") ( 166 cck cc t "Cocos (Keeling) Islands") ( 170 col co t "Colombia") ( 174 com km t "Comoros") ( 178 cog cg t "Congo, Republic of the ") ( 180 cod cd t "Congo, The Democratic Republic Of The") ( 184 cok ck t "Cook Islands") ( 188 cri cr t "Costa Rica") ( 384 civ ci t "Côte d'Ivoire") ( 191 hrv hr t "Croatia") ( 192 cub cu t "Cuba") ( 196 cyp cy t "Cyprus") ( 203 cze cz t "Czech Republic") ( 208 dnk dk t "Denmark") ( 262 dji dj t "Djibouti") ( 212 dma dm t "Dominica") ( 214 dom do t "Dominican Republic") ( 218 ecu ec t "Ecuador") ( 818 egy eg t "Egypt") ( 222 slv sv t "El Salvador") ( 226 gnq gq t "Equatorial Guinea") ( 232 eri er t "Eritrea") ( 233 est ee t "Estonia") ( 231 eth et t "Ethiopia") ( 238 flk fk t "Falkland Islands") ( 234 fro fo t "Faroe Islands") ( 242 fji fj t "Fiji") ( 246 fin fi t "Finland") ( 250 fra fr t "France") ( 254 guf gf t "French Guiana") ( 258 pyf pf t "French Polynesia") ( 260 atf tf t "French Southern Territories") ( 266 gab ga t "Gabon") ( 270 gmb gm t "Gambia") ( 268 geo ge t "Georgia") ( 276 deu de t "Germany") ( 288 gha gh t "Ghana") ( 292 gib gi t "Gibraltar") ( 300 grc gr t "Greece") ( 304 grl gl t "Greenland") ( 308 grd gd t "Grenada") ( 312 glp gp t "Guadeloupe") ( 316 gum gu t "Guam") ( 320 gtm gt t "Guatemala") ( 324 gin gn t "Guinea") ( 624 gnb gw t "Guinea-Bissau") ( 328 guy gy t "Guyana") ( 332 hti ht t "Haiti") ( 334 hmd hm t "Heard Island and McDonald Islands") ( 336 vat va t "Vatican City State") ( 340 hnd hn t "Honduras") ( 344 hkg hk t "Hong Kong") ( 348 hun hu t "Hungary") ( 352 isl is t "Iceland") ( 356 ind in t "India") ( 360 idn id t "Indonesia") ( 364 irn ir t "Iran, Islamic Republic of") ( 368 irq iq t "Iraq") ( 372 irl ie t "Ireland, Republic of") ( 376 isr il t "Israel") ( 380 ita it t "Italy") ( 388 jam jm t "Jamaica") ( 392 jpn jp t "Japan") ( 400 jor jo t "Jordan") ( 398 kaz kz t "Kazakhstan") ( 404 ken ke t "Kenya") ( 296 kir ki t "Kiribati") ( 408 prk kp t "Korea, Democratic People's Republic of") ( 410 kor kr t "Korea, Republic of") ( 414 kwt kw t "Kuwait") ( 417 kgz kg t "Kyrgyzstan") ( 418 lao la t "Lao People's Democratic Republic") ( 428 lva lv t "Latvia") ( 422 lbn lb t "Lebanon") ( 426 lso ls t "Lesotho") ( 430 lbr lr t "Liberia") ( 434 lby ly t "Libyan Arab Jamahiriya") ( 438 lie li t "Liechtenstein") ( 440 ltu lt t "Lithuania") ( 442 lux lu t "Luxembourg") ( 446 mac mo t "Macao") ( 807 mkd mk t "Macedonia, The Former Yugoslav Republic of") ( 450 mdg mg t "Madagascar") ( 454 mwi mw t "Malawi") ( 458 mys my t "Malaysia") ( 462 mdv mv t "Maldives") ( 466 mli ml t "Mali") ( 470 mlt mt t "Malta") ( 584 mhl mh t "Marshall Islands") ( 474 mtq mq t "Martinique") ( 478 mrt mr t "Mauritania") ( 480 mus mu t "Mauritius") ( 175 myt yt t "Mayotte") ( 484 mex mx t "Mexico") ( 583 fsm fm t "Micronesia, Federated States of") ( 498 mda md t "Moldova, Republic of") ( 492 mco mc t "Monaco") ( 496 mng mn t "Mongolia") ( 500 msr ms t "Montserrat") ( 504 mar ma t "Morocco") ( 508 moz mz t "Mozambique") ( 104 mmr mm t "Myanmar") ( 516 nam na t "Namibia") ( 520 nru nr t "Nauru") ( 524 npl np t "Nepal") ( 528 nld nl t "Netherlands") ( 530 ant an t "Netherlands Antilles") ( 540 ncl nc t "New Caledonia") ( 554 nzl nz t "New Zealand") ( 558 nic ni t "Nicaragua") ( 562 ner ne t "Niger") ( 566 nga ng t "Nigeria") ( 570 niu nu t "Niue") ( 574 nfk nf t "Norfolk Island") ( 580 mnp mp t "Northern Mariana Islands") ( 578 nor no t "Norway") ( 512 omn om t "Oman") ( 586 pak pk t "Pakistan") ( 585 plw pw t "Palau") ( 275 pse ps t "Palestinian Territory, Occupied") ( 591 pan pa t "Panama") ( 598 png pg t "Papua New Guinea") ( 600 pry py t "Paraguay") ( 604 per pe t "Peru") ( 608 phl ph t "Philippines") ( 612 pcn pn t "Pitcairn") ( 616 pol pl t "Poland") ( 620 prt pt t "Portugal") ( 630 pri pr t "Puerto Rico") ( 634 qat qa t "Qatar") ( 638 reu re t "Réunion") ( 642 rou ro t "Romania") ( 643 rus ru t "Russian Federation") ( 646 rwa rw t "Rwanda") ( 654 shn sh t "Saint Helena") ( 659 kna kn t "Saint Kitts and Nevis") ( 662 lca lc t "Saint Lucia") ( 666 spm pm t "Saint Pierre and Miquelon") ( 670 vct vc t "Saint Vincent and the Grenadines") ( 882 wsm ws t "Samoa") ( 674 smr sm t "San Marino") ( 678 stp st t "Sáo Tomó and Príncipe") ( 682 sau sa t "Saudi Arabia") ( 686 sen sn t "Senegal") ( 891 scg cs t "Serbia and Montenegro") ( 690 syc sc t "Seychelles") ( 694 sle sl t "Sierra Leone") ( 702 sgp sg t "Singapore") ( 703 svk sk t "Slovakia") ( 705 svn si t "Slovenia") ( 090 slb sb t "Solomon Islands") ( 706 som so t "Somalia") ( 710 zaf za t "South Africa") ( 239 sgs gs t "South Georgia and the South Sandwich Islands") ( 724 esp es t "Spain") ( 144 lka lk t "Sri Lanka") ( 736 sdn sd t "Sudan") ( 740 sur sr t "Suriname") ( 744 sjm sj t "Svalbard and Jan Mayen") ( 748 swz sz t "Swaziland") ( 752 swe se t "Sweden") ( 756 che ch t "Switzerland") ( 760 syr sy t "Syrian Arab Republic") ( 158 twn tw t "Taiwan (Republic of China)") ( 762 tjk tj t "Tajikistan") ( 834 tza tz t "Tanzania, United Republic Of") ( 764 tha th t "Thailand") ( 626 tls tl t "Timor-Leste") ( 768 tgo tg t "Togo") ( 772 tkl tk t "Tokelau") ( 776 ton to t "Tonga") ( 780 tto tt t "Trinidad and Tobago") ( 788 tun tn t "Tunisia") ( 792 tur tr t "Turkey") ( 795 tkm tm t "Turkmenistan") ( 796 tca tc t "Turks and Caicos Islands") ( 798 tuv tv t "Tuvalu") ( 800 uga ug t "Uganda") ( 804 ukr ua t "Ukraine") ( 784 are ae t "United Arab Emirates") ( 826 gbr gb t "United Kingdom") ( 840 usa us t "United States") ( 581 umi um t "United States Minor Outlying Islands") ( 858 ury uy t "Uruguay") ( 860 uzb uz t "Uzbekistan") ( 548 vut vu t "Vanuatu") ( 862 ven ve t "Venezuela") ( 704 vnm vn t "Viet Nam") ( 092 vgb vg t "Virgin Islands, British") ( 850 vir vi t "Virgin Islands, U.S.") ( 876 wlf wf t "Wallis and Futuna") ( 732 esh eh t "Western Sahara") ( 887 yem ye t "Yemen") ( 894 zmb zm t "Zambia") ( 716 zwe zw t "Zimbabwe") ) );;new (defparameter +countries+ '( ( cd nil "La République Démocratique Du Congo" "The Democratic Republic Of The Congo") ( mk nil "L'Ex-République Yougoslave De Macédoine" "The Former Yugoslav Republic Of Macedonia") ( ps nil "Territoire Palestinien Occupé" "Occupied Palestinian Territory") ( tl nil "Timor-Leste" "Timor-Leste") ( ad t "Andorre" "Andorra") ( ae t "Émirats Arabes Unis" "United Arab Emirates") ( af t "Afghanistan" "Afghanistan") ( ag t "Antigua et Barbuda" "Antigua and Barbuda") ( ai t "Anguilla" "Anguilla") ( al t "Albanie" "Albania") ( am t "Arménie" "Armenia") ( an t "Antilles Néerlandaises" "Netherlands Antilles") ( ao t "Angola" "Angola") ( aq t "Antarctique" "Antarctica") ( ar t "Argentine" "Argentina") ( as t "Samoa Américaines" "American Samoa") ( at t "Autriche" "Austria") ( au t "Australie" "Australia") ( aw t "Aruba" "Aruba") ( az t "Azerbaïdjan" "Azerbaijan") ( ba t "Bosnie-Herzégovine" "Bosnia and Herzegovina") ( bb t "Barbade" "Barbados") ( bd t "Bangladesh" "Bangladesh") ( be t "Belgique" "Belgium") ( bf t "Burkina Faso" "Burkina Faso") ( bg t "Bulgarie" "Bulgaria") ( bh t "Bahreïn" "Bahrain") ( bi t "Burundi" "Burundi") ( bj t "Bénin" "Benin") ( bm t "Bermudes" "Bermuda") ( bn t "Brunéi Darussalam" "Brunei Darussalam") ( bo t "Bolivie" "Bolivia") ( br t "Brésil" "Brazil") ( bs t "Bahamas" "Bahamas") ( bt t "Bhoutan" "Bhutan") ( bu nil "Burma" "Burma") ( bv t "Île Bouvet" "Bouvet Island") ( bw t "Botswana" "Botswana") ( by t "Bélarus" "Belarus") ( bz t "Belize" "Belize") ( ca t "Canada" "Canada") ( cc t "Îles Cocos ( Keeling)" "Cocos ( Keeling) Islands") ( cf t "République Centrafricaine" "Central African Republic") ( cg nil "Congo" "Congo") ( ch t "Suisse" "Switzerland") ( ci t "Côte D'Ivoire" "Ivory Coast") ( ck t "Îles Cook" "Cook Islands") ( cl t "Chili" "Chile") ( cm t "Cameroun" "Cameroon") ( cn t "Chine" "China") ( co t "Colombie" "Colombia") ( cr t "Costa Rica" "Costa Rica") ( cs nil "Serbie et Monténégro" "Serbia and Montenegro") ( cu t "Cuba" "Cuba") ( cv t "Cap-Vert" "Cape Verde") ( cx t "Île Christmas" "Christmas Island") ( cy t "Chypre" "Cyprus") ( cz t "République Tchèque" "Czech Republic") ( dd nil "République Démocratique d'Allemagne" "German Democratic Republic") ( de t "Allemagne" "Germany") ( dj t "Djibouti" "Djibouti") ( dk t "Danemark" "Denmark") ( dm t "Dominique" "Dominica") ( do t "République Dominicaine" "Dominican Republic") ( dz t "Algérie" "Algeria") ( ec t "Équateur" "Ecuador") ( ee t "Estonie" "Estonia") ( eg t "Égypte" "Egypt") ( eh t "Sahara Occidental" "Western Sahara") ( er t "Érythrée" "Eritrea") ( es t "Espagne" "Spain") ( et t "Éthiopie" "Ethiopia") ( fi t "Finlande" "Finland") ( fj t "Fidji" "Fiji") ( fk t "Îles Malouines" "Falkland Islands") ( fm t "États Fédérés De Micronésie" "Federated States Of Micronesia") ( fo t "Îles Féroé" "Faroe Islands") ( fr t "France" "France") ( fx t "France Métropolitaine" "Metropolitan France") ( ga t "Gabon" "Gabon") ( gb t "Royaume-Uni" "United Kingdom") ( gd t "Grenade" "Grenada") ( ge t "Géorgie" "Georgia") ( gf t "Guyane Française" "French Guiana") ( gh t "Ghana" "Ghana") ( gi t "Gibraltar" "Gibraltar") ( gl t "Groenland" "Greenland") ( gm t "Gambie" "Gambia") ( gn t "Guinée" "Guinea") ( gp t "Guadeloupe" "Guadeloupe") ( gq t "Guinée Équatoriale" "Equatorial Guinea") ( gr t "Grèce" "Greece") ( gs t "Géorgie Du Sud et Les Îles Sandwich Du Sud" "South Georgia and the South Sandwich Islands") ( gt t "Guatemala" "Guatemala") ( gu t "Guam" "Guam") ( gw t "Guinée-Bissau" "Guinea-Bissau") ( gy t "Guyana" "Guyana") ( hk t "Hong-Kong" "Hong Kong") ( hm t "Île Mcdonald et îles Heard" "Heard Island and Mcdonald Islands") ( hn t "Honduras" "Honduras") ( hr t "Croatie" "Croatia") ( ht t "Haïti" "Haiti") ( hu t "Hongrie" "Hungary") ( id t "Indonésie" "Indonesia") ( ie t "Irlande" "Ireland") ( il t "Israël" "Israel") ( in t "Inde" "India") ( io t "Territoire Britannique de l'Océan Indien" "British Indian Ocean Territory") ( iq t "Iraq" "Iraq") ( ir t "République Islamique D' Iran" "Islamic Republic of Iran") ( is t "Islande" "Iceland") ( it t "Italie" "Italy") ( jm t "Jamaïque" "Jamaica") ( jo t "Jordanie" "Jordan") ( jp t "Japon" "Japan") ( ke t "Kenya" "Kenya") ( kg t "Kirghizistan" "Kyrgyzstan") ( kh t "Cambodge" "Cambodia") ( ki t "Kiribati" "Kiribati") ( km t "Comores" "Comoros") ( kn t "Saint-Kitts et Nevis" "Saint Kitts and Nevis") ( kp t "République Populaire Démocratique De Corée" "Democratic People's Republic of Korea") ( kr t "République De Corée" "Republic of Korea") ( kw t "Koweït" "Kuwait") ( ky t "Îles Caïmanes" "Cayman Islands") ( kz t "Kazakhstan" "Kazakhstan") ( la t "République Démocratique Populaire Lao" "Lao People's Democratic Republic") ( lb t "Liban" "Lebanon") ( lc t "Sainte-Lucie" "Saint Lucia") ( li t "Liechtenstein" "Liechtenstein") ( lk t "Sri Lanka" "Sri Lanka") ( lr t "Libéria" "Liberia") ( ls t "Lesotho" "Lesotho") ( lt t "Lituanie" "Lithuania") ( lu t "Luxembourg" "Luxembourg") ( lv t "Lettonie" "Latvia") ( ly t "Jamahiriya Arabe Libyenne" "Libyan Arab Jamahiriya") ( ma t "Maroc" "Morocco") ( mc t "Monaco" "Monaco") ( md t "République De Moldova" "Republic of Moldova") ( mg t "Madagascar" "Madagascar") ( mh t "Îles Marshall" "Marshall Islands") ( ml t "Mali" "Mali") ( mm t "Myanmar" "Myanmar") ( mn t "Mongolie" "Mongolia") ( mo t "Macao" "Macao" "Macau") ( mp t "Îles Mariannes Du Nord" "Northern Mariana Islands") ( mq t "Martinique" "Martinique") ( mr t "Mauritanie" "Mauritania") ( ms t "Montserrat" "Montserrat" "Monserrat") ( mt t "Malte" "Malta") ( mu t "Maurice" "Mauritius") ( mv t "Maldives" "Maldives") ( mw t "Malawi" "Malawi") ( mx t "Mexique" "Mexico") ( my t "Malaisie" "Malaysia") ( mz t "Mozambique" "Mozambique") ( na t "Namibie" "Namibia" "Nambia") ( nc t "Nouvelle-Calédonie" "New Caledonia") ( ne t "Niger" "Niger") ( nf t "Île Norfolk" "Norfolk Island") ( ng t "Nigéria" "Nigeria") ( ni t "Nicaragua" "Nicaragua") ( nl t "Pays-Bas" "Netherlands") ( no t "Norvège" "Norway") ( np t "Népal" "Nepal") ( nr t "Nauru" "Nauru") ( nt nil "Nil" "Nil" "Neutral Zone") ( nu t "Niué" "Niue") ( nz t "Nouvelle-Zélande" "New Zealand") ( om t "Oman" "Oman") ( pa t "Panama" "Panama") ( pe t "Pérou" "Peru") ( pf t "Polynésie Française" "French Polynesia") ( pg t "Papouasie-Nouvelle-Guinée" "Papua New Guinea") ( ph t "Philippines" "Philippines") ( pk t "Pakistan" "Pakistan") ( pl t "Pologne" "Poland") ( pm t "Saint-Pierre et Miquelon" "Saint Pierre and Miquelon") ( pn t "Pitcairn" "Pitcairn") ( pr t "Porto Rico" "Puerto Rico") ( pt t "Portugal" "Portugal") ( pw t "Palaos" "Palau") ( py t "Paraguay" "Paraguay") ( qa t "Qatar" "Qatar") ( re t "Réunion" "Reunion") ( ro t "Roumanie" "Romania") ( ru t "Fédération De Russie" "Russian Federation") ( rw t "Rwanda" "Rwanda") ( sa t "Arabie Saoudite" "Saudi Arabia") ( sb t "Îles Salomon" "Solomon Islands") ( sc t "Seychelles" "Seychelles") ( sd t "Soudan" "Sudan") ( se t "Suède" "Sweden") ( sg t "Singapour" "Singapore") ( sh t "Sainte-Hélène" "Saint Helena") ( si t "Slovénie" "Slovenia") ( sj t "Svalbard et île Jan Mayen" "Svalbard and Jan Mayen Islands") ( sk t "Slovaquie" "Slovakia") ( sl t "Sierra Leone" "Sierra Leone") ( sm t "Saint-Marin" "San Marino") ( sn t "Sénégal" "Senegal") ( so t "Somalie" "Somalia") ( sr t "Suriname" "Suriname") ( st t "Sao Tomé et Principe" "Sao Tome and Principe") ( su nil "Union des Républiques Socialistes Soviétiques" "Union of Soviet Socialist Republics") ( sv t "El Salvador" "El Salvador") ( sy t "République Arabe Syrienne" "Syrian Arab Republic") ( sz t "Swaziland" "Swaziland") ( tc t "Îles Turks et Caïques" "Turks and Caicos Islands") ( td t "Tchad" "Chad") ( tf t "Terres Australes Françaises" "French Southern Territories") ( tg t "Togo" "Togo") ( th t "Thaïlande" "Thailand") ( tj t "Tadjikistan" "Tajikistan") ( tk t "Tokelau" "Tokelau") ( tm t "Turkménistan" "Turkmenistan") ( tn t "Tunisie" "Tunisia") ( to t "Tonga" "Tonga") ( tp t "Timor Oriental" "East Timor") ( tr t "Turquie" "Turkey") ( tt t "Trinité et Tobago" "Trinidad and Tobago") ( tv t "Tuvalu" "Tuvalu") ( tw t "Province de Chine Taïwan" "Province of China Taiwan") ( tz t "République-Unie de Tanzanie" "United Republic of Tanzania") ( ua t "Ukraine" "Ukraine") ( ug t "Ouganda" "Uganda") ( um t "Îles Mineures Éloignées des États-Unis" "United States Minor Outlying Islands") ( us t "États-Unis" "United States of America") ( uy t "Uruguay" "Uruguay") ( uz t "Ouzbékistan" "Uzbekistan") ( va t "Saint-Siège ( État de La Cité Du Vatican)" "Holy See ( Vatican City State)") ( vc t "Saint-Vincent et Les Grenadines" "Saint Vincent and The Grenadines") ( ve t "Venezuela" "Venezuela") ( vg t "Îles Vierges Britanniques" "British Virgin Islands") ( vi t "Îles Vierges Des États-Unis" "United States Virgin Islands") ( vn t "Viet Nam" "Viet Nam") ( vu t "Vanuatu" "Vanuatu") ( wf t "Wallis Et Futuna" "Wallis and Futuna Islands") ( ws t "Samoa" "Samoa") ( yd nil "Yemen Démocratique" "Democratic Yemen") ( ye t "Yémen" "Yemen") ( yt t "Mayotte" "Mayotte") ( yu t "Yougoslavie" "Yugoslavia") ( za t "Afrique Du Sud" "South Africa") ( zm t "Zambie" "Zambia") ( zr t "Zaïre" "Zaire") ( zw t "Zimbabwe" "Zimbabwe") ( zz t "Pays inconnu ou non spécifié" "Unknown or unspecified country") ));;+COUNTRIES+ (defun merge-countries () (let ((newrest (copy-seq new))) (map nil (lambda (country) (let ((newc (car (member (first country) new :test (function eq) :key (function third))))) (apply (function format) t "( ~3,'0D ~3A ~2A ~3A ~%~S~%~S)~%" (if (null newc) (list 0 nil (first country) (second country) (third country) (fourth country)) (progn (setf newrest (delete newc newrest :test (function eq))) (if (string-equal (fifth newc) (fourth country)) (list (first newc) (second newc) (third newc) t (third country) (fourth country)) (list (first newc) (second newc) (third newc) t (third country) (concatenate 'string (fourth country) " ## " (fifth newc))))))))) +countries+) (map nil (lambda (newc) (apply (function format) t "( ~3,'0D ~3A ~2A ~3A ~%~S~%~S)~%" (list (first newc) (second newc) (third newc) t "" (fifth newc)))) newrest)));;merge-countries ;;;; update-iso3166.lisp -- 2004-03-16 16:50:09 -- pascal ;;;;
24,975
Common Lisp
.lisp
1,028
16.752918
77
0.481917
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
5888bf1f102ca7a6ade582c1a71681e9692c982662abf4a19fe84bfb71f3e9c0
5,119
[ -1 ]
5,120
time.lisp
informatimago_lisp/common-lisp/cesarum/time.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: time.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Provides a time more precise than GET-UNIVERSAL-TIME. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2015-12-05 <PJB> Extracted from Activity. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.TIME" (:use "COMMON-LISP") (:export "INITIALIZE-REAL-TIME-OFFSET" "GET-REAL-TIME" "GET-RUN-TIME" "CHRONO-TIME" "CHRONO-REAL-TIME" "CHRONO-RUN-TIME" "FORMAT-TIME" "*INTERNAL-TIME-UNIT*") (:documentation " This package provides two clocks more precise than GET-UNIVERSAL-TIME which has a 1 second resolution, using the INTERNAL-TIME-UNITS-PER-SECOND. ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.TIME") (defparameter *internal-time-unit* (coerce (/ internal-time-units-per-second) 'double-float) "The internal time slice, in seconds, as a DOUBLE-FLOAT.") (defvar *precise-real-time-offset* 0) (eval-when (:compile-toplevel :load-toplevel :execute) (defun initialize-real-time-offset () "This should be called once per POSIX process before GET-REAL-TIME." (setf *precise-real-time-offset* (loop :with now = (get-universal-time) :while (= now (get-universal-time)) :finally (return (- now (* (get-internal-real-time) *internal-time-unit*))))))) (defparameter *precise-real-time-offset* (initialize-real-time-offset) "Contains the number of seconds that must be added to: (/ (GET-INTERNAL-REAL-TIME) INTERNAL-TIME-UNITS-PER-SECOND) to get the current universal-time with the higher internal time precision.") (defun get-real-time () " RETURN: The universal-time (in seconds), offset by the internal-real-time fraction. " (+ *precise-real-time-offset* (* (get-internal-real-time) *internal-time-unit*))) (defun get-run-time () " RETURN: The run-time (in seconds). Run-time is not synchronized with real-time, since the process is scheduled by the kernel. " (* (get-internal-run-time) *internal-time-unit*)) (defun chrono-time* (thunk) " Call the THUNK. RETURN: the real-time, the run-time, followed by the results of THUNK. " (let* ((start-real (get-real-time)) (start-run (get-run-time)) (results (multiple-value-list (funcall thunk))) (run-time (- (get-run-time) start-run)) (real-time (- (get-real-time) start-real))) (values-list (list* real-time run-time results)))) (defmacro chrono-time (&body body) "RETURN: the real-time, the run-time, followed by the results of BODY." `(chrono-time* (lambda () ,@body))) (defmacro chrono-real-time (&body body) "RETURN: the real-time, followed by the results of BODY." `(let ((values (multiple-value-list (chrono-time* (lambda () ,@body))))) (values-list (cons (first values) (rest (rest values)))))) (defmacro chrono-run-time (&body body) "RETURN: the run-time, followed by the results of BODY." `(let ((values (multiple-value-list (chrono-time* (lambda () ,@body))))) (values-list (rest values)))) (defun format-time (time) (multiple-value-bind (se mi ho) (decode-universal-time time 0) (format nil "~2,'0D:~2,'0D:~2,'0D" ho mi (truncate se)))) (defun test/all () (list (multiple-value-list (chrono-time (progn (sleep 1) (values 1 2 3)))) (multiple-value-list (chrono-real-time (progn (sleep 1) (values 1 2 3)))) (multiple-value-list (chrono-run-time (progn (sleep 1) (values 1 2 3)))))) ;;;; THE END ;;;;
4,759
Common Lisp
.lisp
114
38.429825
85
0.649373
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
7336e66b31e0756f1d862fd215f5e6d208b16fd5d7a0f3b97fdcfe78d5e91a1f
5,120
[ -1 ]
5,121
ascii-test.lisp
informatimago_lisp/common-lisp/cesarum/ascii-test.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: ascii-test.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Tests ascii.lisp. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2015-02-26 <PJB> Extracted from ascii.lisp. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.ASCII.TEST" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SIMPLE-TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.ASCII") (:export "TEST/ALL")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.ASCII.TEST") (define-test test/ascii () " DO: test the ascii package; signal an error if something is wrong. RETURN: :success " (loop :for ch :across *ascii-characters* :for code :from sp :do (assert-true (= code (ascii-code ch))) :do (assert-true (char= ch (code-ascii code)))) (loop :for code :from (ascii-code #\0) :to (ascii-code #\9) :for n :from 0 :do (assert-true (eql n (code-ascii-digit-p code)))) (assert-true (typep (nth-value 1 (ignore-errors (ascii-string #(65 66 8 67 69)))) 'decoding-error)) (assert-true (typep (nth-value 1 (ignore-errors (ascii-bytes "En été, il fait chaud."))) 'encoding-error)) (assert-true (string= "ABCD" (ascii-string #(65 66 67 68)))) (assert-true (string= "ABCD" (ascii-string #(0 0 65 66 67 68 0 0 0 0) :start 2 :end 6))) (assert-true (bytes= #(65 66 67 68) (ascii-bytes "ABCD"))) (assert-true (bytes= #(65 66 67 68) (ascii-bytes "00ABCD0000" :start 2 :end 6))) (let ((*readtable* (copy-readtable nil))) (set-dispatch-macro-character #\# #\Y (function ascii-dispatch-macro) *readtable*) (set-dispatch-macro-character #\# #\" (function ascii-dispatch-macro) *readtable*) (assert-true (bytes= #(65 66 67 68) (read-from-string "#\"ABCD\""))) (assert-true (bytes= #(65 66 67 68) (read-from-string "#Y\"ABCD\"")))) #| TODO: Added more testing of bytes comparisons.|#) (define-test test/replace-ascii-characters () (multiple-value-bind (string end) (replace-ascii-characters (make-string 10 :initial-element #\*) #(13 10) :newline :crlf) (assert-true (char= #\newline (aref string 0))) (assert-true (char= #\* (aref string 1))) (assert-true (= 10 (length string))) (assert-true (= 1 end)))) (define-test test/all () (test/ascii) (test/replace-ascii-characters)) ;;;; THE END ;;;;
3,683
Common Lisp
.lisp
82
40.792683
108
0.606735
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
6be181af52512c81538150e733904e617a359c510afab9b7f91435511d28b591
5,121
[ -1 ]
5,122
llrbtree-test.lisp
informatimago_lisp/common-lisp/cesarum/llrbtree-test.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: llrbtree-test.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Tests llrbtree.lisp. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2015-02-25 <PJB> Extracted from llrbtree.lisp. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.LLRBTREE.TEST" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SIMPLE-TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.LLRBTREE") (:export "TEST/ALL")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.LLRBTREE.TEST") (flet ((insert (tree key value) (setf (tree-get key tree) value)) (finde (tree key) (tree-get key tree)) (erase (tree key) (tree-delete key tree)) (free (tree) (tree-clear tree)) (new-tree () (make-tree))) (define-test test/tree-creation () (let ((tree (make-tree :lessp (function <)))) (insert tree 1 "a") (insert tree 2 "b") (insert tree 12 "c") (insert tree 12 "c") (insert tree 12 "c") (insert tree -1 "d") (insert tree -1 "d") (insert tree 12 "c") (assert-true (equal (finde tree -1) "d") nil "Did not get 'd' for -1") (assert-true (equal (finde tree 1) "a") nil "Did not get 'a' for 1") (assert-true (equal (finde tree 2) "b") nil "Did not get 'b' for 2") (assert-true (equal (finde tree 12) "c") nil "Did not get 'c' for 12"))) (define-test test/node-erase () (let ((tree (new-tree))) (insert tree 4 "a") (insert tree 3 "b") (insert tree 2 "c") (insert tree 1 "d") (assert-true (equal (finde tree 1) "d") nil "Did not get 'd' for 1") (assert-true (equal (finde tree 2) "c") nil "Did not get 'c' for 2") (assert-true (equal (finde tree 3) "b") nil "Did not get 'b' for 3") (assert-true (equal (finde tree 4) "a") nil "Did not get 'a' for 4") (erase tree 2) (assert-true (eq (finde tree 2) nil) nil "Should not have found 2 after it was deleted.") (assert-true (equal (finde tree 1) "d") nil "Did not get 'd' for 1") (assert-true (equal (finde tree 3) "b") nil "Did not get 'b' for 3") (assert-true (equal (finde tree 4) "a") nil "Did not get 'a' for 4") (erase tree 4) (assert-true (eq (finde tree 4) nil) nil "Should not have found 4 after it was deleted.") (assert-true (equal (finde tree 1) "d") nil "Did not get 'd' for 1") (assert-true (equal (finde tree 3) "b") nil "Did not get 'b' for 3") (erase tree 1) (assert-true (eq (finde tree 1) nil) nil "Should not have found 1 after it was deleted.") (assert-true (equal (finde tree 3) "b") nil "Did not get 'b' for 3") (erase tree 3) (assert-true (eq (finde tree 4) nil) nil "Should not have found 4 after it was deleted.") (assert-true (eq (finde tree 3) nil) nil "Should not have found 3 after it was deleted.") (assert-true (eq (finde tree 2) nil) nil "Should not have found 2 after it was deleted.") (assert-true (eq (finde tree 1) nil) nil "Should not have found 1 after it was deleted.") (erase tree 3))) (define-test test/tree-erase () (let ((tree (new-tree))) (insert tree 4 "a") (insert tree 3 "b") (insert tree 2 "c") (insert tree 1 "d") (assert-true (equal (finde tree 1) "d") nil "Did not get 'd' for 1") (assert-true (equal (finde tree 2) "c") nil "Did not get 'c' for 2") (assert-true (equal (finde tree 3) "b") nil "Did not get 'b' for 3") (assert-true (equal (finde tree 4) "a") nil "Did not get 'a' for 4") (free tree) (assert-true (eq (finde tree 4) nil) nil "Should not have found 4 after it was deleted.") (assert-true (eq (finde tree 3) nil) nil "Should not have found 3 after it was deleted.") (assert-true (eq (finde tree 2) nil) nil "Should not have found 2 after it was deleted.") (assert-true (eq (finde tree 1) nil) nil "Should not have found 1 after it was deleted."))) (define-test test/iterator () (let ((tree (new-tree))) (insert tree 4 "a") (insert tree 3 "b") (insert tree 2 "c") (insert tree 1 "d") (with-tree-iterator (i tree) (assert-true (equal (multiple-value-list (i)) '(t 1 "d")) nil "The first element should have been 'd'") (assert-true (equal (multiple-value-list (i)) '(t 2 "c")) nil "Was expecting 'c' next.") (assert-true (equal (multiple-value-list (i)) '(t 3 "b")) nil "Was expecting 'b' next yet again.") (assert-true (equal (multiple-value-list (i)) '(t 4 "a")) nil "Was expecting 'a' next.") (assert-true (not (i)) nil "Was expecting nil this time.") (assert-true (not (i)) nil "The next item past the last one should have been nil.") (assert-true (not (i)) nil "The next item past the last one should have been nil again.")))) );;flet (define-test test/all () (test/tree-creation) (test/node-erase) (test/tree-erase) (test/iterator)) ;;;; THE END ;;;;
6,316
Common Lisp
.lisp
128
43.75
100
0.592208
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
c50adcc17f73536c68237c68d795eef51d2bc00569c844ebc1931f79445f1787
5,122
[ -1 ]
5,123
iana-character-sets.lisp
informatimago_lisp/common-lisp/cesarum/iana-character-sets.lisp
;;;; -*- coding:utf-8 -*- ;;;;**************************************************************************** ;;;;FILE: iana-character-sets.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Converts the IANA character sets assignments to a lisp package. ;;;; IANA character sets: ;;;; http://www.iana.org/assignments/character-sets ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2005-08-31 <PJB> Created ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2005 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;**************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.IANA-CHARACTER-SETS" (:use "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.LIST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.STRING" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY" "COMMON-LISP") (:export "CHARACTER-SETS-MAP" "READ-CHARACTER-SETS") (:documentation " Converts the IANA character set assignments to a lisp package. IANA character sets: http://www.iana.org/assignments/character-sets License: AGPL3 Copyright Pascal J. Bourguignon 2005 - 2012 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.IANA-CHARACTER-SETS") (defun second-word (line) (let* ((space (position (character " ") line)) (start (position (character " ") line :start space :test (complement (function eql)))) (end (position (character " ") line :start start))) (subseq line start end))) (defun read-character-sets (path) (with-open-file (in path) (loop for line = (read-line in nil nil) with name = nil with aliases = '() with results = '() while line do ;; scan Name: and Alias: ; generate on empty line (cond ((prefixp "Name: " line ) (setf name (second-word line))) ((prefixp "Alias: " line) (let ((alias (second-word line))) (unless (string-equal "None" alias) (push alias aliases)))) ((zerop (length (string-trim " " line))) (when name (push (cons name aliases) results)) (setf name nil aliases '()))) finally (return results)))) (defun character-sets-map (path) (let ((hash (make-hash-table :test (function equalp)))) (dolist (cs (read-character-sets path)) (dolist (name cs) (setf (gethash name hash) (first cs)))) hash)) ;;;; THE END ;;;;
4,083
Common Lisp
.lisp
93
39.451613
83
0.638126
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
b543afff76b1cdabc1dc57e8201859b8d7531e7c0039d46625fb1177a0431bca
5,123
[ -1 ]
5,124
ascii.lisp
informatimago_lisp/common-lisp/cesarum/ascii.lisp
;;;;************************************************************************** ;;;;FILE: ascii.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2021-05-22 <PJB> Made use of .character:has-ascii-code-p to ;;;; optimize CODE-ASCII and ASCI-CODE. Renamed ;;;; CODE-ASCII to ASCII-PRINTABLE-CODE-CHAR, and ;;;; implemented CODE-ASCII to map control codes ;;;; to characters when has-ascii-code. ;;;; Renamed CODE-ASCII-DIGIT-P to ASCII-DIGIT-P. ;;;; 2021-05-14 <PJB> Added REPLACE-ASCII-BYTES and REPLACE-ASCII-CHARACTERS. ;;;; 2012-04-20 <PJB> Added conditions; ;;;; Added :start and :stop to ASCII-STRING and ASCII-BYTES. ;;;; Added ASCII-CONTROL-CODE-P and ASCII-PRINTABLE-CODE-P. ;;;; Completed the TEST function. ;;;; 2007-07-05 <PJB> Moved to public/lisp/common-lisp ;;;; 2006-10-01 <PJB> Created. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2006 - 2021 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/> ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.ASCII" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.ECMA048" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.CHARACTER") (:shadow "ED") (:export ; re-export from ECMA048 "NUL" "SOH" "STX" "ETX" "EOT" "ENQ" "ACK" "BEL" "BS" "HT" "LF" "VT" "FF" "CR" "SO" "SI" "DLE" "DC1" "DC2" "DC3" "DC4" "NAK" "SYN" "ETB" "CAN" "EM" "SUB" "ESC" "FS" "GS" "RS" "US" "SP" "DEL") (:export "*NEWLINE*" "*ASCII-CHARACTERS*" "*HEXADECIMAL-DIGITS*" "ENCODING-ERROR" "ENCODING-ERROR-CHARACTER" "ENCODING-ERROR-CODING-SYSTEM" "ENCODING-ERROR-MESSAGE" "DECODING-ERROR" "DECODING-ERROR-CODE" "DECODING-ERROR-CODING-SYSTEM" "DECODING-ERROR-MESSAGE" "ASCII-CODE" "ASCII-DIGIT-P" "ASCII-CODE-P" "ASCII-CONTROL-CODE-P" "ASCII-PRINTABLE-CODE-P" "CODE-ASCII" "ASCII-PRINTABLE-CODE-CHAR" "ASCII-STRING" "ASCII-BYTES" "ASCII-DISPATCH-MACRO" "READ-ASCII-LINE" "ASCII-FORMAT" "BYTES=" "BYTES/=" "BYTES<" "BYTES<=" "BYTES>=" "BYTES>" "REPLACE-ASCII-BYTES" "REPLACE-ASCII-CHARACTERS") (:documentation " Some ASCII code utilities, to process sequences of ASCII code bytes as easily as strings. Note: this works even on implementations that don't use ASCII for CHAR-CODE. Examples: (bytes= buffer #.(ascii-bytes \"HELO \") :end1 (min 5 (length buffer))) (bytes= (read-ascii-line) #\"HELO \" :end1 (min 5 (length buffer))) License: AGPL3 Copyright Pascal J. Bourguignon 2006 - 2021 This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> ")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.ASCII") ;;; http://en.wikipedia.org/wiki/Ascii #-(and) (eval-when (:compile-toplevel :load-toplevel :execute) ;; defined in ecma048 ;; Control codes: (defconstant nul #x00 "^@ ASCII Control Code Null character ") (defconstant soh #x01 "^A ASCII Control Code Start of Header") (defconstant stx #x02 "^B ASCII Control Code Start of Text") (defconstant etx #x03 "^C ASCII Control Code End of Text") (defconstant eot #x04 "^D ASCII Control Code End of Transmission") (defconstant enq #x05 "^E ASCII Control Code Enquiry") (defconstant ack #x06 "^F ASCII Control Code Acknowledgement") (defconstant bel #x07 "^G ASCII Control Code Bell") (defconstant bs #x08 "^H ASCII Control Code Backspace") (defconstant ht #x09 "^I ASCII Control Code Horizontal Tab") (defconstant lf #x0a "^J ASCII Control Code Line feed") (defconstant vt #x0b "^K ASCII Control Code Vectical Tab") (defconstant ff #x0c "^L ASCII Control Code Form feed") (defconstant cr #x0d "^M ASCII Control Code Carriage return") (defconstant so #x0e "^N ASCII Control Code Shift Out") (defconstant si #x0f "^O ASCII Control Code Shift In") (defconstant dle #x10 "^P ASCII Control Code Data Link Escape") (defconstant dc1 #x11 "^Q ASCII Control Code Device Control 1 (X-ON)") (defconstant dc2 #x12 "^R ASCII Control Code Device Control 2") (defconstant dc3 #x13 "^S ASCII Control Code Device Control 3 (X-OFF)") (defconstant dc4 #x14 "^T ASCII Control Code Device Control 4") (defconstant nak #x15 "^U ASCII Control Code Negative Acknowledge") (defconstant syn #x16 "^V ASCII Control Code Synchronous Idle") (defconstant etb #x17 "^W ASCII Control Code End of Transmision Block") (defconstant can #x18 "^X ASCII Control Code Cancel") (defconstant em #x19 "^Y ASCII Control Code End of Medium") (defconstant sub #x1a "^Z ASCII Control Code Substitute") (defconstant esc #x1b "^[ ASCII Control Code Escape") (defconstant fs #x1c "^\ ASCII Control Code File Separator") (defconstant gs #x1d "^] ASCII Control Code Group Separator") (defconstant rs #x1e "^^ ASCII Control Code Record Separator") (defconstant us #x1f "^_ ASCII Control Code Unit Separator") (defconstant del #x7f "^? ASCII Control Code Delete ")) ;; NUL Null: The all-zeros character which may serve to accomplish time ;; fill and media fill. ;; ;; SOH Start of Heading: A communication control character used at the ;; beginning of a sequence of characters which constitute a ;; machine-sensible address or routing information. Such a sequence ;; is referred to as the "heading." An STX character has the effect ;; of terminating a heading. ;; ;; STX Start of Text: A communication control character which precedes a ;; sequence of characters that is to be treated as an entity and ;; entirely transmitted through to the ultimate destination. Such a ;; sequence is referred to as "text." STX may be used to terminate a ;; sequence of characters started by SOH. ;; ;; ETX End of Text: A communication control character used to terminate a ;; sequence of characters started with STX and transmitted as an ;; entity. ;; ;; EOT End of Transmission: A communication control character used to ;; indicate the conclusion of a transmission, which may have ;; contained one or more texts and any associated headings. ;; ;; ENQ Enquiry: A communication control character used in data ;; communication systems as a request for a response from a remote ;; station. It may be used as a "Who Are You" (WRU) to obtain ;; identification, or may be used to obtain station status, or both. ;; ;; ACK Acknowledge: A communication control character transmitted by a ;; receiver as an affirmative response to a sender. ;; ;; BEL Bell: A character for use when there is a need to call for human ;; attention. It may control alarm or attention devices. ;; ;; BS Backspace: A format effector which controls the movement of the ;; printing position one printing space backward on the same printing ;; line. (Applicable also to display devices.) ;; ;; HT Horizontal Tabulation: A format effector which controls the ;; movement of the printing position to the next in a series of ;; predetermined positions along the printing line. (Applicable also ;; to display devices and the skip function on punched cards.) ;; ;; LF Line Feed: A format effector which controls the movement of the ;; printing position to the next printing line. (Applicable also to ;; display devices.) Where appropriate, this character may have the ;; meaning "New Line" (NL), a format effector which controls the ;; movement of the printing point to the first printing position on ;; the next printing line. Use of this convention requires agreement ;; between sender and recipient of data. ;; ;; VT Vertical Tabulation: A format effector which controls the movement ;; of the printing position to the next in a series of predetermined ;; printing lines. (Applicable also to display devices.) ;; ;; FF Form Feed: A format effector which controls the movement of the ;; printing position to the first pre-determined printing line on the ;; next form or page. (Applicable also to display devices.) ;; ;; CR Carriage Return: A format effector which controls the movement of ;; the printing position to the first printing position on the same ;; printing line. (Applicable also to display devices.) ;; ;; SO Shift Out: A control character indicating that the code ;; combinations which follow shall be interpreted as outside of the ;; character set of the standard code table until a Shift In ;; character is reached. ;; ;; SI Shift In: A control character indicating that the code ;; combinations which follow shall be interpreted according to the ;; standard code table. ;; ;; DLE Data Link Escape: A communication control character which will ;; change the meaning of a limited number of contiguously following ;; characters. It is used exclusively to provide supplementary ;; controls in data communication networks. ;; ;; DC1, DC2, DC3, DC4 Device Controls: Characters for the control of ;; ancillary devices associated with data processing or ;; telecommunication systems, more especially switching devices "on" ;; or "off." (If a single "stop" control is required to interrupt or ;; turn off ancillary devices, DC4 is the preferred assignment.) ;; ;; NAK Negative Acknowledge: A communication control character ;; transmitted by a receiver as a negative response to the sender. ;; ;; SYN Synchronous Idle: A communication control character used by a ;; synchronous transmission system in the absence of any other ;; character to provide a signal from which synchronism may be ;; achieved or retained. ;; ;; ETB End of Transmission Block: A communication control character used ;; to indicate the end of a block of data for communication ;; purposes. ETB is used for blocking data where the block structure ;; is not necessarily related to the processing format. ;; ;; CAN Cancel: A control character used to indicate that the data with ;; which it is sent is in error or is to be disregarded. ;; ;; EM End of Medium: A control character associated with the sent data ;; which may be used to identify the physical end of the medium, or ;; the end of the used, or wanted, portion of information recorded on ;; a medium. (The position of this character does not necessarily ;; correspond to the physical end of the medium.) ;; ;; SUB Substitute: A character that may be substituted for a character ;; which is determined to be invalid or in error. ;; ;; ESC Escape: A control character intended to provide code extension ;; (supplementary characters) in general information interchange. The ;; Escape character itself is a prefix affecting the interpretation ;; of a limited number of contiguously following characters. ;; ;; FS, GS, RS, US File Separator, Group Separator, Record Separator, and ;; Unit Separator: These information separators may be used within ;; data in optional fashion, except that their hierarchical ;; relationship shall be: FS is the most inclusive, then GS, then RS, ;; and US is least inclusive. (The content and length of a File, ;; Group, Record, or Unit are not specified.) ;; ;; DEL Delete: This character is used primarily to "erase" or ;; "obliterate" erroneous or unwanted characters in perforated ;; tape. (In the strict sense, DEL is not a control character.) (eval-when (:compile-toplevel :load-toplevel :execute) ;; Printable character: (defconstant sp #x20 " Code of ASCII Character SPACE") (defgeneric encoding-error-character (err) (:documentation "The character that cannot be encoded.")) (defgeneric encoding-error-coding-system (err) (:documentation "A keyword denoting the coding system which cannot encode the character.")) (defgeneric encoding-error-message (err) (:documentation "The error message.")) (define-condition encoding-error (error) ((character :initarg :character :reader encoding-error-character) (coding-system :initarg :coding-system :reader encoding-error-coding-system) (message :initarg :message :reader encoding-error-message)) (:documentation "The condition denoting an encoding error.") (:report (lambda (condition stream) (format stream "The character ~C (native code ~D) cannot be encoded in ~A: ~A" (encoding-error-character condition) (char-code (encoding-error-character condition)) (encoding-error-coding-system condition) (encoding-error-message condition))))) (defgeneric decoding-error-code (err) (:documentation "The code that corresponds to no character.")) (defgeneric decoding-error-coding-system (err) (:documentation "A keyword denoting the coding system which cannot decode the code.")) (defgeneric decoding-error-message (err) (:documentation "The error message.")) (define-condition decoding-error (error) ((code :initarg :code :reader decoding-error-code) (coding-system :initarg :coding-system :reader decoding-error-coding-system) (message :initarg :message :reader decoding-error-message)) (:documentation "The condition denoting a decoding error.") (:report (lambda (condition stream) (format stream "The code ~D (hexa ~:*~2,'0X) cannot be decoded in ~A: ~A" (decoding-error-code condition) (decoding-error-coding-system condition) (decoding-error-message condition))))) (defparameter *ascii-characters* #.(concatenate 'string " !\"#$%&'()*+,-./0123456789:;<=>?" "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_" "`abcdefghijklmnopqrstuvwxyz{|}~") "A string containing all the ASCII characters in lexical order.") (defparameter *hexadecimal-digits* "0123456789abcdef" "A string contaiing the hexadecimal digits (lower case letters) in order.") (declaim (inline ascii-code)) (defun ascii-code (ch) " RETURN: The ASCII code of the character ch, or raise an error if the character has no ascii code. Only printable characters are accepted. No control code. " (let ((code #+has-ascii-code (let ((code (char-code ch))) (when (and code (<= 0 code 127)) code)) #-has-ascii-code (let ((code (position ch *ascii-characters*))) (when code (+ sp code))))) (unless code (error 'encoding-error :character ch :coding-system :us-ascii :message "This character cannot be encoded in ASCII")) code))) (defparameter *newline* :crlf "(OR (MEMBER :CRLF :CR :LF :DOS :MAC :UNIX) (CONS (MEMBER :CRLF :CR :LF :DOS :MAC :UNIX) (MEMBER :CRLF :CR :LF :DOS :MAC :UNIX :ANY)) The encoding used for #\\Newline for output and for input. If it's a keyword, it's used for both output and input. :DOS is an alias for :CRLF, :MAC is an alias for :CR, :UNIX is an alias for LF. If it's a CONS cell, the CAR specifies the newline encoding for output and the CDR specifies the newline encoding for input (it may be :ANY to accept any of CR-LF, CR or LF; LF-CR would read as two newlines).") (declaim (inline map-newline-alias input-newline output-newline)) (defun map-newline-alias (keyword) (ecase keyword ((:dos :crlf) :crlf) ((:mac :cr) :cr) ((:unix :lf) :lf))) (defun input-newline (newline) (map-newline-alias (if (consp newline) (cdr newline) newline))) (defun output-newline (newline) (map-newline-alias (if (consp newline) (car newline) newline))) (declaim (inline ascii-error)) (defun ascii-error (code) (error 'decoding-error :code code :coding-system :us-ascii :message (cond ((or (< code SP) (= code DEL)) "ASCII control codes cannot be converted to characters.") ((< DEL code) "Codes greater than 127 are not ASCII codes.") (t "[SHOULD NOT OCCUR]")))) (declaim (inline ascii-digit-p)) (defun ascii-digit-p (code) " RETURN: The decimal digit value of the character encoded by the ASCII CODE, or NIL if CODE is not the ASCII code of a digit character. " (and (<= #.(ascii-code #\0) code #.(ascii-code #\9)) (- code #.(ascii-code #\0)))) (declaim (inline ascii-code-p)) (defun ascii-code-p (code) "RETURN: Whether CODE is an ASCII code. (ascii-code-p code) <=> (or (ascii-control-code-p code) (ascii-printable-code-p code))" (<= nul code del)) (declaim (inline ascii-control-code-p)) (defun ascii-control-code-p (code) "RETURN: Whether CODE is an ASCII control code." (or (<= nul code (1- sp)) (= del code))) (declaim (inline ascii-printable-code-p)) (defun ascii-printable-code-p (code) "RETURN: Whether CODE is the code of an ASCII printable character." (<= sp code (1- del))) (declaim (inline ascii-printable-code-char)) (defun ascii-printable-code-char (code) " RETURN: The character corresponding to the given ASCII code. Only codes for printable characters are accepted, and both CR and LF are mapped to #\newline. " (cond ((ascii-printable-code-p code) #+has-ascii-code (code-char code) #-has-ascii-code (aref *ascii-characters* (- code sp))) ((or (= code cr) (= code lf)) #\newline) (t (ascii-error code)))) (declaim (inline code-ascii)) (defun code-ascii (code) " RETURN: The character corresponding to the given ASCII code. If (has-ascii-code-p) then control codes are also converted to characters, otherewise NIL is returned, but for CR and LF: both CR and LF are mapped to #\newline. " #+has-ascii-code (if (ascii-code-p code) (code-char code) (ascii-error code)) #-has-ascii-code (cond ((ascii-printable-code-p code) #+has-ascii-standard-characters (code-char code) #-has-ascii-standard-characters (aref *ascii-characters* (- code sp))) ((or (= code CR) (= code LF)) #\newline) (t nil))) (defun replace-ascii-characters (string bytes &key (newline *newline*) (start1 0) end1 (start2 0) (end2 (length bytes))) "Store in STRING, from START1 to END1, the ASCII characters that are encoded in the BYTES vector from START2 to END2. If a code that is not a printable ascii code or CR or LF is encountered, then a DECODING-ERROR signaled. RESULT: STRING and the position beyond the last character stored." (cond ((= start2 end2) (values string start1)) ((> start2 end2) (assert (< start2 end2) (start2 end2) "Invalid bounding index designators START2=~A END2=~A (we must have start2<=end2)" start2 end2)) (t (loop :with newline := (input-newline newline) :with endd := (or end1 (length string)) :with len := (- end2 start2) :with i := start1 :with j := start2 :while (and (< i endd) (< j end2)) :do (let ((code (aref bytes j))) (incf j) (if (ascii-printable-code-p code) (setf (aref string i) (code-ascii code)) (case code ((#.cr) (ecase newline ((:crlf) (if (and (< j len) (= lf (aref bytes j))) (progn (incf j) (setf (aref string i) #\newline)) (ascii-error code))) ((:any) (if (and (< j len) (= lf (aref bytes j))) (progn (incf j) (setf (aref string i) #\newline)) (setf (aref string i) #\newline))) ((:cr) (setf (aref string i) #\newline)) ((:lf) (ascii-error code)))) ((#.lf) (ecase newline ((:any :lf) (setf (aref string i) #\newline)) ((:crlf :cr) (ascii-error code)))) (otherwise (ascii-error code)))) (incf i)) :finally (return (values string i)))))) (defun ascii-string (bytes &key (newline *newline*) (start 0) (end (length bytes))) " DO: Converts the ASCII bytes to a string. If there are control codes, an error is signaled. RETURN: A string containing the characters encoded in the ASCII bytes. NEWLINE: (member :crlf :cr :lf :any) ; the default is *NEWLINE*. If lone CR or LF are present, then an error is signaled. START: index of the first byte to be converted. END: index beyond the last byte to be converted. " (multiple-value-bind (string size) (replace-ascii-characters (make-array (- end start) :element-type 'character :adjustable t :fill-pointer (- end start)) bytes :newline newline :start2 start :end2 end) (setf (fill-pointer string) size) string)) (defun replace-ascii-bytes (bytes string &key (newline *newline*) (start1 0) end1 (start2 0) (end2 (length string))) " RETURN: BYTES, and the position beyond the last byte stored. BYTES: A byte vector containing the ASCII codes of the characters in the string. Only printable character and #\newline are accepted in the string. #\newline is translated to either CR+LF, CR, or LF according to the NEWLINE parameter. NEWLINE: (member :crlf :cr :lf) ; the default is *NEWLINE*. " (loop :with newline = (output-newline newline) :with endd := (or end1 (length bytes)) :with i := (- start1 1) :for j :from start2 :below end2 :for ch := (aref string j) :while (< i endd) :do (if (char= ch #\newline) (ecase newline ((:crlf) (setf (aref bytes (incf i)) cr (aref bytes (incf i)) lf)) ((:cr) (setf (aref bytes (incf i)) cr)) ((:lf) (setf (aref bytes (incf i)) lf))) (setf (aref bytes (incf i)) (ascii-code ch))) :finally (return (values bytes j)))) (defun ascii-bytes (string &key (newline *newline*) (start 0) (end (length string))) " RETURN: A byte vector containing the ASCII codes of the characters in the string. Only printable character and #\newline are accepted in the string. #\newline is translated to either CR+LF, CR, or LF according to the NEWLINE parameter. NEWLINE: (member :crlf :cr :lf) ; the default is *NEWLINE*. " (replace-ascii-bytes (make-array (+ (- end start) (if (eq newline :crlf) (count #\newline string :start start :end end) 0)) :element-type '(unsigned-byte 8)) string :newline newline :start2 start :end2 end)) (defun ascii-dispatch-macro (stream sub-char argument) " DO: Read a string and converts it to an ASCII byte sequence. ARGUMENT: If NIL, #\newline are encoded according to *NEWLINE*. If 0, #\newline are encoded to CR-LF. If 1, #\newline are encoded to LF. If 2, #\newline are encoded to CR. Otherwise an error is issued. SUB-CHAR: If it is #\" then it's considered the start of the string, otherwise we expect to read a full string next. This allow to set dispatch macro characters for: #\"abc\" or #Y\"abc\" EXAMPLES: (set-dispatch-macro-character #\# #\Y (function ascii-dispatch-macro) *readtable*) (set-dispatch-macro-character #\# #\" (function ascii-dispatch-macro) *readtable*) " (when (char= #\" sub-char) (unread-char sub-char stream)) (let ((string (read stream t nil t))) (assert (stringp string) (string) "~s expects to read a string, not ~s" 'ascii-dispatch-macro string) (ascii-bytes string :newline (ecase argument ((nil) *newline*) ((0) :crlf) ((1) :lf) ((2) :cr))))) (defun read-ascii-line (stream &optional (eof-error t) (eof-value nil) (newline *newline*)) " newline: (member :crlf :cr :lf) ; the defaultl is :CRLF since that's what's used in internet binary protocols using ascii. " (setf newline (input-newline newline)) (loop :with buffer = (make-array 80 :element-type (stream-element-type stream) :adjustable t :fill-pointer 0) :for item = (read-byte stream nil) :while item :do (vector-push-extend item buffer (array-dimension buffer 0)) (ecase newline ((:crlf) (when (and (<= 2 (length buffer)) (= cr (aref buffer (- (length buffer) 2))) (= lf (aref buffer (- (length buffer) 1)))) (decf (fill-pointer buffer) 2) (return-from read-ascii-line buffer))) ((:cr) (when (and (<= 1 (length buffer)) (= cr (aref buffer (- (length buffer) 1)))) (decf (fill-pointer buffer)) (return-from read-ascii-line buffer))) ((:lf) (when (and (<= 1 (length buffer)) (= lf (aref buffer (- (length buffer) 1)))) (decf (fill-pointer buffer)) (return-from read-ascii-line buffer)))) :finally (cond ((plusp (length buffer)) (return-from read-ascii-line buffer)) (eof-error (error 'end-of-file :stream stream)) (t (return-from read-ascii-line eof-value))))) (defun ascii-format (destination ctrl-string &rest arguments) " DO: Format the CTRL-STRING and the ARGUMENTS with FORMAT, convert the resulting string to a vector of ASCII bytes and send it to the DESTINATION. RETURN: NIL if DESTINATION is not NIL, a byte vector otherwise. DESTINATION: T -> *STANDARD-OUTPUT* NIL -> A vector of bytes is returned. STREAM -> An output binary stream to which the bytes are written. CTRL-STRING: A FORMAT control string (contaiing only characters in the ASCII character set). ARGUMENTS: Arguments to be formated with FORMAT. SEE ALSO: FORMAT " (let ((bytes (ascii-bytes (apply (function format) nil ctrl-string arguments)))) (case destination ((t) (write-sequence bytes *standard-output*) nil) ((nil) bytes) (otherwise (write-sequence bytes destination) nil)))) (defun bytes= (v1 v2 &key (start1 0) (start2 0) (end1 nil) (end2 nil)) " like string=, but for byte vectors. " (if (and (zerop start1) (zerop start2) (or (null end1) (= end1 (length v1))) (or (null end2) (= end2 (length v2)))) (equalp v1 v2) (and (= (- (or end1 (length v1)) start1) (- (or end2 (length v2)) start2)) (loop :for i :from start1 :below (or end1 (length v1)) :for j :from start2 :below (or end2 (length v2)) :always (= (aref v1 i) (aref v2 j)))))) (defun bytes/= (v1 v2 &key (start1 0) (start2 0) (end1 nil) (end2 nil)) " like string/=, but for byte vectors. " (not (bytes= v1 v2 :start1 start1 :end1 end1 :start2 start2 :end2 end2))) (defun bytes< (v1 v2 &key (start1 0) (start2 0) (end1 nil) (end2 nil)) " like string<, but for byte vectors. " (loop :with i = start1 :with mi = (or end1 (length v1)) :with j = start2 :with mj = (or end2 (length v2)) :while (and (< i mi) (< j mj) (= (aref v1 i) (aref v2 j))) :do (incf i) (incf j) :finally (return (if (< i mi) (if (< j mj) (< (aref v1 i) (aref v2 j)) ; "abc" "axc" nil) ; "abcd" "abc" (< j mj))))) ; "abc" "abcd" ; "abc" "abc" (defun bytes<= (v1 v2 &key (start1 0) (start2 0) (end1 nil) (end2 nil)) " like string<=, but for byte vectors. " (or (bytes= v1 v2 :start1 start1 :end1 end1 :start2 start2 :end2 end2) (bytes< v1 v2 :start1 start1 :end1 end1 :start2 start2 :end2 end2))) (defun bytes>= (v1 v2 &key (start1 0) (start2 0) (end1 nil) (end2 nil)) " like string>=, but for byte vectors. " (not (bytes< v1 v2 :start1 start1 :end1 end1 :start2 start2 :end2 end2))) (defun bytes> (v1 v2 &key (start1 0) (start2 0) (end1 nil) (end2 nil)) " like string<, but for byte vectors. " (not (bytes<= v1 v2 :start1 start1 :end1 end1 :start2 start2 :end2 end2))) ;;;; THE END ;;;;
31,121
Common Lisp
.lisp
632
42.651899
120
0.626936
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
e8a75cfc92b66187870b54cf8fd13659abeb0938839750befc7ebaf148e8c153
5,124
[ -1 ]
5,125
combination-test.lisp
informatimago_lisp/common-lisp/cesarum/combination-test.lisp
;;;; -*- mode:lisp;coding:utf-8 -*- ;;;;************************************************************************** ;;;;FILE: combination-test.lisp ;;;;LANGUAGE: Common-Lisp ;;;;SYSTEM: Common-Lisp ;;;;USER-INTERFACE: NONE ;;;;DESCRIPTION ;;;; ;;;; Tests combination.lisp. ;;;; ;;;;AUTHORS ;;;; <PJB> Pascal J. Bourguignon <[email protected]> ;;;;MODIFICATIONS ;;;; 2015-02-28 <PJB> Extracted from combination.lisp. ;;;;BUGS ;;;;LEGAL ;;;; AGPL3 ;;;; ;;;; Copyright Pascal J. Bourguignon 2015 - 2016 ;;;; ;;;; This program is free software: you can redistribute it and/or modify ;;;; it under the terms of the GNU Affero General Public License as published by ;;;; the Free Software Foundation, either version 3 of the License, or ;;;; (at your option) any later version. ;;;; ;;;; This program is distributed in the hope that it will be useful, ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;;; GNU Affero General Public License for more details. ;;;; ;;;; You should have received a copy of the GNU Affero General Public License ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;;;;************************************************************************** (eval-when (:compile-toplevel :load-toplevel :execute) (setf *readtable* (copy-readtable nil))) (defpackage "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.COMBINATION.TEST" (:use "COMMON-LISP" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SIMPLE-TEST" "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.COMBINATION") (:export "TEST/ALL")) (in-package "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.COMBINATION.TEST") (define-test test/arrangement-with-repeat/take-3-of-5 () (let ((awr (make-instance 'arrangement-with-repeat))) (setf (base-cardinal awr) 5 (element-size awr) 3) (reset awr) (assert-true (= 125 (cardinal awr))) (assert-true (equalp (loop :named awr :with results = '() :do (multiple-value-bind (arrangement done) (get-next-element awr) (when done (return-from awr (nreverse results))) (push arrangement results))) '(#(0 0 0) #(0 0 1) #(0 0 2) #(0 0 3) #(0 0 4) #(0 1 0) #(0 1 1) #(0 1 2) #(0 1 3) #(0 1 4) #(0 2 0) #(0 2 1) #(0 2 2) #(0 2 3) #(0 2 4) #(0 3 0) #(0 3 1) #(0 3 2) #(0 3 3) #(0 3 4) #(0 4 0) #(0 4 1) #(0 4 2) #(0 4 3) #(0 4 4) #(1 0 0) #(1 0 1) #(1 0 2) #(1 0 3) #(1 0 4) #(1 1 0) #(1 1 1) #(1 1 2) #(1 1 3) #(1 1 4) #(1 2 0) #(1 2 1) #(1 2 2) #(1 2 3) #(1 2 4) #(1 3 0) #(1 3 1) #(1 3 2) #(1 3 3) #(1 3 4) #(1 4 0) #(1 4 1) #(1 4 2) #(1 4 3) #(1 4 4) #(2 0 0) #(2 0 1) #(2 0 2) #(2 0 3) #(2 0 4) #(2 1 0) #(2 1 1) #(2 1 2) #(2 1 3) #(2 1 4) #(2 2 0) #(2 2 1) #(2 2 2) #(2 2 3) #(2 2 4) #(2 3 0) #(2 3 1) #(2 3 2) #(2 3 3) #(2 3 4) #(2 4 0) #(2 4 1) #(2 4 2) #(2 4 3) #(2 4 4) #(3 0 0) #(3 0 1) #(3 0 2) #(3 0 3) #(3 0 4) #(3 1 0) #(3 1 1) #(3 1 2) #(3 1 3) #(3 1 4) #(3 2 0) #(3 2 1) #(3 2 2) #(3 2 3) #(3 2 4) #(3 3 0) #(3 3 1) #(3 3 2) #(3 3 3) #(3 3 4) #(3 4 0) #(3 4 1) #(3 4 2) #(3 4 3) #(3 4 4) #(4 0 0) #(4 0 1) #(4 0 2) #(4 0 3) #(4 0 4) #(4 1 0) #(4 1 1) #(4 1 2) #(4 1 3) #(4 1 4) #(4 2 0) #(4 2 1) #(4 2 2) #(4 2 3) #(4 2 4) #(4 3 0) #(4 3 1) #(4 3 2) #(4 3 3) #(4 3 4) #(4 4 0) #(4 4 1) #(4 4 2) #(4 4 3) #(4 4 4)))))) (define-test test/arrangement-sans-repeat/take-3-of-5-distinct () (let ((asr (make-instance 'arrangement-sans-repeat))) (setf (base-cardinal asr) 5 (element-size asr) 3) (reset asr) (assert-true (= 60 (cardinal asr))) (assert-true (equalp (loop :with results = '() :named asr :do (multiple-value-bind (arrangement done) (get-next-element asr) (when done (return-from asr (nreverse results))) (push arrangement results))) '(#(0 1 2) #(0 1 3) #(0 1 4) #(0 2 1) #(0 2 3) #(0 2 4) #(0 3 1) #(0 3 2) #(0 3 4) #(0 4 1) #(0 4 2) #(0 4 3) #(1 0 2) #(1 0 3) #(1 0 4) #(1 2 0) #(1 2 3) #(1 2 4) #(1 3 0) #(1 3 2) #(1 3 4) #(1 4 0) #(1 4 2) #(1 4 3) #(2 0 1) #(2 0 3) #(2 0 4) #(2 1 0) #(2 1 3) #(2 1 4) #(2 3 0) #(2 3 1) #(2 3 4) #(2 4 0) #(2 4 1) #(2 4 3) #(3 0 1) #(3 0 2) #(3 0 4) #(3 1 0) #(3 1 2) #(3 1 4) #(3 2 0) #(3 2 1) #(3 2 4) #(3 4 0) #(3 4 1) #(3 4 2) #(4 0 1) #(4 0 2) #(4 0 3) #(4 1 0) #(4 1 2) #(4 1 3) #(4 2 0) #(4 2 1) #(4 2 3) #(4 3 0) #(4 3 1) #(4 3 2)))))) (define-test test/combination/3-from-5 () (let ((com (make-instance 'combination))) (setf (base-cardinal com) 5 (element-size com) 3) (reset com) (assert-true (= 10 (cardinal com))) (assert-true (equalp (loop :with results = '() :named com :do (multiple-value-bind (arrangement done) (get-next-element com) (when done (return-from com (nreverse results))) (push arrangement results))) '(#(0 1 2) #(0 1 3) #(0 1 4) #(0 2 3) #(0 2 4) #(0 3 4) #(1 2 3) #(1 2 4) #(1 3 4) #(2 3 4)))))) (define-test test/all () (test/arrangement-with-repeat/take-3-of-5) (test/arrangement-sans-repeat/take-3-of-5-distinct) (test/combination/3-from-5)) ;;;; THE END ;;;;
6,369
Common Lisp
.lisp
108
45.935185
97
0.424388
informatimago/lisp
20
6
0
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
4d1d2c6c27de67f0ebd2a1f5b394bcd5e27b1436a9cc7dd6dc728270435b55f6
5,125
[ -1 ]