2
我是新來的Prolog,我們使用的大學,它被要求來定義一個聖人,我寫了一個快速腳本接聽到要求:優化Prolog的腳本
% List of Saints taken from https://en.wikipedia.org/wiki/List_of_saints
% Rule to define sainthood
saint(X) :-
human(X),
has_faith(X),
died(X),
made_miracles(X).
% List of humans
human('Abadiu of phoenix').
human('Abakuh').
human('Abamun of Tarnut').
human('Saint Phoenix').
human('Fabrizio').
human('Bob').
% List of believer
has_faith('Abadiu of phoenix').
has_faith('Abakuh').
has_faith('Abamun of Tarnut').
has_faith('Saint Phoenix').
has_faith('Bob').
% List of died
died('Abadiu of phoenix').
died('Abakuh').
died('Abamun of Tarnut').
died('Saint Phoenix').
made_miracles('Abadiu of phoenix').
made_miracles('Abakuh').
made_miracles('Abamun of Tarnut').
made_miracles('Saint Phoenix').
但我想改善的代碼,並在同一時間學習Prolog的,我用:
human(X,['Abadiu of phoenix','Abakuh','Abamun of Tarnut','Saint Phoenix','Fabrizio']).
或
human(['Abadiu of phoenix','Abakuh','Abamun of Tarnut','Saint Phoenix','Fabrizio']).
爲了創建一個人類的陣列,但沒有成功,我需要看看爲了改善上述代碼?