我有一些员工:
employee(2,2,'George','Johnson','12/16/1987').
employee(4,3,'Noah','Jones','6/9/1984').
employee(5,4,'Jack','Brown','2/16/1992').
employee(6,6,'Charlie','Davis','3/28/1997').
employee(7,1,'Leo','Miller','6/6/1997').
employee(8,6,'Jacob','Wilson','2/16/1997').
我想打印所有这些。我现在这样做:
run :- findall(Id, employee(Id, _, _, _, _), L), writeEmployees(L).
writeEmployees([]) :- !.
writeEmployees([Id|T]) :- employee(Id, PosId, FN, LN, Birth),
writeq(employee(Id, PosId, FN, LN, Birth)), nl, writeEmployees(T).
它可以工作,但看起来不太好,我的意思是,'_' 太多了,我必须写 'Id, PosId, FN, LN, Birth' 字符串。如何在 findall() 中直接找到员工?