singleShiftDataGen([Name1,Name2,Name3,Name4],Shifts,
PersonData1,PersonData2,PersonData3,PersonData4):-
find(Name1, Shifts, PersonData1),
find(Name2, Shifts, PersonData2),
find(Name3, Shifts, PersonData3),
find(Name4, Shifts, PersonData4).
%checkSingleShiftReport(PersonData1,PersonData2, PersonData3,PersonData4).
% This method will take in one single.
find(Item, [[Item|T1]|T2], T1).
find(Item, [[_|_]|T], List):-
find(Item, T, List1),
append([], List1, List).
Input:-
singleShiftDataGen([young, collins, vieira, liu], [
[aziz, 1, 0, 0],
[blumenthal, 0, 1, 1],
[collins, 1, 1, 1],
[davis, 1, 0, 0],
[ericson, 1, 0, 0],
[fitzgerald, 1, 0, 1],
[gutierrez, 1, 0, 1],
[hughes, 1, 0, 0],
[jones, 1, 1, 1],
[kelly, 0, 1, 1],
[liu, 1, 0, 1],
[martinez, 0, 1, 1],
[patel, 1, 1, 1],
[qureshi, 1, 1, 0],
[rodriguez, 1, 0, 0],
[singh, 0, 1, 1],
[tortorella, 0, 0, 1],
[williams, 1, 0, 0],
[vieira, 0, 1, 0],
[young, 0, 1, 0],
[zimmerman, 1, 1, 1]], Person1, Person2, Person3, Person4).
Actual Output:-
Person1:- Person3
Person2:- [1, 1, 1]
Person3:- [0, 1, 0]
Person4:- [1, 0, 1]
Expected Output:-
Person1:- [0, 1, 0]
Person2:- [1, 1, 1]
Person3:- [0, 1, 0]
Person4:- [1, 0, 1]
As you can see I am getting the output which is Person1 = Person3 instead of actual integers in a list. Is there a way I can fix that? because of that my whole homework assignment won't work.
Actually, your code is working. Person1 = Person3
it's just a feature of the SWI-Prolog console interface (so called toplevel). I guess the UX choice inspiring the behaviour is to make easier to detect when Variables being reported are equals for complex values.
edit
Seems the feature cannot be disabled, but you can inspect a variable - after a successful query - with the $VARIABLE syntax (available only in toplevel):
?- write($Person1).
[0,1,0]
Person1 = [0, 1, 0].