This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/Logtalk/examples/tabling/tabling.lgt
pmoura 6b4bde14e1 Logtalk 2.30.1 files.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1903 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
2007-06-12 10:39:47 +00:00

49 lines
828 B
Plaintext

:- object(paths).
:- info([
version is 1.0,
author is 'Paulo Moura',
date is 2007/05/14,
comment is 'Simple tabling example using graph paths.',
source is 'Direct conversion to Logtalk of a XSB tabling example.']).
:- public(path/2).
:- table(path/2).
path(X,Y) :- path(X,Z), edge(Z,Y).
path(X,Y) :- edge(X,Y).
edge(1,2).
edge(2,2).
edge(2,4).
edge(2,3).
edge(3,5).
:- end_object.
:- object(fibonacci).
:- info([
version is 1.1,
author is 'Paulo Moura',
date is 2007/05/28,
comment is 'Simple tabling example using Fibonacci numbers.',
source is 'Direct conversion to Logtalk of a B-Prolog tabling example.']).
:- public(fib/2).
:- table(fib/2).
fib(0, 1).
fib(1, 1).
fib(N,F) :-
N > 1,
N1 is N - 1,
N2 is N - 2,
fib(N1, F1),
fib(N2, F2),
F is F1 + F2.
:- end_object.