2014-11-27 1 views
2

SWI-PROLOG 버전 6.6.6을 사용 중입니다.콘솔의 모든 요소를 ​​인쇄하지 않는 프롤로그 목록

특정 조건 자 유형의 모든 속성을 인쇄하려고합니다.

나는 사실 중 일부는

law(borrow,'To borrow Money on the credit of the United States'). 
law(commerce,'To regulate Commerce with foreign Nations, and among the several States, and with the Indian Tribes'). 
law(unifomity,'To establish an uniform Rule of Naturalization, and uniform Laws on the subject of Bankruptcies throughout the United States'). 
law(money,'To coin Money, regulate the Value thereof, and of foreign Coin, and fix the Standard of Weights and Measures'). 
law(punishment,'To provide for the Punishment of counterfeiting the Securities and current Coin of the United States'). 
law(establishment,'To establish Post Offices and post Roads'). 
law(exclusiverights,'To promote the Progress of Science and useful Arts, by securing for limited Times to Authors and Inventors the exclusive Right to their respective Writings and Discoveries'). 
law(court,'To constitute Tribunals inferior to the supreme Court'). 

입니다 인수에 대응 2.

와 법이라는 술어가 등

지금은 유형을 입력하여 법에 액세스하려면. 이러한

power(X) :- law(X,Y), display('\nCongress has the power : '),display(Y). 
powers(ALL) :- display('\nCongress has the powers : '), law(_,Y), display('\n'), display(Y). 

, 이것은 완벽하게 작동합니다. 이제 사용자가 모든 법률 유형을 알고 있으므로 해당 법률을 얻기 위해 쿼리를 입력 할 수 있습니다. 예 power(money).

이 경우 모든 키워드를 가져와 목록에 추가하고 목록을 표시하는 쿼리를 작성했습니다. 그러나 마지막으로 인쇄 된 목록이 완전하지 않습니다.

powerList(L) :- findall(X,law(X,_), L). 

나는이 코드를 사용하여 목록을 얻습니다. 그러나 콘솔의 출력이도 piracyfelony 후 많은 법 종류가 있습니다 그리고 그들은 콘솔에 인쇄되지 않아요,

L = [borrow, commerce, unifomity, money, punishment, establishment, exclusiverights, court, piracyfelony|...]. 

입니다하지만. 어떻게 인쇄합니까?

+0

FAQ는 SWI-Prolog 웹 사이트에서 답변을 제공합니다 : http://www.swi-prolog.org/FAQ/ AllOutput.html –

+0

@PauloMoura : 7 용으로 오래되었습니다. – false

+2

@false "SWI-PROLOG 버전 6.6.6을 사용 중입니다."라는 질문이 시작됩니다. –

답변

2

이것은 출력을 짧게 유지하려고하는 프롤로그의 최상위 루프의 기능입니다.

에게, 당신이 그것을 변경하는 방법을 알아 보려면 어떤 프롤로그 플래그 두 개 이상의 요소 목록이되는 값이 당신의 프롤로그 지원 : 이제

?- current_prolog_flag(F,Options), Options = [_,_|_]. 
F = debugger_print_options, 
Options = [quoted(true), portray(true), max_depth(10), attributes(portray), spacing(next_argument)] ; 
F = toplevel_print_options, 
Options = [quoted(true), portray(true), max_depth(10), spacing(next_argument)] ; 
F = argv, 
Options = [swipl, '-f', none] ; 
false. 

를 적절하게 수정 :

?- length(L,10). 
L = [_G303, _G306, _G309, _G312, _G315, _G318, _G321, _G324, _G327|...]. 

?- set_prolog_flag(toplevel_print_options,[quoted(true), portray(true), max_depth(0), spacing(next_argument)]). 
true. 

?- length(L,10). 
L = [_G303, _G306, _G309, _G312, _G315, _G318, _G321, _G324, _G327, _G330]. 

(SWI 7로 시작하는 최신 버전에는 다른 플래그 값인 answer_write_options이 있습니다.)