Translations:Como executar o Prolog/16/en

De Augusto Baffa Wiki
Ir para navegação Ir para pesquisar

<syntaxhighlight lang="Prolog"> ?- ['2_1.pl']. /* 1. Load a program from a local file*/ yes ?- listing(factorial/2). /* 2. List program to the screen*/

factorial(0,1).

factorial(A,B) :-

          A > 0, 
          C is A-1,
          factorial(C,D),
          B is A*D. 

yes

?- factorial(10,What). /* 3. Compute factorial of 10 */ What=3628800

?- ['2_7.pl']. /* 4. Load another program */