如何从文件中读取Sexp [英] How to read sexp from file

查看:54
本文介绍了如何从文件中读取Sexp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我使用写文件

(with-open-file (s "~/example.sexp" :direction :output)
           (write '(1 2 3) :stream s)
           (write '(4 5 6) :stream s)
           (write '(7 8 9) :stream s))

创建的文件包含

(1 2 3)(4 5 6)(7 8 9)

但是当我尝试打开并使用

But when I attempt to open and read it using

(setf f (open "~/example.sexp"))
(read :input-stream f)

我收到:INPUT-STREAM不是STREAM类型"错误.

I get an ":INPUT-STREAM is not of type STREAM" error.

(type-of f)

返回STREAM :: LATIN-1-FILE-STREAM,它看起来至少与我需要的 close 相同.有什么区别?

returns STREAM::LATIN-1-FILE-STREAM which looks like it is at least close to what I need. What is the difference?

如何阅读已写入文件的列表?

How can I read the lists I've written to the file?

推荐答案

您将参数 READ 弄错了.应该只是(read f),而不是(read:input-stream f).

You got the arguments to READ wrong. It should be simply (read f), not (read :input-stream f).

这篇关于如何从文件中读取Sexp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