This is a terrible example, but say I have points a
, b
and c
and blue and red lines, e.g. line(blue,a)
means point a
lines on a blue line.
point(a).
point(b).
point(c).
line(blue,a).
line(blue,b).
line(red,a).
line(red,c).
I want to find out which points P
lie on more than one line (so a
in this case as it's on the blue and red line).
I made a start and got this:
multiple_points(P) :- point(P), point(_,P).
When I run the query ?- multiple_points(P).
all points that are on a line appear, but I only want duplicates shown to see which points appear on more than one line.
Is there an easy one line way to only show values of P
which are duplicates?