我的文件夹中有25个文本文件要测试。但是我不想为25个文件编写代码,这意味着测试这些文件需要25行。
(myfunc "myfiles/txtfile1.txt")
(myfunc "myfiles/txtfile2.txt")
...
如何使用for循环调用此函数?像下面的示例代码。对不起,我的英语不好
(loop for x from 1 to 25
do ((myfunc "myfiles/txtfile~a.txt" x))
)
)
您可以使用以下格式将文件名末尾的数字连接起来:
(x的循环从1到25做(myfunc(格式nil“ myfiles / txtfile〜a.txt” x)))
一种简单的方法是使用format
功能(manual):
(loop for x from 1 to 25
do (myfunc (format nil "myfiles/txtfile~a.txt" x)))
由于所有文件都在目录中,因此您还可以查看directory
预定义功能(manual,question in SO)。