1 ;;; $Id: utils.cl,v 1.1 2002/09/16 01:13:49 kevin Exp $
3 ;;;; General purpose utilities
8 (defmacro aif (test then &optional else)
12 (defmacro awhen (test-form &body body)
16 (defun keyword-symbol? (x)
17 "Returns T if object is a symbol in the keyword package"
19 (string-equal "keyword" (package-name (symbol-package x)))))
21 (defun list-to-spaced-string (list)
22 (format nil "~{ ~A~}" list))
24 (defun indent-spaces (n &optional (stream *standard-output*))
25 "Indent n*2 spaces to output stream"
26 (let ((fmt (format nil "~~~D~~T" (+ n n))))
29 (defun print-file-contents (file &optional (strm *standard-output*))
30 "Opens a reads a file. Returns the contents as a single string"
31 (when (probe-file file)
32 (with-open-file (in file :direction :input)
33 (do ((line (read-line in nil 'eof)
34 (read-line in nil 'eof)))
36 (format strm "~A~%" line)))))
38 (defun date-string (ut)
39 (if (typep ut 'integer)
40 (multiple-value-bind (sec min hr day mon year dow daylight-p zone)
41 (decode-universal-time ut)
42 (declare (ignore daylight-p zone))
43 (format nil "~[Mon~;Tue~;Wed~;Thu~;Fri~;Sat~;Sun~], ~
44 ~d ~[Jan~;Feb~;Mar~;Apr~;May~;Jun~;Jul~;Aug~;Sep~;Oct~;Nov~;Dec~] ~d ~