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

📄 fig23_2.pl

📁 超多的prolog源代码 具体内容见压缩包里面的programs.txt
💻 PL
字号:
%  Figure 23.2  A Prolog meta-interpreter for tracing programs
%  in pure Prolog.


% trace( Goal): execute Prolog goal Goal displaying trace information

trace( Goal)  :-
  trace( Goal, 0).

trace( true, Depth)  :-  !.                      % Red cut; Dept = depth of call

trace( ( Goal1, Goal2), Depth)  :-  !,           % Red cut
  trace( Goal1, Depth), 
  trace( Goal2, Depth).

trace( Goal, Depth)  :-
  display( 'Call: ', Goal, Depth),
  clause( Goal, Body),
  Depth1 is Depth + 1,
  trace( Body, Depth1),
  display( 'Exit: ', Goal, Depth),
  display_redo( Goal, Depth).

trace( Goal, Depth)  :-                          % All alternatives exhausted
  display( 'Fail: ', Goal, Depth),
  fail.

display( Message, Goal, Depth)  :-
  tab( Depth), write( Message),
  write( Goal), nl.

display_redo( Goal, Depth)  :-
  true                                           % First succeed simply
  ;
  display( 'Redo: ', Goal, Depth),               % Then announce backtracking
  fail.                                          % Force backtracking  

⌨️ 快捷键说明

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