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

📄 fig23_13.pl

📁 超多的prolog源代码 具体内容见压缩包里面的programs.txt
💻 PL
字号:
%  Figure 23.13  A small interpreter for pattern-directed programs.


%   A small interpreter for pattern-directed programs
%   The system's database is manipulated through assert/retract


:-  op( 800, xfx, --->).

% run: execute production rules of the form
%      Condition ---> Action until action `stop' is triggered

run  :-
  Condition ---> Action,         % A production rule
  test( Condition),              % Precondition satisfied?
  execute( Action).

% test( [ Condition1, Condition2, ...])  if all conditions true

test( []).                       % Empty condition

test( [First|Rest])  :-          % Test conjunctive condition
  call( First),
  test( Rest).

% execute( [ Action1, Action2, ...]): execute list of actions

execute( [ stop])  :-  !.         % Stop execution

execute( [])  :-                 % Empty action (execution cycle completed)
  run.                           % Continue with next execution cycle

execute( [First | Rest])  :-
  call( First),
  execute( Rest).

replace( A, B)  :-               % Replace A with B in database
  retract( A), !,                % Retract once only
  assert( B).

⌨️ 快捷键说明

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