Logtalk 2.28.2 files.

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1712 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
pmoura
2006-11-07 18:11:49 +00:00
parent 36a326908c
commit 2d7ccc1278
168 changed files with 3143 additions and 1018 deletions

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================
@@ -27,7 +27,9 @@ code or from known Prolog text books and are copyrighted by the respective
authors.
These are programming examples, meaning that you should study the source
files to fully understand them.
files to fully understand them. However, note that some examples purpose
is to illustrate general principles rather than being adequate, efficient
solutions for deployment code.
All examples are formatted using four spaces tabs.
@@ -109,10 +111,11 @@ lpa
examples adopted from the LPA Prolog++ system
metapredicates
example of using metapredicates in Logtalk objects
example of using meta-predicates in Logtalk objects
metainterpreters
some examples of simple metainterpreters
some examples of simple meta-interpreters defined as categories which
may be imported by "database" objects
mi
multi-inheritance examples
@@ -177,5 +180,8 @@ symdiff
example of using parametric objects to implement symbolic expression
differentiation and simplification
threads
several simple examples of multi-threading programming
viewpoints
example on how to implement property and value sharing with prototypes

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================
@@ -20,6 +20,13 @@ Result = -9
yes
% Recognize MAC addresses:
| ?- macaddr::valid("00:1e:4a:ef:72:8b").
yes
% solve a cellphone keypad encoded enigma:
| ?- enigma::solve("4 96853 5683 86 4283 346637 9484 968 8664448", Message).

View File

@@ -0,0 +1,17 @@
:- object(macaddr).
:- public(valid/1).
valid(Address) :-
phrase(mac, Address).
mac --> digits, ":", digits, ":", digits, ":", digits, ":", digits, ":", digits.
digits --> digit, digit.
digit --> [C], {0'0 =< C, C =< 0'9}.
digit --> [C], {0'a =< C, C =< 0'f}.
digit --> [C], {0'A =< C, C =< 0'F}.
:- end_object.

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================
@@ -9,7 +9,7 @@ Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
To load this example and for sample queries, please see the SCRIPT file.
This example contains simple meta-interpreters for pure Prolog encapsulated
in Logtalk objects:
in Logtalk categories:
solver
simple meta-interpreter for pure Prolog
@@ -21,3 +21,6 @@ in Logtalk objects:
tracer
simple meta-interpreter for pure Prolog that traces proof
construction
To use a meta-interpreter with an object, simply import the corresponding
category.

View File

@@ -1,113 +0,0 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================
% start by loading the example:
| ?- logtalk_load(metainterpreters(loader)).
...
% solver - a simple meta-interpreter for pure Prolog:
| ?- solver::assertz(member_of(H, [H| _])).
H = _G178
yes
| ?- solver::assertz((member_of(H, [_| T]) :- member_of(H, T))).
H = _G181
T = _G179
yes
| ?- solver::solve(member_of(2, [1,2,3])).
yes
| ?- solver::solve(member_of(X, [1,2,3])).
X = 1 ;
X = 2 ;
X = 3
yes
% proof_tree - a simple meta-interpreter for pure Prolog that
% construct a proof tree:
| ?- proof_tree::assertz(member_of(H, [H| _])).
H = _G178
yes
| ?- proof_tree::assertz((member_of(H, [_| T]) :- member_of(H, T))).
H = _G181
T = _G179
yes
| ?- proof_tree::solve(member_of(2, [1,2,3]), Tree).
Tree = member_of(2, [1, 2, 3]):- (member_of(2, [2, 3]):-true)
yes
% tracer - a simple meta-interpreter for tracing goal proofs
% using pure Prolog:
| ?- tracer::assertz(member_of(H, [H| _])).
H = _G178
yes
| ?- tracer::assertz((member_of(H, [_| T]) :- member_of(H, T))).
H = _G181
T = _G179
yes
| ?- tracer::trace(member_of(3, [1,2,3])).
1 call: member_of(3, [1, 2, 3])
2 call: member_of(3, [2, 3])
3 call: member_of(3, [3])
3 exit: member_of(3, [3])
2 exit: member_of(3, [2, 3])
1 exit: member_of(3, [1, 2, 3])
yes
| ?- tracer::trace(member_of(X, [1,2,3])).
1 call: member_of(_G187, [1, 2, 3])
1 exit: member_of(1, [1, 2, 3])
X = 1 ;
1 redo: member_of(1, [1, 2, 3])
2 call: member_of(_G187, [2, 3])
2 exit: member_of(2, [2, 3])
1 exit: member_of(2, [1, 2, 3])
X = 2 ;
1 redo: member_of(2, [1, 2, 3])
2 redo: member_of(2, [2, 3])
3 call: member_of(_G187, [3])
3 exit: member_of(3, [3])
2 exit: member_of(3, [2, 3])
1 exit: member_of(3, [1, 2, 3])
X = 3 ;
1 redo: member_of(3, [1, 2, 3])
2 redo: member_of(3, [2, 3])
3 redo: member_of(3, [3])
4 call: member_of(_G187, [])
4 fail: member_of(_G187, [])
3 fail: member_of(_G187, [3])
2 fail: member_of(_G187, [2, 3])
1 fail: member_of(_G187, [1, 2, 3])
no

