在顶层显示文件内容的函数

CL-USER> (defun pseudo-cat (file)
       (with-open-file (str file :direction :input)
         (do ((line (read-line str nil 'eof)
            (read-line str nil 'eof)))
         ((eql line 'eof))
           (format t "~A~%" line))))
               
PSEUDO-CAT

 

使用示例:

CL-USER> (setf path (make-pathname :name "becky.txt"))
#P"becky>.txt"
CL-USER> (pseudo-cat path)
aaaaaaaaaaaaa

bbbbbbbbbbbbb

ccccccccccccccccc

ddddddddddddddd

eeeeeeeeeeeeeeeeee

ffffffffffffffffffffffffffff

I love U ,becky!
NIL
CL-USER>

posted @ 2013-01-02 11:39  flowjacky  阅读(160)  评论(0编辑  收藏  举报