⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fig19_9.pl

📁 超多的prolog源代码 具体内容见压缩包里面的programs.txt
💻 PL
字号:
% Figure 19.9  Learning about a path in a graph.


% Learning about path: path(StartNode,GoalNode,Path)

% A directed graph

link(a,b).
link(a,c).
link(b,c).
link(b,d).
link(d,e).

backliteral( link(X,Y), [ X:item], [ Y:item]). 
backliteral( path(X,Y,L), [ X:item], [ Y:item, L:list]).

term( list, [X|L], [ X:item, L:list]).
term( list, [], []).

prolog_predicate( link(X,Y)).

start_clause( [ path(X,Y,L)] / [X:item,Y:item,L:list] ).

% Examples

ex( path( a, a, [a])).
ex( path( b, b, [b])).
ex( path( e, e, [e])).
ex( path( f, f, [f])).
ex( path( a, c, [a,c])).
ex( path( b, e, [b,d,e])).
ex( path( a, e, [a,b,d,e])).

nex( path( a, a, [])).
nex( path( a, a, [b])).
nex( path( a, a, [b,b])).
nex( path( e, d, [e,d])).
nex( path( a, d, [a,b,c])).
nex( path( a, c, [a])).
nex( path( a, c, [a,c,a,c])).
nex( path( a, d, [a,d])).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -