I am using SICStus Prolog and have a set of facts:
student('John Henry', 'Maths').
student('Jim Henry', 'Maths').
student('John Alan', 'Maths').
student('Alan Smith', 'Computing').
student('Gary Henry', 'Maths').
I want to get the shared subject of two students where both students are different, so I got:
sharedSubject(S1, S2, Sub) :- S1 \== S2, student(S1, Sub), student(S2, Sub).
However, when I enter:
sharedSubject('John Henry', F, E).
I get F = 'John Henry'
. Can someone point out where I am going wrong and what I need to do? Thanks.