superclass('Horde', 'Blood Elf').
superclass('Horde', 'Orc').
element('Blood Elf', ['Paladin', 'Priest','Mage','Warlock','Death Knight','Rogue']).
element('Orc', ['Warrior', 'Shaman','Warlock','Death Knight','Hunter','Rogue']).
find(A):-
( element(_,B),member(A,B)
-> forall(
(element(_,B), member(A,B)),
(element(C,B), superclass(D,C), format('~w -> ~w -> ~w\n',[D,C,A])))
; superclass(A, _)
-> format('~w\n',A), forall(superclass(A,B),format('\t~w\n',B))
).
및 find('Rogue').
에 대한 결과 두 가지 조건이 작동하지 않습니다. 결국 술어는 그 중 단 하나만 인쇄합니다. 그러나, 내가 콘솔 forall(..)
copypaste, 그것은 나에게 모두 2 결과를 제공합니다. 왜?
어떻게 forall/2? – false
forall ((요소 (_, B), 멤버 ('Rogue', B)), (요소 (C, B), 수퍼 클래스 (D, C) – defusioner