View File

@@ -0,0 +1,100 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================
% start by loading the example:
| ?- logtalk_load(metainterpreters(loader)).
...
% direct call of p/1:
| ?- ?- database::p(X).
X = 1 ;
X = 2
yes
% solver - a simple meta-interpreter for pure Prolog:
| ?- database::solve(p(X)).
X = 1 ;
X = 2
yes
| ?- database::proof_tree(p(X), Tree).
X = 1
Tree = p(1):- (q(1, a):- (s(1):-true), (t(1, a):-true)), (r(a):-true) ;
X = 2
Tree = p(2):- (q(2, b):- (s(2):-true), (t(2, b):-true)), (r(b):-true)
yes
% tracer - a simple meta-interpreter for tracing goal proofs using pure Prolog:
| ?- database::trace(p(X)).
1 call: p(_G180)
2 call: q(_G180, _G316)
3 call: s(_G180)
3 exit: s(1)
3 call: t(1, _G316)
3 exit: t(1, a)
2 exit: q(1, a)
2 call: r(a)
2 exit: r(a)
1 exit: p(1)
X = 1 ;
1 redo: p(1)
2 redo: r(a)
2 fail: r(a)
2 redo: q(1, a)
3 redo: t(1, a)
3 fail: t(1, _G316)
3 redo: s(1)
3 exit: s(2)
3 call: t(2, _G316)
3 exit: t(2, b)
2 exit: q(2, b)
2 call: r(b)
2 exit: r(b)
1 exit: p(2)
X = 2 ;
1 redo: p(2)
2 redo: r(b)
2 fail: r(b)
2 redo: q(2, b)
3 redo: t(2, b)
3 fail: t(2, _G316)
3 redo: s(2)
3 exit: s(3)
3 call: t(3, _G316)
3 fail: t(3, _G316)
3 redo: s(3)
3 fail: s(_G180)
2 fail: q(_G180, _G316)
1 fail: p(_G180)
no
% another example: expert system rules:
| rules::prove(weather(Wheather)).
Wheather = raining
yes
| ?- rules::prove(goto(Where)).
Where = cinema
yes

View File

@@ -0,0 +1,23 @@
:- object(database,
imports(solver, proof_tree, tracer)).
:- public(p/1).
:- private(q/2, r/1, s/1, t/2).
:- dynamic(p/1, q/2, r/1, s/1, t/2).
p(X) :- q(X, Y), r(Y).
q(X, Y) :- s(X), t(X, Y).
r(a).
r(b).
s(1).
s(2).
s(3).
t(1, a).
t(2, b).
:- end_object.

