Home > Blockchain >  Prolog for sets (lists)
Prolog for sets (lists)

Time:09-26

I'm learning prolog through youtube videos and I'm struggling a lot with lists. I'm trying to write a predicate overlap(A,B) that will find out if A and B have any common elements. Which I'm able to do but how can I use this overlap(A,B) predicate to define another predicate disjoint(S1, S2)?

CodePudding user response:

If there is no overlap between S1and S2 then S1and S2 are disjoint:

disjoint(S1,S2) :- \  overlap(S1,S2).
  • Related