以下规则应将我的List写入与文件关联的流,但它是一个永不停止的难以理解的字符流。帮助
writeListToFile(List, File) :- open(File, write, Stream),
\+ writeListToStream(Stream, List),
close(Stream).
writeListToStream(Stream, List) :- member(Element, List),
write(Stream, Element),
write(Stream, ' '),
fail.
即使使用像
这样的简单列表,也会发生这种情况List = ['a', 'b'].
执行
writeListToFile(List, 'output.txt').
我的SWI-Prolog没有回复,我看到文件中充满了无穷无尽的
“_ G889 _G892 _G895 _G898 _G901 _G904 _G907 _G910 _G913 _G916 _G919 _G922 _G925 _G928 _G931 _G934 _G937 _G940 _G943 _G946 _G949 _G952 _G955 _G958 _G961 _G964 _G967 _G970 _G973 _G911 _G994 _G992 _G988 _G10088 _G991 _G994 _G9912 _G1000 _G1003 _G1006 _G1009 _G1012 _G1015 _G1018“
等