実践Common Lispを読んでみる8

実践Common Lisp

実践Common Lisp

今日から、第15章・実践:パスネーム可搬ライブラリ。
…動かなかった。バグは明日の私に任せて眠ることにする。
以下、ソースコード

(defun component-present-p (value)
  (and value (not (eql value :unspecific))))
(defun directory-pathname-p (p)
  (and
   (not (component-present-p (pathname-name p)))
   (not (component-present-p (pathname-type p)))
   p))
(defun pathname-as-directory (name)
  (let ((pathname (pathname name)))
    (when (wild-pathname-p pathname)
      (error "can't reliably convert wild pathnames."))
    (if (not (directory-pathname-p name))
	(make-pathname
	 :directory	(append (or (pathname-directory pathname) (list :relative))
				(list (file-namestring pathname)))
	 :name		nil
	 :type		nil
	 :defaults	pathname)
	pathname)))
(defun directory-wildcard (dirname)
  (make-pathname
   :name :wild
   :type #-clisp :wild #+clisp nil
   :defaults (pathname-as-directory dirname)))
(defun list-directory (dirname)
  (when (wild-pathname-p dirname)
    (error "Can only list concrete directory names."))
  (directory (directory-wildcard dirname)))

http://dl.getdropbox.com/u/228440/veleno-samples/lisp-samples/sample.lisp