(原)在ubuntu 中安装 swi prolog 和 简单的使用

  1. 参考网址:http://www0.cs.ucl.ac.uk/staff/mahmed/teaching/intro.html
  2. 参考网址:http://www.swi-prolog.org/build/Debian.html
  3. 安装
% sudo apt-add-repository ppa:swi-prolog/stable
% sudo apt-get update
% sudo apt-get install swi-prolog

2. 检测ubuntu 版本的方法 :打开 terminal 输入 swipl --version

3. 检索方法:

by loading a database (your program) holding the facts and rules you want to use with; ['progName.pl'] or compile('progName.pl') or consult('progName.pl'), for example

?- ['family.pl'].
?- compile('family.pl').
?- consult('family.pl').

注意:一定在结尾处有 "."

4. 退出方法:

?- halt.
<Ctrl>+<D>

5.查询方法:

The listing command can be used to list the predicates that you have specified in your program or those in to the built in the interpreter, for example:

?- listing(grandparent).

grandparent(X, Y) :-
parent(X, Z),
parent(Z, Y). Yes
上一篇:swi prolog 与c#


下一篇:原生js格式化json和格式化xml的方法