Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何从 Prolog 中的文本文件中读取数据?在 SWI-prolog 中是否有任何文件读取示例?
readfacts:- open('example.txt',read,In), repeat, read_line_to_codes(In,X),writef(" "), writef(X),nl, X=end_of_file,!, nl, close(In).
Prolog 有许多输入/输出谓词,分为两类:新的 ISO谓词或与 Edinburgh 和 DEC 10 版本兼容的旧谓词。有关包括示例代码在内的完整详细信息,请参阅上述链接后面的参考手册。