I want to read in the contents of a file into a list. Some of my attempts so far have been -
(defun get-file (filename)
(let ((x (open filename)))
(when x
(loop for line = (read-line x nil)
while line do (list line)))
(close x)))
(defun get-file (filename)
(let ((x (open filename :if-does-not-exist nil)) (contents (list nil)))
(when x
(loop for line = (read-line x nil)
while line do (cons contents line)))
(close x) contents))
(defun get-file (filename)
(let ((x (open filename :if-does-not-exist nil)) (contents nil))
(when x
(loop for line = (read-line x nil)
while line do (append contents line)))
(close x) contents))
None of these worked. Can anyone tell me a way? Or even better - how to put all of the contents into an array?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…