Aim: Write a Prolog program for finding a set, which is result of the intersection of the two given sets.
Prolog Program Code:
domains
X=symbol*
Y=symbol
predicates
union(X,X,X)
inter(X,X,X)
member(Y,X)
clauses
union([],L,L).
union([H|T],L,[H|U]):-union(T,L,U),not(member(H,U)),!.
union([_|T],L,U):-union(T,L,U).
inter([],_,[]).
inter([H|T],L,[H|Lr]):-member(H,L),inter(T,L,Lr),!.
inter([H|T],L,Lr):-not(member(H,L)),inter(T,L,Lr).
member(H,[H|_]).
member(H,[_|L]):-member(H,L).
1 Comments
Nobfirfrat_he Juan Reyes https://wakelet.com/wake/EKE_UbClKitS_5bKCr2d8
ReplyDeletesoundzeppomur