在顶层显示文件内容的函数
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)
aaaaaaaaaaaaabbbbbbbbbbbbb
ccccccccccccccccc
ddddddddddddddd
eeeeeeeeeeeeeeeeee
ffffffffffffffffffffffffffff
I love U ,becky!
NIL
CL-USER>