我要加载这个简单的东西放到我的责任编辑:

Write:-repeat,write("hi"),nl,fail.

所以它打印的 “hi”。

我应该怎么办?

目前,我正在尝试做File->New

和保存文件名为写入E:\Program Files\pl\xpce\prolog\lib

当执行查询:

- ?写

它的印刷:

1 ?- Write.
% ... 1,000,000 ............ 10,000,000 years later
% 
%       >> 42 << (last release gives the question)

<强>为什么吗

有帮助吗?

解决方案

修改

我做了一些调查研究。显然,这是SWI-Prolog的呢,当你问它大约一个非实例变量。

$ prolog
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 5.6.64)
Copyright (c) 1990-2008 University of Amsterdam.
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.

For help, use ?- help(Topic). or ?- apropos(Word).

?- X.
% ... 1,000,000 ............ 10,000,000 years later
% 
%       >> 42 << (last release gives the question)
?- 

<强>更新

更改为小写作品的名称。大写为变量:

helloworld.prolog:

helloworld:-write('Hello World!'),nl,fail.

然后:

$ prolog
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 5.6.64)
Copyright (c) 1990-2008 University of Amsterdam.
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.

For help, use ?- help(Topic). or ?- apropos(Word).

?- ['helloworld.prolog'].
% helloworld.prolog compiled 0.00 sec, 1,376 bytes
true.

?- helloworld.
Hello World!
false.

?- 

请注意,您必须先谘询文件。我尝试了这一点,它的工作原理是肯定的。

其他提示

您需要命名的程序write,不Write。大写字母开始是变量。 (这可能是减少混乱,如果你把它叫做别的东西像writeHi什么的,所以它不具有相同的名称作为一个内置的程序,但它仍然会工作的时候你怎么称呼它write因为你的写有不同的元数比内置在一个)。

此外,你可能想用"hi"更换'hi',虽然它会工作无论哪种方式(但只有第二个版本将实际打印的字喜到屏幕上 - 你的版本将打印它作为一个整数列表)。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top