在prolog Systems跨系统的ATOM_TO_TERM/3等于什么?
我发现Swi-Prolog提供了:
atom_to_term(+atom,-term,-bindings)
使用ATOM用作read_term/2使用选项variable_names
的输入 并在绑定中返回术语和变量绑定。
https://www.sw.sw-swi-prolog.org.org.org/pldoc/pldoc/man? predicate = atom_to_term/3
但是我很难弄清楚其他prolog Systems 在这方面提供。也许有些人确实已经获得了解决方案, 他们可能想分享吗?
示例它的作用:
?- atom_to_term('X + Y', T, N).
T = _A+_B,
N = ['X'=_A, 'Y'=_B].
I find that SWI-Prolog offers:
atom_to_term(+Atom, -Term, -Bindings)
Use Atom as input to read_term/2 using the option variable_names
and return the read term in Term and the variable bindings in Bindings.
https://www.swi-prolog.org/pldoc/man?predicate=atom_to_term/3
But I am having a hard time, figuring out what other Prolog systems
offer in this respect . Maybe some people did already obtain solutions,
that they might want to share?
Example what it does:
?- atom_to_term('X + Y', T, N).
T = _A+_B,
N = ['X'=_A, 'Y'=_B].
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
两者 swi and 和 eclipse 支持
term_string/3
和atom_string/atom_string/atom_string/2 ,您可以通过其中写入
畸形字符串(语法错误)悄悄地失败,使用
其他错误处理选项为
fail> fail
(打印语法错误消息和失败)和错误(投掷错误/2项)。
Both SWI and ECLiPSe support
term_string/3
andatom_string/2
, with which you can writeTo make it quietly fail for malformed strings (syntax errors), use
Other error handling options are
fail
(print syntax error message and fail) anderror
(throw error/2 term).logTalk在所有这些后端prolystemp上运行,还有几个,提供了便携式 库在/到原子,字符(字符列表)和代码(字符代码列表)中实现阅读/写作术语。例如,使用GNU Prolog:
原子结束时的一个时期是可选的:
Logtalk, which runs on all those backend Prolog systems and several more, provides a portable
term_io
library that implements reading/writing terms from/to atoms, chars (lists of characters), and codes (lists of character codes). For example using GNU Prolog:A period at the end of the atom is optional:
好的,我已经为GNU Prolog找到了这可以起作用:
示例通过了:
但是Tau Prolog(浏览器),Scryer Prolog,Sicstus Prolog,Eclipse Prolog等呢?
Ok, I already found for GNU Prolog, that this could work:
The example passes:
But what about Tau Prolog (Browser), Scryer Prolog, SICStus Prolog, ECLiPSe Prolog etc..?