我收到了以下代码(来自this教程)
main:-
open(’houses.txt’,read,Str),
read_houses(Str,Houses),
close(Str),
write(Houses), nl.
read_houses(Stream,[]):-
at_end_of_stream(Stream).
read_houses(Stream,[X|L]):-
\+ at_end_of_stream(Stream),
read(Stream,X),
read_houses(Stream,L).
houses.txt:
gryffindor.
hufflepuff.
ravenclaw.
slytherin.
我像这样加载它:
$ swipl -s flp18-log.pl
当我想要启动主要“功能” - >
时,问题就出现了?- main.
ERROR: Undefined procedure: main/1
ERROR: However, there are definitions for:
ERROR: main/0
ERROR:
ERROR: In:
ERROR: [9] main([])
ERROR: [8] prolog_main:main at /usr/local/Cellar/swi-prolog/HEAD-e6bbda4/libexec/lib/swipl-7.7.12/library/main.pl:82
ERROR: [7] <user>
Exception: (9) main([]) ?
我花了几个小时搞清楚什么是错的。不成功。你能帮忙吗?
答案 0 :(得分:0)
是:
open('houses.txt',read,Str)
与&#39;,而不是'。