New 并将名为 Wri-6ren">
gpt4 book ai didi

procedure - 序言 : Making a procedure to print Hello World

转载 作者:行者123 更新时间:2023-12-04 02:03:53 24 4
gpt4 key购买 nike

我想将这个简单的东西加载到我的编辑器中:

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

所以它打印“嗨”。

我该怎么办?

我目前正在尝试做 File->New
并将名为 Write 的文件保存到 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.

?-

请注意,您必须先查阅文件。我试过了,它肯定有效。

关于procedure - 序言 : Making a procedure to print Hello World,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2556253/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com