fig23_12.pl
来自「超多的prolog源代码 具体内容见压缩包里面的programs.txt」· PL 代码 · 共 25 行
PL
25 行
% Figure 23.12 A pattern-directed program to find the greatest
% common divisor of a set of numbers.
% The follwing directive is required by some Prologs:
:- dynamic num/1.
% Production rules for finding greatest common divisor (Euclid algorithm)
:- op( 800, xfx, --->).
:- op( 300, fx, num).
[ num X, num Y, X > Y ] --->
[ NewX is X - Y, replace( num X, num NewX) ].
[ num X] ---> [ write( X), stop ].
% An initial database
num 25.
num 10.
num 15.
num 30.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?