我想计算一个平面文件中的行数,所以我写了代码:
(defun ff-rows (dir file)
  (with-open-file (str (make-pathname :name file
                                      :directory dir)
                                      :direction :input)
    (let ((rownum 0))
      (do ((line (read-line str file nil 'eof)
                 (read-line str file nil 'eof)))
          ((eql line 'eof) rownum)
        (incf rownum )))))
但是我得到了错误:
*** - READ: input stream
       #<INPUT BUFFERED FILE-STREAM CHARACTER #P"/home/lambda/Documents/flatfile"
         @4>
      ends within an object
请问这里有什么问题吗?我试着数行数;这个操作很好。
注意:这是我用来测试函数的平面文件的内容:
2 3 4 6 2 
1 2 3 1 2
2 3 4 1 6