Logtalk 2.30.1 files.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1903 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
pmoura
2007-06-12 10:39:47 +00:00
parent 84f478c301
commit 6b4bde14e1
475 changed files with 6213 additions and 6424 deletions

View File

@@ -0,0 +1,13 @@
================================================================
Logtalk - Open source object-oriented logic programming language
Release 2.30.1
Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
================================================================
To load this example and for sample queries, please see the SCRIPT file.
This folder contains an example of using tabled predicates within objects.
Currently supported compilers include B-Prolog, XSB, and YAP (when compiled
with tabling enabled).

View File

@@ -0,0 +1,32 @@
================================================================
Logtalk - Open source object-oriented logic programming language
Release 2.30.1
Copyright (c) 1998-2007 Paulo Moura. All Rights Reserved.
================================================================
% start by loading the example:
| ?- logtalk_load(tabling(loader)).
...
% use tabling to cope with a left-recursive path finding predicate
% (the order of the solutions may depend on the tabling strategy):
| ?- paths::path(1, Y).
Y = 2 ? ;
Y = 4 ? ;
Y = 3 ? ;
Y = 5 ?
yes
% use tabling to avoid repeated calculation of Fibonacci numbers:
| ?- fibonacci::fib(30, F).
F = 1346269
yes

View File

@@ -0,0 +1,3 @@
:- initialization(
logtalk_load(tabling)).

View File

@@ -0,0 +1,48 @@
:- 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.