View File

@@ -0,0 +1,48 @@
:- category(engine).
:- public(prove/1).
:- public(if/1).
:- dynamic(if/1).
:- op(200, fx, if).
:- op(100, xfx, then).
prove(true) :-
!.
prove([]) :-
!.
prove([Cond| Conds]) :-
!,
prove(Cond),
prove(Conds).
prove(Fact) :-
::clause(Fact, true).
prove(Conclusion) :-
::clause(if Conds then Conclusion, true),
prove(Conds).
:- end_category.
:- object(rules,
imports(engine)).
:- public([weather/1, weekday/1, time/1, goto/1]).
:- dynamic([weather/1, weekday/1, time/1, goto/1]).
:- op(200, fx, if).
:- op(100, xfx, then).
if [weather(sunny), weekday(weekend), time(day)] then goto(beach).
if [weather(raining), weekday(weekend), time(night)] then goto(cinema).
if [weekday(workday), time(day)] then goto(work).
weather(raining).
weekday(weekend).
time(night).
:- end_object.

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================
@@ -8,7 +8,7 @@ Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
To load this example and for sample queries, please see the SCRIPT file.
This example shows the use of metapredicates in Logtalk. Metapredicates are
This example shows the use of meta-predicates in Logtalk. Meta-predicates are
predicates whose head contains arguments that will be called as goals in the
body of the predicate definition.
@@ -20,5 +20,5 @@ This example defines two objects:
of the elements being sorted
tracer
this object implements a metapredicate that is used by sort(_) to
this object implements a meta-predicate that is used by sort(_) to
trace the sorting algorithm steps

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,12 +0,0 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================
To load this example and for sample queries, please see the SCRIPT file.
This folder contains three examples of parametric objects, the first two
dealing with time and date values and the third one representing rectangles.

View File

@@ -0,0 +1,12 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================
To load this example and for sample queries, please see the SCRIPT file.
This folder contains some examples of parametric objects, dealing with
lists, time and date values, and rectangles.

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================
@@ -12,6 +12,30 @@ Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
...
% some queries using the list parametric object:
| ?- [1, 2, 3]::member(X).
X = 1 ;
X = 2 ;
X = 3 ;
no
| ?- [1, 2, 3]::last(X).
X = 3
yes
| ?- [1, 2, 3]::nextto(2, Y).
Y = 3
yes
| ?- []::member(X)
no
% some queries using the time and date parametric objects:
| ?- date(Year, Month, Day)::today.
@@ -19,14 +43,12 @@ Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
Year = 2000
Month = 8
Day = 15
Yes
yes
| ?- date(Year, _, _)::(today, \+ leap_year).
Year = 2002
yes
@@ -35,8 +57,7 @@ yes
Hours = 13
Mins = 52
Secs = 42
Yes
yes
| ?- R = rectangle(W, H, X, Y), R::init, R::move(3, 4, NR), NR::position(X2, Y2).
@@ -49,5 +70,4 @@ Y = 0
NR = rectangle(2, 1, 3, 4)
X2 = 3
Y2 = 4
Yes
yes

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================
@@ -9,6 +9,9 @@ Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
This directory contains two versions, one prototype-based and the
other one class-based, of a very simple geometric shapes hierarchy.
The aim of this example is to compare the pros and cons of using
either prototypes or classes for defining object hierarchies.
ph
prototype-based version

View File

@@ -1,14 +0,0 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================
To load this example and for sample queries, please see the SCRIPT file.
You will need to load the following files in the library directory:
events_loader, types_loader, and hierarchies_loader. Alternatively,
you may load the library all_loader file to load all library entities.

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -0,0 +1,10 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================
To load this example and for sample queries, please see the SCRIPT
file.

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -0,0 +1,11 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================
The examples in this folder are adopted from the SICStus Prolog manual.
To load this example and for sample queries, please see the SCRIPT file.

