;time sbcl --noinform --noprint --load lecture1.lisp --eval '(d1)' --eval '(quit)'|less ;
(defmacro eecummings (x) "http://en.wikipedia.org/wiki/E._E._Cummings" `(progn (setf cl:*print-case* :downcase) ,x (setf cl:*print-case* :upcase))) (defun todo-p (x) (fboundp (first x))) (let ((in 0) (c " ") (next 2) (s t)) (defun pad () (dotimes (i in) (princ c s))) (defun tag (x) (cond ((atom x) (pad) (format s "~a~%" x)) ((todo-p x) (eval x)) (t (wrap (pop x) x)))) (defun tag1 (l) (setf in (+ in next)) (dolist (one l) (tag one)) (setf in (- in next))) (defun wrap (a b &optional (c a)) (pad) (format s "<~a>~%" a) (tag1 b) (pad) (format s "~a>~%" c)) (defun href (url txt) (pad) (format s "~a~%" url txt)) (defmacro tr1 (&rest l) `(wrap "tr class=one" ',l "tr")) (defmacro tr0 (&rest l) `(wrap "tr class=zero" ',l "tr")) ) (defun d1 () (eecummings (tag '(html (head (title "sadas")) (body (p Anytime you want its trouble asdasd asd dsasasdasa sad asd asd as dsadasasdas (table (tr0 (td i love ice cream) (td "dssaasd"))) (ul (li "dadas asdas") (li "dasddas asdas 121312")) (href "dsda" "dass"))))))) ;; (defmacro whitespacep (char) ;; "Checks whether CHAR is whitespace." ;; `(find ,char ;; '(#\Space #\Tab #\Newline #\Linefeed #\Return #\Page))) ;; (defun skip-whitespace (s) ;; (if (whitespace (peek-char nil s nil :eof)) ;; (read-char nil s nil) ;; (skip-whitespace s))) ;; (defun tagfile (fin fout) ;; (with-open-file (*standard-output* fout ;; :direction :output ;; :if-exists :supersede) ;; (with-open-file (sin fin :direction :input) ;; (tagfile1 sin)))) ;; (defun tagfile1 (s &optional b4 ) ;; (when b4 ;; (format s "~a~%" b4)) ;; (skip-whitespace s) ;; (let* ((one (peek-char nil s nil :eof1)) ;; (two (peek-char nil s nil :eof2)) ;; (three (peek-char nil s nil :eof3)) ;; (four (peek-char nil s nil :eof4))) ;; (cond ((and (eql one #\() (eql two #\t) (eql three #\a) (eql four #\g)) ;; (eval (read s)) ;; (princ "") ;; (tagfile1 s ")) ;; ( ;; (loop for line = (read stream nil 'end) ;; until (eq line 'end) ;; do (print (list (coerce line 'integer) ;want to make single list )