union.pl

来自「关系算子的PROLOG描述 prolog人工智能语言」· PL 代码 · 共 18 行

PL
18
字号
% This buffer is for notes you don't want to save.
% If you want to create a file, visit that file with C-x C-f,
% then enter the text in that file's own buffer.


%uni(+SETA,+SETB,-SETC).
%method1
%uni(A,[],A).
%uni(A,[H|T],[H|B]):-uni(A,T,B),not(member(H,A)).
%uni(A,[H|T],B):-uni(A,T,B), member(H,A).

%method2
%uni(A,B,X):-union(A,B,X).

uni(A,[],A).
uni(A,[HB|TB],[HB|TC]):-uni(A,TB,TC),not(member(HB,A)).
uni(A,[HB|TB],TC):-uni(A,TB,TC), member(HB,A).

⌨️ 快捷键说明

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