View File

@@ -0,0 +1,120 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================
% start by loading the necessary library support files (if not
% already loaded):
| ?- logtalk_load([library(hierarchies_loader), library(types_loader)]).
...
% now you are ready for loading the example:
| ?- logtalk_load(sicstus(loader)).
...
% try some simple queries:
| ?- sort(rational)::sort([1/8, 2/7, 6/5, 2/9, 1/3], Sorted).
Sorted = [1/8, 2/9, 2/7, 1/3, 6/5]
yes
| ?- sort(colours)::sort([orange, indigo, red, yellow, violet, blue, green], Sorted).
Sorted = [red, orange, yellow, green, blue, indigo, violet]
yes
% using the pseudo-object user implies using the Prolog built-in standard
% order operators:
| ?- sort(user)::sort([3, 1, 4, 2, 9], Sorted).
Sorted = [1, 2, 3, 4, 9]
yes
% some messages testing object parameter passing and using:
| ?- red_circle(3)::color(Color).
Color = red
yes
| ?- red_circle(3)::area(Area).
Area = 28.274334
yes
| ?- red_circle(3)::ancestors(As).
As = [circle(3, red), ellipse(3, 3, red)]
yes
% show the execution context using a method (context/3) that is defined in the
% hierarchy root and specialized (using super calls) in each descendant:
| ?- red_circle(3)::context.
red_circle1
self: red_circle(3)
this: red_circle(3)
sender: user
circle2
self: red_circle(3)
this: circle(3,red)
sender: user
ellipse3
self: red_circle(3)
this: ellipse(3,3,red)
sender: user
yes
% send a conjunction of messages/goals to an object; just some useful syntax
% sugar:
| ?- square(2)::(side(Side), width(Width), height(Height), area(Area)).
Side = 2
Width = 2
Height = 2
Area = 4
yes
% find all messages accepted by an object:
| ?- square(2)::current_predicate(Pred).
Pred = side/1 ;
Pred = width/1 ;
Pred = height/1 ;
Pred = area/1
yes
% find all data on a specific message accepted by an object:
| ?- square(_)::predicate_property(side(_), Prop).
Prop = public ;
Prop = static ;
Prop = declared_in(square(_133)) ;
Prop = defined_in(square(_164))
yes

View File

@@ -0,0 +1,24 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.28.2
Copyright (c) 1998-2006 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 parametric objects to implement
symbolic expression differentiation and simplification.
Current limitations:
- the expression that we intend to differentiate or simplify
must be a compound term. Accepted functors are *, +, -, **, and log.
- use as a variable the atom x.
- only integers can be used as constants.
This example is still incomplete. For example, using sum distribution
property to simplify expressions is not yet implemented.

View File

@@ -0,0 +1,41 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================
% start by loading the example:
| ?- logtalk_load(symdiff(loader)).
...
% simplify the expression x^1 + x0 - x1
| ?- (x**1 + x*0 - x*1)::simplify(S).
S = 0
yes
% differentiate and then simplify the expression 2x^3 + x^2 - 4x
| ?- (2*x**3 + x**2 - 4*x)::diff(D), D::simplify(S).
D = 2*(3*x**2*1)+2*x**1*1-4*1
S = 2*(3*x**2)+2*x-4
yes
% differentiate and then simplify the expression ln(x^2 + 2x - 7) + 4x
| ?- (log(x**2 + 2*x - 7) + 4*x)::diff(D), D::simplify(S).
D = (2*x**1*1+2*1)*(x**2+2*x-7)** -1+4*1
S = (2*x+2)*(x**2+2*x-7)** -1+4
yes

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================

View File

@@ -1,6 +1,6 @@
=================================================================
Logtalk - Object oriented extension to Prolog
Release 2.27.1
Release 2.28.2
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
=================================================================