(defun empty-line (line) (or (eql (length line) 0) (not (find-if (lambda (x) (not (eql x #\Space))) line)) (eql (elt line 0) #\#))) (defun scan-address-file (filename) (with-open-file (inf filename :direction :input :if-does-not-exist :error) (loop with newline = nil with erg = nil with aktadress = nil do (setf newline (read-line inf nil 'eof)) (when (eql newline 'eof) (if aktadress (setf erg (append erg (list aktadress)))) (return erg)) (if (not (empty-line newline)) (setf aktadress (append aktadress (list newline))) (when aktadress (setf erg (append erg (list aktadress))) (setf aktadress nil)))))) (defun testanf () (format t "A")) (defun testend () (format t "E")) (defun testmid () (format t "M")) (defun testelm (elm) (format t "~A" elm)) (defun generate-tex-out (filename addr-list) (with-open-file (outf filename :direction :output :if-exists :supersede) (let* ((process-adress #'(lambda (addr) (block-process 1 (car addr) #'(lambda () (format outf "\\parbox[b]{5.25cm}{~%" )) #'(lambda () (format outf "}")) #'(lambda (addr-line) (format outf "~A~%" (car addr-line))) #'(lambda () (format outf "~%"))))) (process-line #'(lambda (line) (block-process 1 line #'(lambda () (print-tex-ruler outf)) #'(lambda () ()) process-adress #'(lambda () (format outf "~% & ~%"))))) (process-page #'(lambda (page) (block-process 4 page #'(lambda () (print-tex-tableheader outf)) #'(lambda () (print-tex-tableclose outf)) process-line #'(lambda () (format outf "~%\\\\~%")))))) (block-process 20 addr-list #'(lambda () ()) #'(lambda () ()) process-page #'(lambda () (format outf "\\newpage~%")))))) (defun list-chop (n list) (do ((list1 list) (acc nil) (i 0 (incf i))) ((or (eql i n) (null list1)) (values (reverse acc) list1)) (push (pop list1) acc))) (defun block-process (n list start-fun end-fun elem-fun between-fun) (if (null list) nil (progn (funcall start-fun) (do ((list-block nil) (list1 list) (firstelem t nil)) ((null list1)) (unless firstelem (funcall between-fun)) (multiple-value-bind (block rest) (list-chop n list1) (setf list-block block) (setf list1 rest)) (funcall elem-fun list-block)) (funcall end-fun)))) (defun print-tex-tableheader (outf) (format outf "\\begin{tabular}{p{1mm}p{5.25cm}p{5.25cm}p{5.25cm}p{5.25cm}}~%")) (defun print-tex-ruler (outf) (format outf "\\rule[0mm]{0mm}{74.25mm} & ~%")) (defun print-tex-tableclose (outf) (format outf "\\end{tabular}~%"))