This is the code for implementing the "cat" command with lisp, as described in ANSI Common Lisp , page 122.
(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))))
Why is the read-line function executed twice? I tried to run it with only one line of reading, but Lisp could not finish the code.
input lisp common-lisp
prosseek
source share