我的下一个项目是写一个刽子手游戏.我认为它可以帮助我刷新字符串并提交I/O.
目前,我一直在阅读一个字符串文件到列表中.我试图避免全局变量,所以有人能指出我正确的方向将这个(可能已损坏的)代码变成一个返回列表的函数吗?
(defun read-word-list ()
"Returns a list of words read in from a file."
(let ((word-list (make-array 0
:adjustable t
:fill-pointer 0)))
(with-open-file (stream #p"wordlist.txt")
(loop for line = (read-line stream)
while line
(push line word-list)))
(select-target-word word-list)))))
Run Code Online (Sandbox Code Playgroud)