How to create and write into text file in Lisp

ε祈祈猫儿з 提交于 2019-12-01 02:47:03

问题


I want to know, how to create and write text file in lisp. I just want to write simple line like:

"break 1"
"break 2"

I am using LispWorks IDE on Window 7


回答1:


(with-open-file (str "/.../filename.txt"
                     :direction :output
                     :if-exists :supersede
                     :if-does-not-exist :create)
  (format str "write anything ~%"))

You may also choose different settings for the with-open-file macro. If you use :append instead of :supersede then you can write into the text file while preserving its context instead of superseding the available content.



来源:https://stackoverflow.com/questions/9495376/how-to-create-and-write-into-text-file-in-lisp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!