LISP初学 发表于 2020-11-6 12:36:54

lisp怎么读取文件数据并赋值给程序

lisp怎么读取文件数据并赋值给程序,请指教,谢谢!

taoyi0727 发表于 2020-11-6 14:32:49

(setq file (open 路径 "r");打开文件
(setq str-lst "")
(whlie (setq str (real-line file));获取文件内每行文字
(strcat str-lst str)
)
(close file);关闭文件

paulpipi 发表于 2020-11-6 14:53:05

真好,学习了,谢谢

菜卷鱼 发表于 2020-11-7 10:09:39

taoyi0727 发表于 2020-11-6 14:32
(setq file (open 路径 "r");打开文件
(setq str-lst "")
(whlie (setq str (real-line file));获取文件 ...

要不要纪念一下你的996?

mokson 发表于 2020-11-7 10:25:43

本帖最后由 mokson 于 2020-11-7 10:39 编辑

如何自动批量地设置变量为: setq name1, name2, name3 .... name(n) 的形式,
我想了很久,不得骑姐:

setq n 0)
(whlie (< n 10)
(setq (strcat "name" (rtos n)) n)
(setq n (1+ n))
)


;提示语法错误,
;各位老大们,想实现这样的效果,有其它可行的方法吗?

原地踏步 发表于 2020-11-7 15:50:50

(defun c:tt ()
(setq n 0)
(while (< n 10)
    (setq a (strcat "name" (rtos n)))
    (set (read a) n)
    (setq n (1+ n))
)
)
页: [1]
查看完整版本: lisp怎么读取文件数据并赋值给程序