Programación Lógica

Código fuente

casiano@exthost2:~/src/LPP/170912/prolog (master)$ ls
fact.pl  Rakefile  README

casiano@exthost2:~/src/LPP/170912/prolog (master)$ cat fact.pl 
fact(X, 1) :- X<2.
fact(X, F) :- Y is X-1, fact(Y,Z), F is Z*X.

casiano@exthost2:~/src/LPP/170912/prolog (master)$ prolog
Welcome to SWI-Prolog (Multi-threaded, 32 bits, Version 5.8.0)
Copyright (c) 1990-2009 University of Amsterdam.
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.

For help, use ?- help(Topic). or ?- apropos(Word).

?- [fact].
% fact compiled 0.00 sec, 1,076 bytes
true.

?- fact(4,X).
X = 24 .

?- fact(4, 24).
true .

?- halt.
casiano@exthost2:~/src/LPP/170912/prolog (master)$



Casiano Rodriguez León 2015-01-07